Browse Source

Merge commit '9950cff' into cgmerges

Conflicts:
	API-README
	api.c
Luke Dashjr 13 years ago
parent
commit
d7fb30aa56
4 changed files with 117 additions and 3 deletions
  1. 19 0
      API-README
  2. 45 1
      api.c
  3. 51 2
      driver-bitforce.c
  4. 2 0
      miner.h

+ 19 - 0
API-README

@@ -263,6 +263,22 @@ The list of requests - a (*) means it requires privileged access - and replies a
                               stating the results of the disable request
                               stating the results of the disable request
                               This is only available if PGA mining is enabled
                               This is only available if PGA mining is enabled
 
 
+ pgaidentify|N (*)
+               none           There is no reply section just the STATUS section
+                              stating the results of the identify request
+                              This is only available if PGA mining is enabled
+                              and currently only BFL singles support this command
+                              On a BFL single it will flash the led on the front
+                              of the device for appoximately 4s
+                              All other non BFL PGA devices will return a warning
+                              status message stating that they dont support it
+                              This adds a 4s delay to the BFL share being processed
+                              so you may get a message stating that procssing took
+                              longer than 7000ms if the request was sent towards
+                              the end of the timing of any work being worked on
+                              e.g.: BFL0: took 8438ms - longer than 7000ms
+                              You should ignore this
+
  devdetails    DEVDETAILS     Each device with a list of their static details
  devdetails    DEVDETAILS     Each device with a list of their static details
                               This lists all devices including those not supported
                               This lists all devices including those not supported
                               by the 'devs' command
                               by the 'devs' command
@@ -367,6 +383,9 @@ Feature Changelog for external applications using the API:
 
 
 API V1.19b
 API V1.19b
 
 
+Added API commands:
+ 'pgaidentify|N'
+
 Modified API commands:
 Modified API commands:
  'notify' - add '*Dev Throttle' (for BFL Singles)
  'notify' - add '*Dev Throttle' (for BFL Singles)
 
 

+ 45 - 1
api.c

@@ -396,6 +396,8 @@ static const char *JSON_PARAMETER = "parameter";
 #define MSG_FOO 77
 #define MSG_FOO 77
 #define MSG_MINECOIN 78
 #define MSG_MINECOIN 78
 #define MSG_DEBUGSET 79
 #define MSG_DEBUGSET 79
+#define MSG_PGAIDENT 80
+#define MSG_PGANOID 81
 
 
 #define MSG_SETCONFIG 82
 #define MSG_SETCONFIG 82
 #define MSG_UNKCON 83
 #define MSG_UNKCON 83
@@ -557,7 +559,10 @@ struct CODES {
  { SEVERITY_SUCC,  MSG_FOO,	PARAM_BOOL,	"Failover-Only set to %s" },
  { SEVERITY_SUCC,  MSG_FOO,	PARAM_BOOL,	"Failover-Only set to %s" },
  { SEVERITY_SUCC,  MSG_MINECOIN,PARAM_NONE,	"BFGMiner coin" },
  { SEVERITY_SUCC,  MSG_MINECOIN,PARAM_NONE,	"BFGMiner coin" },
  { SEVERITY_SUCC,  MSG_DEBUGSET,PARAM_STR,	"Debug settings" },
  { SEVERITY_SUCC,  MSG_DEBUGSET,PARAM_STR,	"Debug settings" },
-
+#ifdef HAVE_AN_FPGA
+ { SEVERITY_SUCC,  MSG_PGAIDENT,PARAM_PGA,	"Identify command sent to PGA%d" },
+ { SEVERITY_WARN,  MSG_PGANOID,	PARAM_PGA,	"PGA%d does not support identify" },
+#endif
  { SEVERITY_SUCC,  MSG_SETCONFIG,PARAM_SET,	"Set config '%s' to %d" },
  { SEVERITY_SUCC,  MSG_SETCONFIG,PARAM_SET,	"Set config '%s' to %d" },
  { SEVERITY_ERR,   MSG_UNKCON,	PARAM_STR,	"Unknown config '%s'" },
  { SEVERITY_ERR,   MSG_UNKCON,	PARAM_STR,	"Unknown config '%s'" },
  { SEVERITY_ERR,   MSG_INVNUM,	PARAM_BOTH,	"Invalid number (%d) for '%s' range is 0-9999" },
  { SEVERITY_ERR,   MSG_INVNUM,	PARAM_BOTH,	"Invalid number (%d) for '%s' range is 0-9999" },
@@ -1648,6 +1653,44 @@ static void pgadisable(__maybe_unused SOCKETTYPE c, char *param, bool isjson, __
 
 
 	strcpy(io_buffer, message(MSG_PGADIS, id, NULL, isjson));
 	strcpy(io_buffer, message(MSG_PGADIS, id, NULL, isjson));
 }
 }
