Browse Source

usbutils add delay API stats

nfactor-troky
Kano 12 years ago
parent
commit
fc89f170a3
  1. 17
      api.c
  2. 25
      usbutils.c
  3. 5
      usbutils.h

17
api.c

@ -3023,10 +3023,10 @@ static int itemstats(struct io_data *io_data, int i, char *id, struct cgminer_st
if (cgpu) { if (cgpu) {
#ifdef USE_USBUTILS #ifdef USE_USBUTILS
char pipe_details[128]; char details[128];
if (cgpu->usbinfo.pipe_count) if (cgpu->usbinfo.pipe_count)
snprintf(pipe_details, sizeof(pipe_details), snprintf(details, sizeof(details),
"%"PRIu64" %"PRIu64"/%"PRIu64"/%"PRIu64" %lu", "%"PRIu64" %"PRIu64"/%"PRIu64"/%"PRIu64" %lu",
cgpu->usbinfo.pipe_count, cgpu->usbinfo.pipe_count,
cgpu->usbinfo.clear_err_count, cgpu->usbinfo.clear_err_count,
@ -3034,9 +3034,18 @@ static int itemstats(struct io_data *io_data, int i, char *id, struct cgminer_st
cgpu->usbinfo.clear_fail_count, cgpu->usbinfo.clear_fail_count,
(unsigned long)(cgpu->usbinfo.last_pipe)); (unsigned long)(cgpu->usbinfo.last_pipe));
else else
strcpy(pipe_details, "0"); strcpy(details, "0");
root = api_add_string(root, "USB Pipe", pipe_details, true); root = api_add_string(root, "USB Pipe", details, true);
snprintf(details, sizeof(details),
"r%"PRIu64" %.6f w%"PRIu64" %.6f",
cgpu->usbinfo.read_delay_count,
cgpu->usbinfo.total_read_delay,
cgpu->usbinfo.write_delay_count,
cgpu->usbinfo.total_write_delay);
root = api_add_string(root, "USB Delay", details, true);
#endif #endif
} }

25
usbutils.c

@ -2323,8 +2323,11 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro
tdiff(&(usbdev->last_write_tv), &now); tdiff(&(usbdev->last_write_tv), &now);
// Simple error condition check/avoidance '< 1.0' // Simple error condition check/avoidance '< 1.0'
if (need > 0.0 && need < 1.0) if (need > 0.0 && need < 1.0) {
cgpu->usbinfo.read_delay_count++;
cgpu->usbinfo.total_read_delay += need;
nmsleep((unsigned int)(need * 1000.0)); nmsleep((unsigned int)(need * 1000.0));
}
} }
} }
STATS_TIMEVAL(&tv_start); STATS_TIMEVAL(&tv_start);
@ -2429,8 +2432,11 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro
tdiff(&(usbdev->last_write_tv), &now); tdiff(&(usbdev->last_write_tv), &now);
// Simple error condition check/avoidance '< 1.0' // Simple error condition check/avoidance '< 1.0'
if (need > 0.0 && need < 1.0) if (need > 0.0 && need < 1.0) {
cgpu->usbinfo.read_delay_count++;
cgpu->usbinfo.total_read_delay += need;
nmsleep((unsigned int)(need * 1000.0)); nmsleep((unsigned int)(need * 1000.0));
}
} }
} }
STATS_TIMEVAL(&tv_start); STATS_TIMEVAL(&tv_start);
@ -2572,8 +2578,11 @@ int _usb_write(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pr
tdiff(&(usbdev->last_write_tv), &now); tdiff(&(usbdev->last_write_tv), &now);
// Simple error condition check/avoidance '< 1.0' // Simple error condition check/avoidance '< 1.0'
if (need > 0.0 && need < 1.0) if (need > 0.0 && need < 1.0) {
cgpu->usbinfo.write_delay_count++;
cgpu->usbinfo.total_write_delay += need;
nmsleep((unsigned int)(need * 1000.0)); nmsleep((unsigned int)(need * 1000.0));
}
} }
cgtime(&(usbdev->last_write_tv)); cgtime(&(usbdev->last_write_tv));
usbdev->last_write_siz = bufsiz; usbdev->last_write_siz = bufsiz;
@ -2666,8 +2675,11 @@ int __usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bReques
tdiff(&(usbdev->last_write_tv), &now); tdiff(&(usbdev->last_write_tv), &now);
// Simple error condition check/avoidance '< 1.0' // Simple error condition check/avoidance '< 1.0'
if (need > 0.0 && need < 1.0) if (need > 0.0 && need < 1.0) {
cgpu->usbinfo.write_delay_count++;
cgpu->usbinfo.total_write_delay += need;
nmsleep((unsigned int)(need * 1000.0)); nmsleep((unsigned int)(need * 1000.0));
}
} }
cgtime(&(usbdev->last_write_tv)); cgtime(&(usbdev->last_write_tv));
usbdev->last_write_siz = siz; usbdev->last_write_siz = siz;
@ -2740,8 +2752,11 @@ int _usb_transfer_read(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRe
tdiff(&(usbdev->last_write_tv), &now); tdiff(&(usbdev->last_write_tv), &now);
// Simple error condition check/avoidance '< 1.0' // Simple error condition check/avoidance '< 1.0'
if (need > 0.0 && need < 1.0) if (need > 0.0 && need < 1.0) {
cgpu->usbinfo.read_delay_count++;
cgpu->usbinfo.total_read_delay += need;
nmsleep((unsigned int)(need * 1000.0)); nmsleep((unsigned int)(need * 1000.0));
}
} }
} }
STATS_TIMEVAL(&tv_start); STATS_TIMEVAL(&tv_start);

5
usbutils.h

@ -210,6 +210,11 @@ struct cg_usb_info {
uint64_t clear_err_count; uint64_t clear_err_count;
uint64_t retry_err_count; uint64_t retry_err_count;
uint64_t clear_fail_count; uint64_t clear_fail_count;
uint64_t read_delay_count;
double total_read_delay;
uint64_t write_delay_count;
double total_write_delay;
}; };
enum usb_cmds { enum usb_cmds {

Loading…
Cancel
Save