This repository has been archived by the owner on May 27, 2020. It is now read-only.
forked from jgarzik/cpuminer
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
driver-bitfury16.h
407 lines (326 loc) · 10.5 KB
/
driver-bitfury16.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
#ifndef BITFURY16_H
#define BITFURY16_H
#include "miner.h"
#include "bf16-bitfury16.h"
/* file contains device build revision: one of following */
/* #define MINER_X5 */
/* #define MINER_X6 */
/* #include "bf16-devicerev.h" */
#define MINER_X6
#if defined(MINER_X5) && defined(MINER_X6)
#error "MINER_X5 and MINER_X6 can not be defined both"
#endif
#if !defined(MINER_X5) && !defined(MINER_X6)
#error "At least one of MINER_X5 and MINER_X6 should be defined"
#endif
#define CHIPBOARD_NUM 2 /* chipboard number */
#define BF16_NUM 11 /* chips number per BTC250 concentrator */
#ifdef MINER_X5
#define BCM250_NUM 3 /* BCM250 chips per chipboard */
#define CHANNEL_DEPTH 2 /* maximum channel length */
#define CHIPS_NUM 26 /* BF16 chips per chipboard */
#endif
#ifdef MINER_X6
#define BCM250_NUM 6 /* BCM250 chips per chipboard */
#define CHANNEL_DEPTH 4 /* maximum channel length */
#define CHIPS_NUM 52 /* BF16 chips per chipboard */
#endif
#define FILELOG
enum bf_opt_renonce {
RENONCE_DISABLED,
RENONCE_ONE_CHIP,
RENONCE_CHIP_PER_BOARD
};
/* chip structure */
typedef struct {
uint8_t clock;
bf_chip_status_t status;
uint8_t curr_buff;
uint8_t task_processed;
/* nonces list to extract dups */
bf_list_t* nonce_list;
/* chip statistics */
float nonces;
float task_switch;
float status_cmd;
float status_cmd_none;
uint32_t nonces_dx;
uint32_t nonces_good_dx;
uint32_t nonces_diff_dx;
uint32_t nonces_bad_dx;
uint32_t nonces_re_dx;
uint32_t nonces_re_good_dx;
uint32_t nonces_re_bad_dx;
uint32_t task_switch_dx;
uint32_t status_cmd_dx;
uint32_t status_cmd_none_dx;
float hashrate;
float hashrate_good;
float hashrate_diff;
float hashrate_bad;
float hashrate_re;
float hashrate_re_good;
float hashrate_re_bad;
uint32_t errors; /* error counter */
uint32_t error_rate; /* error rate */
time_t last_error_time;/* time since last error */
uint16_t recovery_count;
time_t last_nonce_time;/* time since last good nonce */
struct timeval status_time; /* time since last status cmd */
struct timeval switch_time; /* time since last task switch */
/* command stuff */
bf_works_t owork; /* old work */
bf_works_t cwork; /* current work */
uint32_t rx[12];
uint32_t rx_prev[12];
} bf_chip_t;
/* chip concentrator init map structure */
typedef struct {
uint8_t channel_path[CHANNEL_DEPTH];
uint8_t first_good_chip;
uint8_t last_good_chip;
uint8_t chips_num;
} bf_bcm250_map_t;
/* chip concentrator structure */
typedef struct {
uint8_t* channel_path; /* channel path to chip concentrator */
uint8_t channel_depth;
uint8_t first_good_chip;
uint8_t last_good_chip;
uint8_t chips_num;
uint8_t chips_failed;
bf_chip_t chips[BF16_NUM];
/* chip statistics */
float nonces;
float task_switch;
float status_cmd;
float status_cmd_none;
uint32_t nonces_dx;
uint32_t nonces_good_dx;
uint32_t nonces_diff_dx;
uint32_t nonces_bad_dx;
uint32_t nonces_re_dx;
uint32_t nonces_re_good_dx;
uint32_t nonces_re_bad_dx;
uint32_t task_switch_dx;
uint32_t status_cmd_dx;
uint32_t status_cmd_none_dx;
float hashrate;
float hashrate_good;
float hashrate_diff;
float hashrate_bad;
float hashrate_re;
float hashrate_re_good;
float hashrate_re_bad;
} bf_bcm250_t;
/* pid structure */
typedef struct {
int16_t i_state; /* integrator state */
int16_t i_max; /* maximum allowable integrator state */
int16_t i_min; /* minimum allowable integrator state */
} bf_pid_t;
typedef enum {
CHIPBOARD_X5,
CHIPBOARD_X6
} bf_chipboard_type_t;
typedef enum {
CHIPBOARD_REV1,
CHIPBOARD_REV2,
CHIPBOARD_REV3
} bf_chipboard_rev_t;
/* chipboard structure */
typedef struct {
bool detected;
bool active;
bf_pid_t pid;
bf_chipboard_type_t board_type;
bf_chipboard_rev_t board_rev;
/* MSP version data */
uint32_t board_ver;
uint32_t board_fwver;
char board_hwid[32];
/* MSP hw data */
float temp;
float u_board;
float p_board;
uint8_t p_chain1_enabled;
uint8_t p_chain2_enabled;
float u_chain1;
float u_chain2;
float i_chain1;
float i_chain2;
float p_chain1;
float p_chain2;
float p_fan;
uint32_t rpm;
uint8_t fan_speed;
float i_alarm;
float t_alarm;
float t_gisteresis;
char fan_mode;
float target_temp;
uint8_t a_temp;
uint8_t a_ichain1;
uint8_t a_ichain2;
uint8_t bcm250_num;
uint8_t chips_num;
uint8_t chips_failed;
uint8_t chips_disabled;
bf_bcm250_t* bcm250;
#ifdef MINER_X5
bool power_disabled;
uint32_t power_disable_count;
time_t power_disable_time;
time_t power_enable_time;
#endif
#ifdef MINER_X6
bool power1_disabled;
bool power2_disabled;
uint32_t power1_disable_count;
uint32_t power2_disable_count;
time_t power1_disable_time;
time_t power2_disable_time;
time_t power1_enable_time;
time_t power2_enable_time;
#endif
bf_cmd_buffer_t cmd_buffer;
/* chip statistics */
float nonces;
float task_switch;
float status_cmd;
float status_cmd_none;
uint32_t nonces_dx;
uint32_t nonces_good_dx;
uint32_t nonces_diff_dx;
uint32_t nonces_bad_dx;
uint32_t nonces_re_dx;
uint32_t nonces_re_good_dx;
uint32_t nonces_re_bad_dx;
uint32_t task_switch_dx;
uint32_t status_cmd_dx;
uint32_t status_cmd_none_dx;
float hashrate;
float hashrate_good;
float hashrate_diff;
float hashrate_bad;
float hashrate_re;
float hashrate_re_good;
float hashrate_re_bad;
float txrx_speed;
uint32_t bytes_transmitted_dx;
uint64_t bytes_transmitted;
} bf_chipboard_t;
struct bitfury16_info {
struct thr_info *thr;
struct thr_info chipworker_thr;
struct thr_info nonceworker_thr;
struct thr_info renonceworker_thr;
struct thr_info hwmonitor_thr;
struct thr_info alarm_thr;
struct thr_info statistics_thr;
#ifdef FILELOG
FILE* logfile;
pthread_mutex_t logfile_mutex;
#endif
uint8_t chipboard_num;
/* boards with all sensors in propriate state */
uint8_t active_chipboard_num;
uint8_t chips_num;
uint8_t chips_failed;
uint8_t chips_disabled;
uint8_t renonce_chips;
bf_chipboard_t* chipboard;
/* work list */
bf_list_t* work_list;
/* work list */
bf_list_t* stale_work_list;
/* nonces for calculation */
bf_list_t* noncework_list;
/* renonces for calculation */
bf_list_t* renoncework_list;
/* nonces for recalculation */
uint32_t renonce_id;
bf_list_t* renonce_list;
uint32_t stage0_match;
uint32_t stage0_mismatch;
uint32_t stage1_match;
uint32_t stage1_mismatch;
uint32_t stage2_match;
uint32_t stage2_mismatch;
uint32_t stage3_match;
uint32_t stage3_mismatch;
uint32_t unmatched;
uint8_t channel_length;
/* driver statistics */
float nonces;
float task_switch;
float status_cmd;
float status_cmd_none;
uint32_t nonces_dx;
uint32_t nonces_good_dx;
uint32_t nonces_diff_dx;
uint32_t nonces_bad_dx;
uint32_t nonces_re_dx;
uint32_t nonces_re_good_dx;
uint32_t nonces_re_bad_dx;
uint32_t task_switch_dx;
uint32_t status_cmd_dx;
uint32_t status_cmd_none_dx;
float hashrate;
float hashrate_good;
float hashrate_diff;
float hashrate_bad;
float hashrate_re;
float hashrate_re_good;
float hashrate_re_bad;
pthread_mutex_t nonces_good_lock;
uint32_t nonces_good_cg;
float u_avg;
float i_total;
float p_total;
float u_chip;
float p_chip;
bool a_temp;
bool a_ichain;
bool a_net;
time_t ialarm_start;
uint16_t ialarm_count;
bool ialarm_buzzer;
bool led_red_enabled;
struct timeval led_red_switch;
bool led_green_enabled;
struct timeval led_green_switch;
bool buzzer_enabled;
struct timeval buzzer_switch;
bool initialised;
};
/* set clock to all chips and exit */
extern bool opt_bf16_set_clock;
/* enable board mining statistics output */
extern bool opt_bf16_stats_enabled;
/* chip clock value */
extern char* opt_bf16_clock;
extern uint8_t bf16_chip_clock;
/* renonce chip clock value */
extern char* opt_bf16_renonce_clock;
extern uint8_t bf16_renonce_chip_clock;
/* renonce configuration */
extern int opt_bf16_renonce;
/* manual PID enabled */
#ifdef MINER_X5
extern bool opt_bf16_manual_pid_enabled;
#endif
#ifdef MINER_X6
extern bool opt_bf16_manual_pid_disabled;
#endif
/* disable automatic power management */
extern bool opt_bf16_power_management_disabled;
/* fan speed */
extern int opt_bf16_fan_speed;
/* target temp */
extern int opt_bf16_target_temp;
/* alarm temp */
extern int opt_bf16_alarm_temp;
/* test chip communication */
extern char* opt_bf16_test_chip;
#endif /* BITFURY16_H */