+
+static void pgaidentify(__maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
+{
+	int numpga = numpgas();
+	int id;
+
+	if (numpga == 0) {
+		strcpy(io_buffer, message(MSG_PGANON, 0, NULL, isjson));
+		return;
+	}
+
+	if (param == NULL || *param == '\0') {
+		strcpy(io_buffer, message(MSG_MISID, 0, NULL, isjson));
+		return;
+	}
+
+	id = atoi(param);
+	if (id < 0 || id >= numpga) {
+		strcpy(io_buffer, message(MSG_INVPGA, id, NULL, isjson));
+		return;
+	}
+
+	int dev = pgadevice(id);
+	if (dev < 0) { // Should never happen
+		strcpy(io_buffer, message(MSG_INVPGA, id, NULL, isjson));
+		return;
+	}
+
+	struct cgpu_info *cgpu = devices[dev];
+	struct device_api *api = cgpu->api;
+
+	if (!api->identify_device)
+		strcpy(io_buffer, message(MSG_PGANOID, id, NULL, isjson));
+	else {
+		api->identify_device(cgpu);
+		strcpy(io_buffer, message(MSG_PGAIDENT, id, NULL, isjson));
+	}
+}
 #endif
 #endif
 
 
 #ifdef WANT_CPUMINE
 #ifdef WANT_CPUMINE
@@ -2880,6 +2923,7 @@ struct CMDS {
 	{ "pga",		pgadev,		false },
 	{ "pga",		pgadev,		false },
 	{ "pgaenable",		pgaenable,	true },
 	{ "pgaenable",		pgaenable,	true },
 	{ "pgadisable",		pgadisable,	true },
 	{ "pgadisable",		pgadisable,	true },
+	{ "pgaidentify",	pgaidentify,	true },
 #endif
 #endif
 #ifdef WANT_CPUMINE
 #ifdef WANT_CPUMINE
 	{ "cpu",		cpudev,		false },
 	{ "cpu",		cpudev,		false },

+ 51 - 2
driver-bitforce.c

@@ -76,6 +76,7 @@ static bool bitforce_detect_one(const char *devpath)
 	}
 	}
 
 
 	BFwrite(fdDev, "ZGX", 3);
 	BFwrite(fdDev, "ZGX", 3);
