static void *hfa_read(void *arg) { struct thr_info *thr = (struct thr_info *)arg; struct cgpu_info *hashfast = thr->cgpu; struct hashfast_info *info = hashfast->device_data; char threadname[16]; snprintf(threadname, sizeof(threadname), "%d/%sRead", hashfast->device_id, hashfast->drv->name); RenameThread(threadname); while (likely(!hashfast->shutdown)) { char buf[512]; struct hf_header *h = (struct hf_header *)buf; bool ret = hfa_get_packet(hashfast, h); if (unlikely(hashfast->usbinfo.nodev)) break; if (unlikely(!ret)) continue; switch (h->operation_code) { case OP_GWQ_STATUS: hfa_parse_gwq_status(hashfast, info, h); break; case OP_DIE_STATUS: hfa_update_die_status(hashfast, info, h); break; case OP_NONCE: hfa_parse_nonce(thr, hashfast, info, h); break; case OP_STATISTICS: hfa_update_die_statistics(info, h); break; case OP_USB_STATS1: hfa_update_stats1(hashfast, info, h); break; case OP_USB_NOTICE: hfa_parse_notice(hashfast, h); break; case OP_PING: /* Do nothing */ break; default: applog(LOG_WARNING, "%s %d: Unhandled operation code %d", hashfast->drv->name, hashfast->device_id, h->operation_code); break; } /* Make sure we send something to the device at least every 5 * seconds so it knows the driver is still alive for when we * run out of work. The read thread never blocks so is the * best place to do this. */ if (time(NULL) - info->last_send > 5) hfa_send_frame(hashfast, HF_USB_CMD(OP_PING), 0, NULL, 0); } applog(LOG_DEBUG, "%s %d: Shutting down read thread", hashfast->drv->name, hashfast->device_id); return NULL; }
static void *hfa_read(void *arg) { struct thr_info *thr = (struct thr_info *)arg; struct cgpu_info *hashfast = thr->cgpu; struct hashfast_info *info = hashfast->device_data; char threadname[24]; snprintf(threadname, 24, "hfa_read/%d", hashfast->device_id); RenameThread(threadname); while (likely(!hashfast->shutdown)) { char buf[512]; struct hf_header *h = (struct hf_header *)buf; bool ret = hfa_get_packet(hashfast, h); if (unlikely(hashfast->usbinfo.nodev)) break; if (unlikely(!ret)) continue; switch (h->operation_code) { case OP_GWQ_STATUS: hfa_parse_gwq_status(hashfast, info, h); break; case OP_DIE_STATUS: hfa_update_die_status(hashfast, info, h); break; case OP_NONCE: hfa_parse_nonce(thr, hashfast, info, h); break; case OP_STATISTICS: hfa_update_die_statistics(info, h); break; case OP_USB_STATS1: hfa_update_stats1(hashfast, info, h); break; case OP_USB_NOTICE: hfa_parse_notice(hashfast, h); break; default: applog(LOG_WARNING, "HFA %d: Unhandled operation code %d", hashfast->device_id, h->operation_code); break; } } applog(LOG_DEBUG, "HFA %d: Shutting down read thread", hashfast->device_id); return NULL; }