Browse Source

INCOMPLETE Merge commit 'eab9deb' into bfgminer

This effectively reverts:
	d7372d1 API: Refactor device status into a single common function
	9dad7a8 API: Append Driver, Kernel, Model, and Device Path to device information
	74b9378 API: Move device-specific information fetching to the device API model with a new get_extra_device_info function
	db23372 Divide device info into "detail" (static information) and "status" (dynamic information), adding a new "devdetail" JSON API method to get the former
	f4e9426 API: Refactor devstatus method to make it simpler
	d78c36e Keep device/driver API clean by abstracting performance stats data request

Conflicts:
	api.c
	driver-icarus.c
	miner.h
Luke Dashjr 13 years ago
parent
commit
5cf2b2b360
3 changed files with 721 additions and 243 deletions
  1. 639 226
      api.c
  2. 29 16
      driver-icarus.c
  3. 53 1
      miner.h

File diff suppressed because it is too large
+ 639 - 226
api.c


+ 29 - 16
driver-icarus.c

@@ -777,31 +777,44 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 	return hash_count;
 }
 
-static json_t*
-icarus_perf_stats(struct cgpu_info *cgpu)
+//static void icarus_api_stats(char *buf, struct cgpu_info *cgpu, bool isjson)
+static struct api_data *icarus_api_stats(struct cgpu_info *cgpu)
 {
+	struct api_data *root = NULL;
 	struct ICARUS_INFO *info = icarus_info[cgpu->device_id];
 	json_t *ji = json_object();
 
 	// Warning, access to these is not locked - but we don't really
 	// care since hashing performance is way more important than
 	// locking access to displaying API debug 'stats'
-	json_object_set(ji, "read_count"    , json_integer(info->read_count    ));
-	json_object_set(ji, "fullnonce"     , json_real   (info->fullnonce     ));
-	json_object_set(ji, "count"         , json_integer(info->count         ));
-	json_object_set(ji, "Hs"            , json_real   (info->Hs            ));
-	json_object_set(ji, "W"             , json_real   (info->W             ));
-	json_object_set(ji, "total_values"  , json_integer(info->values        ));
-	json_object_set(ji, "range"         , json_integer(info->hash_count_range));
-	json_object_set(ji, "history_count" , json_integer(info->history_count ));
-	json_object_set(ji, "history_time"  , json_real   (
+	// If locking becomes an issue for any of them, use copy_data=true also
+	root = api_add_int(root, "read_count", &(info->read_count), false);
+	root = api_add_double(root, "fullnonce", &(info->fullnonce), false);
+	root = api_add_int(root, "count", &(info->count), false);
+	root = api_add_hs(root, "Hs", &(info->Hs), false);
+	root = api_add_double(root, "W", &(info->W), false);
+	root = api_add_uint(root, "total_values", &(info->values), false);
+	root = api_add_uint64(root, "range", &(info->hash_count_range), false);
+	root = api_add_uint64(root, "history_count", &(info->history_count), false);
+	root = api_add_timeval(root, "history_time", &(info->history_time), false);
+	root = api_add_uint(root, "min_data_count", &(info->min_data_count), false);
+	root = api_add_uint(root, "timing_values", &(info->history[0].values), false);
+	root = api_add_const(root, "timing_mode", timing_mode_str(info->timing_mode), false);
+	root = api_add_bool(root, "is_timing", &(info->do_icarus_timing), false);
+/*
+	sprintf(buf, isjson
+		? "\"read_count\":%d,\"fullnonce\":%f,\"count\":%d,\"Hs\":%.15f,\"W\":%f,\"total_values\":%u,\"range\":%"PRIu64",\"history_count\":%"PRIu64",\"history_time\":%f,\"min_data_count\":%u,\"timing_values\":%u"
+		: "read_count=%d,fullnonce=%f,count=%d,Hs=%.15f,W=%f,total_values=%u,range=%"PRIu64",history_count=%"PRIu64",history_time=%f,min_data_count=%u,timing_values=%u",
+		info->read_count, info->fullnonce,
+		info->count, info->Hs, info->W,
+		info->values, info->hash_count_range,
+		info->history_count,
 		(double)(info->history_time.tv_sec)
-			+ ((double)(info->history_time.tv_usec))/((double)1000000)
-	));
-	json_object_set(ji, "min_data_count", json_integer(info->min_data_count));
-	json_object_set(ji, "timing_values" , json_integer(info->history[0].values));
+			+ ((double)(info->history_time.tv_usec))/((double)1000000),
+		info->min_data_count, info->history[0].values);
+*/
 
-	return ji;
+	return root;
 }
 
 static void icarus_shutdown(struct thr_info *thr)

+ 53 - 1
miner.h

@@ -216,6 +216,7 @@ struct gpu_adl {
 };
 #endif
 
+struct api_data;
 struct thr_info;
 struct work;
 
@@ -232,7 +233,7 @@ struct device_api {
 	void (*get_statline)(char*, struct cgpu_info*);
 	json_t* (*get_extra_device_detail)(struct cgpu_info*);
 	json_t* (*get_extra_device_status)(struct cgpu_info*);
-	json_t* (*get_extra_device_perf_stats)(struct cgpu_info*);
+	struct api_data *(*get_api_stats)(struct cgpu_info*);
 
 	// Thread-specific functions
 	bool (*thread_prepare)(struct thr_info*);
@@ -771,4 +772,55 @@ extern bool successful_connect;
 extern void adl(void);
 extern void app_restart(void);
 
+enum api_data_type {
+	API_ESCAPE,
+	API_STRING,
+	API_CONST,
+	API_INT,
+	API_UINT,
+	API_UINT32,
+	API_UINT64,
+	API_DOUBLE,
+	API_ELAPSED,
+	API_BOOL,
+	API_TIMEVAL,
+	API_TIME,
+	API_MHS,
+	API_MHTOTAL,
+	API_TEMP,
+	API_UTILITY,
+	API_FREQ,
+	API_VOLTS,
+	API_HS
+};
+
+struct api_data {
+	enum api_data_type type;
+	char *name;
+	void *data;
+	bool data_was_malloc;
+	struct api_data *prev;
+	struct api_data *next;
+};
+
+extern struct api_data *api_add_escape(struct api_data *root, char *name, char *data, bool copy_data);
+extern struct api_data *api_add_string(struct api_data *root, char *name, char *data, bool copy_data);
+extern struct api_data *api_add_const(struct api_data *root, char *name, const char *data, bool copy_data);
+extern struct api_data *api_add_int(struct api_data *root, char *name, int *data, bool copy_data);
+extern struct api_data *api_add_uint(struct api_data *root, char *name, unsigned int *data, bool copy_data);
+extern struct api_data *api_add_uint32(struct api_data *root, char *name, uint32_t *data, bool copy_data);
+extern struct api_data *api_add_uint64(struct api_data *root, char *name, uint64_t *data, bool copy_data);
+extern struct api_data *api_add_double(struct api_data *root, char *name, double *data, bool copy_data);
+extern struct api_data *api_add_elapsed(struct api_data *root, char *name, double *data, bool copy_data);
+extern struct api_data *api_add_bool(struct api_data *root, char *name, bool *data, bool copy_data);
+extern struct api_data *api_add_timeval(struct api_data *root, char *name, struct timeval *data, bool copy_data);
+extern struct api_data *api_add_time(struct api_data *root, char *name, time_t *data, bool copy_data);
+extern struct api_data *api_add_mhs(struct api_data *root, char *name, double *data, bool copy_data);
+extern struct api_data *api_add_mhstotal(struct api_data *root, char *name, double *data, bool copy_data);
+extern struct api_data *api_add_temp(struct api_data *root, char *name, float *data, bool copy_data);
+extern struct api_data *api_add_utility(struct api_data *root, char *name, double *data, bool copy_data);
+extern struct api_data *api_add_freq(struct api_data *root, char *name, double *data, bool copy_data);
+extern struct api_data *api_add_volts(struct api_data *root, char *name, float *data, bool copy_data);
+extern struct api_data *api_add_hs(struct api_data *root, char *name, double *data, bool copy_data);
+
 #endif /* __MINER_H__ */

Some files were not shown because too many files changed in this diff