Commit 0c071937320daaefc34fc9ec75e6a55c81994047

Con Kolivas 2014-05-05T21:13:55

Add basic API stats for nfu drivers to see how many submits each chip returns

diff --git a/driver-bitfury.c b/driver-bitfury.c
index 435753c..6951ccf 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -389,8 +389,7 @@ static void nfu_close(struct cgpu_info *bitfury)
 
 static bool nfu_reinit(struct cgpu_info *bitfury, struct bitfury_info *info)
 {
-	bool ret;
-
+	bool ret = true;
 	int i;
 
 	for (i = 0; i < info->chips; i++) {
@@ -424,6 +423,7 @@ static void nfu_alloc_arrays(struct bitfury_info *info)
 	info->second_run = calloc(sizeof(bool), info->chips);
 	info->work = calloc(sizeof(struct work *), info->chips);
 	info->owork = calloc(sizeof(struct work *), info->chips);
+	info->submits = calloc(sizeof(int *), info->chips);
 }
 
 static bool nfu_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
@@ -1540,6 +1540,20 @@ static struct api_data *bxf_api_stats(struct cgpu_info *bitfury, struct bitfury_
 	return root;
 }
 
+static struct api_data *nfu_api_stats(struct bitfury_info *info)
+{
+	struct api_data *root = NULL;
+	char buf[32];
+	int i;
+
+	root = api_add_int(root, "Chips", &info->chips, false);
+	for (i = 0; i < info->chips; i++) {
+		sprintf(buf, "Core%d submits", i);
+		root = api_add_int(root, buf, &info->submits[i], false);
+	}
+	return root;
+}
+
 static struct api_data *bitfury_api_stats(struct cgpu_info *cgpu)
 {
 	struct bitfury_info *info = cgpu->device_data;
@@ -1552,6 +1566,10 @@ static struct api_data *bitfury_api_stats(struct cgpu_info *cgpu)
 		case IDENT_OSM:
 			return bxf_api_stats(cgpu, info);
 			break;
+		case IDENT_NFU:
+		case IDENT_BXM:
+			return nfu_api_stats(info);
+			break;
 		default:
 			break;
 	}
diff --git a/libbitfury.c b/libbitfury.c
index 63da5b8..78f982c 100644
--- a/libbitfury.c
+++ b/libbitfury.c
@@ -370,8 +370,10 @@ bool libbitfury_sendHashData(struct thr_info *thr, struct cgpu_info *bitfury,
 					uint32_t nonce; //possible nonce
 
 					nonce = decnonce(newbuf[i]);
-					if (bitfury_checkresults(thr, info->owork[chip_n], nonce))
+					if (bitfury_checkresults(thr, info->owork[chip_n], nonce)) {
+						info->submits[chip_n]++;
 						info->nonces++;
+					}
 				}
 			}
 			memcpy(oldbuf, newbuf, 17 * 4);