+	pdevbuf[0] = '\0';
 	BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 	BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 	if (unlikely(!pdevbuf[0])) {
 	if (unlikely(!pdevbuf[0])) {
 		applog(LOG_DEBUG, "BFL: Error reading/timeout (ZGX)");
 		applog(LOG_DEBUG, "BFL: Error reading/timeout (ZGX)");
@@ -205,6 +206,7 @@ void bitforce_init(struct cgpu_info *bitforce)
 
 
 	do {
 	do {
 		BFwrite(fdDev, "ZGX", 3);
 		BFwrite(fdDev, "ZGX", 3);
+		pdevbuf[0] = '\0';
 		BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 		BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 
 
 		if (unlikely(!pdevbuf[0])) {
 		if (unlikely(!pdevbuf[0])) {
@@ -234,6 +236,37 @@ void bitforce_init(struct cgpu_info *bitforce)
 	mutex_unlock(&bitforce->device_mutex);
 	mutex_unlock(&bitforce->device_mutex);
 }
 }
 
 
+static void bitforce_flash_led(struct cgpu_info *bitforce)
+{
+	int fdDev = bitforce->device_fd;
+
+	if (!fdDev)
+		return;
+
+	/* Do not try to flash the led if we're polling for a result to
+	 * minimise the chance of interleaved results */
+	if (bitforce->polling)
+		return;
+
+	/* It is not critical flashing the led so don't get stuck if we
+	 * can't grab the mutex here */
+	if (mutex_trylock(&bitforce->device_mutex))
+		return;
+
+	BFwrite(fdDev, "ZMX", 3);
+
+	/* Once we've tried - don't do it until told to again */
+	bitforce->flash_led = false;
+
+	/* However, this stops anything else getting a reply
+	 * So best to delay any other access to the BFL */
+	sleep(4);
+
+	mutex_unlock(&bitforce->device_mutex);
+
+	return; // nothing is returned by the BFL
+}
+
 static bool bitforce_get_temp(struct cgpu_info *bitforce)
 static bool bitforce_get_temp(struct cgpu_info *bitforce)
 {
 {
 	int fdDev = bitforce->device_fd;
 	int fdDev = bitforce->device_fd;
@@ -244,16 +277,23 @@ static bool bitforce_get_temp(struct cgpu_info *bitforce)
 		return false;
 		return false;
 
 
 	/* Do not try to get the temperature if we're polling for a result to
 	/* Do not try to get the temperature if we're polling for a result to
-	 * minimise the change of interleaved results */
+	 * minimise the chance of interleaved results */
 	if (bitforce->polling)
 	if (bitforce->polling)
 		return true;
 		return true;
 
 
-	/* It is not critical getting temperature so don't get stuck if  we
+	// Flash instead of Temp - doing both can be too slow
+	if (bitforce->flash_led) {
+		bitforce_flash_led(bitforce);
+ 		return true;
+	}
+
+	/* It is not critical getting temperature so don't get stuck if we
 	 * can't grab the mutex here */
 	 * can't grab the mutex here */
 	if (mutex_trylock(&bitforce->device_mutex))
 	if (mutex_trylock(&bitforce->device_mutex))
 		return false;
 		return false;
 
 
 	BFwrite(fdDev, "ZLX", 3);
 	BFwrite(fdDev, "ZLX", 3);
+	pdevbuf[0] = '\0';
 	BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 	BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 	mutex_unlock(&bitforce->device_mutex);
 	mutex_unlock(&bitforce->device_mutex);
 	
 	
@@ -310,6 +350,7 @@ re_send:
 		BFwrite(fdDev, "ZPX", 3);
 		BFwrite(fdDev, "ZPX", 3);
 	else
 	else
 		BFwrite(fdDev, "ZDX", 3);
 		BFwrite(fdDev, "ZDX", 3);
+	pdevbuf[0] = '\0';
 	BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 	BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 	if (!pdevbuf[0] || !strncasecmp(pdevbuf, "B", 1)) {
 	if (!pdevbuf[0] || !strncasecmp(pdevbuf, "B", 1)) {
 		mutex_unlock(&bitforce->device_mutex);
 		mutex_unlock(&bitforce->device_mutex);
@@ -350,6 +391,7 @@ re_send:
 		BFwrite(fdDev, ob, 68);
 		BFwrite(fdDev, ob, 68);
 	}
 	}
 
 
+	pdevbuf[0] = '\0';
 	BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 	BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 	mutex_unlock(&bitforce->device_mutex);
 	mutex_unlock(&bitforce->device_mutex);
 
 
@@ -400,6 +442,7 @@ static int64_t bitforce_get_result(struct thr_info *thr, struct work *work)
 	while (1) {
 	while (1) {
 		mutex_lock(&bitforce->device_mutex);
 		mutex_lock(&bitforce->device_mutex);
 		BFwrite(fdDev, "ZFX", 3);
 		BFwrite(fdDev, "ZFX", 3);
+		pdevbuf[0] = '\0';
 		BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 		BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 		mutex_unlock(&bitforce->device_mutex);
 		mutex_unlock(&bitforce->device_mutex);
 
 
@@ -557,6 +600,11 @@ static bool bitforce_get_stats(struct cgpu_info *bitforce)
 	return bitforce_get_temp(bitforce);
 	return bitforce_get_temp(bitforce);
 }
 }
 
 
+static void bitforce_identify(struct cgpu_info *bitforce)
+{
+	bitforce->flash_led = true;
+}
+
 static bool bitforce_thread_init(struct thr_info *thr)
 static bool bitforce_thread_init(struct thr_info *thr)
 {
 {
 	struct cgpu_info *bitforce = thr->cgpu;
 	struct cgpu_info *bitforce = thr->cgpu;
@@ -593,6 +641,7 @@ struct device_api bitforce_api = {
 	.reinit_device = bitforce_init,
 	.reinit_device = bitforce_init,
 	.get_statline_before = get_bitforce_statline_before,
 	.get_statline_before = get_bitforce_statline_before,
 	.get_stats = bitforce_get_stats,
 	.get_stats = bitforce_get_stats,
+	.identify_device = bitforce_identify,
 	.thread_prepare = bitforce_thread_prepare,
 	.thread_prepare = bitforce_thread_prepare,
 	.thread_init = bitforce_thread_init,
 	.thread_init = bitforce_thread_init,
 	.scanhash = bitforce_scanhash,
 	.scanhash = bitforce_scanhash,

+ 2 - 0
miner.h

@@ -278,6 +278,7 @@ struct device_api {
 	struct api_data* (*get_api_extra_device_status)(struct cgpu_info*);
 	struct api_data* (*get_api_extra_device_status)(struct cgpu_info*);
 	struct api_data *(*get_api_stats)(struct cgpu_info*);
 	struct api_data *(*get_api_stats)(struct cgpu_info*);
 	bool (*get_stats)(struct cgpu_info*);
 	bool (*get_stats)(struct cgpu_info*);
+	void (*identify_device)(struct cgpu_info*); // e.g. to flash a led
 
 
 	// Thread-specific functions
 	// Thread-specific functions
 	bool (*thread_prepare)(struct thr_info*);
 	bool (*thread_prepare)(struct thr_info*);
@@ -377,6 +378,7 @@ struct cgpu_info {
 	uint32_t nonces;
 	uint32_t nonces;
 	bool nonce_range;
 	bool nonce_range;
 	bool polling;
 	bool polling;
+	bool flash_led;
 #endif
 #endif
 	void *cgpu_data;
 	void *cgpu_data;
 	pthread_mutex_t		device_mutex;
 	pthread_mutex_t		device_mutex;