|
|
@ -142,38 +142,20 @@ static char *SendCmdGetReply(struct cgpu_info *klncgpu, char Cmd, int device, in |
|
|
|
} |
|
|
|
} |
|
|
|
return NULL; |
|
|
|
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++) { |
|
|
|
static bool klondike_init(struct cgpu_info *klncgpu) |
|
|
|
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) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); |
|
|
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); |
|
|
|
bool allok = false; |
|
|
|
|
|
|
|
int slaves, dev; |
|
|
|
int slaves, dev; |
|
|
|
|
|
|
|
|
|
|
|
if (klncgpu->usbinfo.nodev) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *reply = SendCmdGetReply(klncgpu, 'S', 0, 0, NULL); |
|
|
|
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; |
|
|
|
slaves = ((WORKSTATUS *)(reply+2))->slavecount; |
|
|
|
if(klninfo->status == NULL) { |
|
|
|
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
|
|
|
|
// alloc space for status, devinfo and cfg for master and slaves
|
|
|
|
klninfo->status = calloc(slaves+1, sizeof(WORKSTATUS)); |
|
|
|
klninfo->status = calloc(slaves+1, sizeof(WORKSTATUS)); |
|
|
|
if (unlikely(!klninfo->status)) |
|
|
|
if (unlikely(!klninfo->status)) |
|
|
@ -184,26 +166,46 @@ static bool klondike_get_stats(struct cgpu_info *klncgpu) |
|
|
|
klninfo->cfg = calloc(slaves+1, sizeof(WORKCFG)); |
|
|
|
klninfo->cfg = calloc(slaves+1, sizeof(WORKCFG)); |
|
|
|
if (unlikely(!klninfo->cfg)) |
|
|
|
if (unlikely(!klninfo->cfg)) |
|
|
|
quit(1, "Failed to calloc cfg array in klondke_get_stats"); |
|
|
|
quit(1, "Failed to calloc cfg array in klondke_get_stats"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// where does saved user cfg info come from?
|
|
|
|
// where does saved user cfg info come from?
|
|
|
|
// todo: set user cfg to devices
|
|
|
|
// 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
|
|
|
|
SendCmdGetReply(klncgpu, 'E', 0, 1, "1"); |
|
|
|
wr_lock(&(klninfo->stat_lock)); |
|
|
|
|
|
|
|
klninfo->status[0] = *(WORKSTATUS *)(reply+2); |
|
|
|
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
|
|
|
|
if (klncgpu->usbinfo.nodev || klninfo->status == NULL) |
|
|
|
for(dev = 1; dev <= slaves; dev++) { |
|
|
|
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); |
|
|
|
char *reply = SendCmdGetReply(klncgpu, 'S', dev, 0, NULL); |
|
|
|
if(reply != NULL) |
|
|
|
if(reply != NULL) |
|
|
|
klninfo->status[dev] = *(WORKSTATUS *)(reply+2); |
|
|
|
klninfo->status[dev] = *(WORKSTATUS *)(reply+2); |
|
|
|
} |
|
|
|
} |
|
|
|
wr_unlock(&(klninfo->stat_lock)); |
|
|
|
wr_unlock(&(klninfo->stat_lock)); |
|
|
|
allok = true; |
|
|
|
|
|
|
|
} |
|
|
|
// todo: detect slavecount change and realloc space
|
|
|
|
return allok; |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool klondike_detect_one(struct libusb_device *dev, struct usb_find_devices *found) |
|
|
|
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) |
|
|
|
struct work *work, *tmp; |
|
|
|
struct work *work, *tmp; |
|
|
|
|
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Klondike FOUND NONCE (%02x:%08x)", result->workid, result->nonce); |
|
|
|
applog(LOG_DEBUG, "Klondike FOUND NONCE (%02x:%08x)", result->workid, result->nonce); |
|
|
|
|
|
|
|
|
|
|
|
HASH_ITER(hh, klncgpu->queued_work, work, tmp) { |
|
|
|
HASH_ITER(hh, klncgpu->queued_work, work, tmp) { |
|
|
|
if (work->queued && (work->subid == (result->device*256 + result->workid))) { |
|
|
|
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) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
klncgpu->drv->name, klncgpu->device_id, result->device, result->workid, result->nonce); |
|
|
|
//inc_hw_errors(klncgpu->thr[0]);
|
|
|
|
//inc_hw_errors(klncgpu->thr[0]);
|
|
|
|
} |
|
|
|
} |
|
|
@ -330,33 +333,11 @@ static void *klondike_get_replies(void *userdata) |
|
|
|
return NULL; |
|
|
|
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) |
|
|
|
static void klondike_flush_work(struct cgpu_info *klncgpu) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); |
|
|
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); |
|
|
|
int dev; |
|
|
|
int dev; |
|
|
|
|
|
|
|
|
|
|
|
if(klninfo->status == NULL) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Klondike flushing work work"); |
|
|
|
applog(LOG_DEBUG, "Klondike flushing work work"); |
|
|
|
for (dev = 0; dev <= klninfo->status->slavecount; dev++) { |
|
|
|
for (dev = 0; dev <= klninfo->status->slavecount; dev++) { |
|
|
|
char *reply = SendCmdGetReply(klncgpu, 'A', dev, 0, NULL); |
|
|
|
char *reply = SendCmdGetReply(klncgpu, 'A', dev, 0, NULL); |
|
|
@ -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) |
|
|
|
static bool klondike_thread_init(struct thr_info *thr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct cgpu_info *klncgpu = thr->cgpu; |
|
|
|
struct cgpu_info *klncgpu = thr->cgpu; |
|
|
@ -386,6 +385,9 @@ static void klondike_shutdown(struct thr_info *thr) |
|
|
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); |
|
|
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); |
|
|
|
|
|
|
|
|
|
|
|
klondike_flush_work(klncgpu); |
|
|
|
klondike_flush_work(klncgpu); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SendCmdGetReply(klncgpu, 'E', 0, 1, "0"); |
|
|
|
|
|
|
|
|
|
|
|
klninfo->shutdown = true; |
|
|
|
klninfo->shutdown = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -396,8 +398,8 @@ static void klondike_thread_enable(struct thr_info *thr) |
|
|
|
if (klncgpu->usbinfo.nodev) |
|
|
|
if (klncgpu->usbinfo.nodev) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
klondike_flush_work(klncgpu); |
|
|
|
SendCmdGetReply(klncgpu, 'E', 0, 1, "0"); |
|
|
|
klondike_get_cfgs(klncgpu); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool klondike_send_work(struct cgpu_info *klncgpu, int dev, struct work *work) |
|
|
|
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) |
|
|
|
uint8_t temp = 0xFF; |
|
|
|
uint8_t temp = 0xFF; |
|
|
|
int dev; |
|
|
|
int dev; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(klninfo->status == NULL) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
rd_lock(&(klninfo->stat_lock)); |
|
|
|
rd_lock(&(klninfo->stat_lock)); |
|
|
|
for (dev = 0; dev <= klninfo->status->slavecount; dev++) { |
|
|
|
for (dev = 0; dev <= klninfo->status->slavecount; dev++) { |
|
|
|
if (klninfo->status[dev].temp < temp) |
|
|
|
if (klninfo->status[dev].temp < temp) |
|
|
@ -509,6 +514,9 @@ static struct api_data *klondike_api_stats(struct cgpu_info *klncgpu) |
|
|
|
char buf[32]; |
|
|
|
char buf[32]; |
|
|
|
int dev; |
|
|
|
int dev; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(klninfo->status == NULL) |
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
|
|
rd_lock(&(klninfo->stat_lock)); |
|
|
|
rd_lock(&(klninfo->stat_lock)); |
|
|
|
for (dev = 0; dev <= klninfo->status->slavecount; dev++) { |
|
|
|
for (dev = 0; dev <= klninfo->status->slavecount; dev++) { |
|
|
|
|
|
|
|
|
|
|
|