Commit 47fd1bae62d7826708ef0d6da31438e7a71a44f8

Con Kolivas 2013-11-30T23:10:57

Store a per-core nonce and hw error count for bflsc.

diff --git a/driver-bflsc.c b/driver-bflsc.c
index 5dafa9c..6f9d7b9 100644
--- a/driver-bflsc.c
+++ b/driver-bflsc.c
@@ -1219,15 +1219,32 @@ static bool bflsc_get_temp(struct cgpu_info *bflsc, int dev)
 	return true;
 }
 
+static void inc_bflsc_errors(struct thr_info *thr, struct bflsc_info *info, int8_t core)
+{
+	inc_hw_errors(thr);
+	if (core >= 0 && core < 16)
+		info->core_hw[core]++;
+	applog(LOG_WARNING, "Adding HW to core %d", core);
+}
+
+static void inc_bflsc_nonces(struct bflsc_info *info, int8_t core)
+{
+	if (core >= 0 && core < 16)
+		info->core_nonces[core]++;
+	applog(LOG_WARNING, "Adding Nonce to core %d", core);
+}
+
 static void process_nonces(struct cgpu_info *bflsc, int dev, char *xlink, char *data, int count, char **fields, int *nonces)
 {
 	struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
 	char midstate[MIDSTATE_BYTES], blockdata[MERKLE_BYTES];
+	struct thr_info *thr = bflsc->thr[0];
 	struct work *work;
+	int8_t core = -1;
 	uint32_t nonce;
 	int i, num, x;
-	bool res;
 	char *tmp;
+	bool res;
 
 	if (count < sc_info->que_fld_min) {
 		tmp = str_text(data);
@@ -1235,15 +1252,22 @@ static void process_nonces(struct cgpu_info *bflsc, int dev, char *xlink, char *
 				"%s%i:%s work returned too small (%d,%s)",
 				bflsc->drv->name, bflsc->device_id, xlink, count, tmp);
 		free(tmp);
-		inc_hw_errors(bflsc->thr[0]);
+		inc_bflsc_errors(thr, sc_info, core);
 		return;
 	}
 
+	if (sc_info->que_noncecount != QUE_NONCECOUNT_V1) {
+		unsigned int ucore;
+
+		if (sscanf(fields[QUE_CHIP_V2], "%x", &ucore) == 1)
+			core = ucore;
+	}
+
 	if (count > sc_info->que_fld_max) {
 		applog(LOG_INFO, "%s%i:%s work returned too large (%d) processing %d anyway",
 		       bflsc->drv->name, bflsc->device_id, xlink, count, sc_info->que_fld_max);
 		count = sc_info->que_fld_max;
-		inc_hw_errors(bflsc->thr[0]);
+		inc_bflsc_errors(thr, sc_info, core);
 	}
 
 	num = atoi(fields[sc_info->que_noncecount]);
@@ -1254,7 +1278,7 @@ static void process_nonces(struct cgpu_info *bflsc, int dev, char *xlink, char *
 				bflsc->drv->name, bflsc->device_id, xlink, num,
 				count - sc_info->que_fld_max, tmp);
 		free(tmp);
-		inc_hw_errors(bflsc->thr[0]);
+		inc_bflsc_errors(thr, sc_info, core);
 	}
 
 	memset(midstate, 0, MIDSTATE_BYTES);
@@ -1263,7 +1287,7 @@ static void process_nonces(struct cgpu_info *bflsc, int dev, char *xlink, char *
 	    !hex2bin((unsigned char *)blockdata, fields[QUE_BLOCKDATA], MERKLE_BYTES)) {
 		applog(LOG_INFO, "%s%i:%s Failed to convert binary data to hex result - ignored",
 		       bflsc->drv->name, bflsc->device_id, xlink);
-		inc_hw_errors(bflsc->thr[0]);
+		inc_bflsc_errors(thr, sc_info, core);
 		return;
 	}
 
@@ -1273,7 +1297,7 @@ static void process_nonces(struct cgpu_info *bflsc, int dev, char *xlink, char *
 		if (sc_info->not_first_work) {
 			applog(LOG_INFO, "%s%i:%s failed to find nonce work - can't be processed - ignored",
 			       bflsc->drv->name, bflsc->device_id, xlink);
-			inc_hw_errors(bflsc->thr[0]);
+			inc_bflsc_errors(thr, sc_info, core);
 		}
 		return;
 	}
@@ -1291,7 +1315,7 @@ static void process_nonces(struct cgpu_info *bflsc, int dev, char *xlink, char *
 
 		hex2bin((void*)&nonce, fields[i], 4);
 		nonce = htobe32(nonce);
-		res = submit_nonce(bflsc->thr[0], work, nonce);
+		res = submit_nonce(thr, work, nonce);
 		if (res) {
 			wr_lock(&(sc_info->stat_lock));
 			sc_info->sc_devs[dev].nonces_found++;
@@ -1299,6 +1323,7 @@ static void process_nonces(struct cgpu_info *bflsc, int dev, char *xlink, char *
 
 			(*nonces)++;
 			x++;
+			inc_bflsc_nonces(sc_info, core);
 		}
 	}
 
diff --git a/driver-bflsc.h b/driver-bflsc.h
index b547ded..b1d65fa 100644
--- a/driver-bflsc.h
+++ b/driver-bflsc.h
@@ -139,6 +139,8 @@ struct bflsc_info {
 	int que_noncecount;
 	int que_fld_min;
 	int que_fld_max;
+	int core_nonces[17];
+	int core_hw[17];
 	int flush_size;
 	// count of given size, [+2] is for any > QUE_MAX_RESULTS
 	uint64_t result_size[QUE_MAX_RESULTS+2];