/ driver-cointerra.h
driver-cointerra.h
1 /* 2 * Copyright 2013-2014 Con Kolivas <kernel@kolivas.org> 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License as published by the Free 6 * Software Foundation; either version 3 of the License, or (at your option) 7 * any later version. See COPYING for more details. 8 */ 9 10 #ifndef COINTERRA_H 11 #define COINTERRA_H 12 13 #define CTA_READBUF_SIZE 8192 14 #define CTA_MSG_SIZE 64 15 #define CTA_READ_TIMEOUT 1 16 #define CTA_READ_INTERVAL 100 17 #define CTA_SCAN_INTERVAL 500 18 #define CTA_RESET_TIMEOUT 1000 19 20 #define CTA_INIT_DIFF 32*0.9999847412109375 21 22 #if 0 23 /* FIXME: how big should this be? */ 24 #define CTA_MAX_QUEUE 2300 25 #else 26 #define CTA_MAX_QUEUE (32 / CTA_NROLL_TIME) 27 #endif 28 29 #define CTA_NROLL_TIME 2 30 31 /* Offsets into buffer */ 32 #define CTA_MSG_TYPE 2 33 #define CTA_RESET_TYPE 3 34 #define CTA_RESET_DIFF 4 35 #define CTA_RESET_LOAD 5 36 #define CTA_RESET_PSLOAD 6 37 #define CTA_DRIVER_TAG 3 38 #define CTA_MCU_TAG 5 39 #define CTA_MCU_CORE 5 40 #define CTA_MCU_ASIC 6 41 #define CTA_MCU_PIPE 8 42 #define CTA_MATCH_NOFFSET 45 43 #define CTA_MATCH_NONCE 60 44 #define CTA_WDONE_NONCES 11 45 #define CTA_MSG_RECVD 3 46 #define CTA_WORK_MIDSTATE 9 47 #define CTA_WORK_DATA 41 48 #define CTA_WORK_NROLL 53 49 #define CTA_WORK_DIFFBITS 55 50 #define CTA_REQWORK_REQUESTS 3 51 #define CTA_CORE_HASHRATES 3 52 53 /* Received message types */ 54 #define CTA_RECV_UNUSED 0 55 #define CTA_RECV_REQWORK 1 56 #define CTA_RECV_MATCH 2 57 #define CTA_RECV_WDONE 3 58 #define CTA_RECV_STATREAD 4 59 #define CTA_RECV_STATSET 5 60 #define CTA_RECV_INFO 6 61 #define CTA_RECV_MSG 7 62 #define CTA_RECV_RDONE 8 63 #define CTA_RECV_STATDEBUG 10 64 #define CTA_RECV_IRSTAT 11 65 66 /* Sent message types */ 67 #define CTA_SEND_UNUSED 0 68 #define CTA_SEND_RESET 1 69 #define CTA_SEND_WORK 2 70 #define CTA_SEND_SETPERF 3 71 #define CTA_SEND_REQUEST 4 72 #define CTA_SEND_FMATCH 5 73 #define CTA_SEND_IDENTIFY 6 74 #define CTA_SEND_COREHASHRATE 7 75 76 /* Types of reset in CTA_RESET_TYPE */ 77 #define CTA_RESET_NONE 0 78 #define CTA_RESET_UPDATE 1 79 #define CTA_RESET_NEW 2 80 #define CTA_RESET_INIT 3 81 82 #define CTA_INFO_HWREV 3 83 #define CTA_INFO_SERNO 5 84 #define CTA_INFO_NUMASICS 9 85 #define CTA_INFO_NUMDIES 10 86 #define CTA_INFO_NUMCORES 11 87 #define CTA_INFO_BOARDNUMBER 13 88 #define CTA_INFO_FWREV_MAJ 19 89 #define CTA_INFO_FWREV_MIN 20 90 #define CTA_INFO_FWREV_MIC 21 91 #define CTA_INFO_FWDATE_YEAR 23 92 #define CTA_INFO_FWDATE_MONTH 25 93 #define CTA_INFO_FWDATE_DAY 26 94 #define CTA_INFO_INITDIFFBITS 27 95 #define CTA_INFO_MINDIFFBITS 28 96 #define CTA_INFO_MAXDIFFBITS 29 97 98 #define CTA_STAT_CORETEMPS 3 99 #define CTA_STAT_AMBTEMP_LOW 19 100 #define CTA_STAT_AMBTEMP_AVG 21 101 #define CTA_STAT_AMBTEMP_HIGH 23 102 #define CTA_STAT_PUMP_TACHS 25 103 #define CTA_STAT_FAN_TACHS 29 104 #define CTA_STAT_CORE_VOLTS 37 105 #define CTA_STAT_VOLTS33 53 106 #define CTA_STAT_VOLTS12 55 107 #define CTA_STAT_INACTIVE 57 108 #define CTA_STAT_ACTIVE 59 109 110 #define CTA_STAT_PERFMODE 3 111 #define CTA_STAT_FANSPEEDS 11 112 #define CTA_STAT_DIES_ACTIVE 15 113 #define CTA_STAT_PIPES_ENABLED 16 114 #define CTA_STAT_MIN_FAN_SPEED 24 115 #define CTA_STAT_UPTIME 25 116 #define CTA_STAT_HEARTBEATS 29 117 #define CTA_STAT_CORE_FREQS 45 118 119 #define CTA_STAT_UNDERRUNS 3 120 #define CTA_STAT_HW_ERRORS 5 121 #define CTA_STAT_UPTIME_MS 21 122 #define CTA_STAT_HASHES 25 123 #define CTA_STAT_FLUSHED_HASHES 33 124 #define CTA_STAT_AUTOVOLTAGE 41 125 #define CTA_STAT_POWER_PERCENT 42 126 #define CTA_STAT_POWER_USED 43 127 #define CTA_STAT_VOLTAGE 45 128 #define CTA_STAT_IPOWER_USED 47 129 #define CTA_STAT_IVOLTAGE 49 130 #define CTA_STAT_PS_TEMP1 51 131 #define CTA_STAT_PS_TEMP2 53 132 133 #define CTA_IRSTAT_CHANNEL 3 134 #define CTA_IRSTAT_VIN 4 135 #define CTA_IRSTAT_IIN 6 136 #define CTA_IRSTAT_VOUT 8 137 #define CTA_IRSTAT_IOUT 10 138 #define CTA_IRSTAT_TEMP1 12 139 #define CTA_IRSTAT_TEMP2 14 140 #define CTA_IRSTAT_POUT 16 141 #define CTA_IRSTAT_PIN 18 142 #define CTA_IRSTAT_EFF 20 143 #define CTA_IRSTAT_STATUS 22 144 145 146 #define CTA_CORES 8 147 #define CTA_PUMPS 2 148 #define CTA_FANS 4 149 150 #define CTA_REQ_MSGTYPE 3 151 #define CTA_REQ_INTERVAL 5 152 153 154 int opt_cta_load; 155 int opt_ps_load; 156 157 struct cointerra_info { 158 /* Info data */ 159 uint16_t hwrev; 160 uint32_t serial; 161 uint8_t asics; 162 uint8_t dies; 163 uint16_t cores; 164 uint8_t board_number; 165 uint8_t fwrev[3]; 166 uint16_t fw_year; 167 uint8_t fw_month; 168 uint8_t fw_day; 169 uint8_t init_diffbits; 170 uint8_t min_diffbits; 171 uint8_t max_diffbits; 172 173 /* Status readings data */ 174 uint16_t coretemp[CTA_CORES]; 175 uint16_t ambtemp_low; 176 uint16_t ambtemp_avg; 177 uint16_t ambtemp_high; 178 uint16_t pump_tachs[CTA_PUMPS]; 179 uint16_t fan_tachs[CTA_FANS]; 180 uint16_t corevolts[CTA_CORES]; 181 uint16_t volts33; 182 uint16_t volts12; 183 uint16_t inactive; 184 uint16_t active; 185 uint16_t corefreqs[CTA_CORES]; 186 uint32_t uptime; 187 188 /* Status settings data */ 189 uint8_t coreperf[CTA_CORES]; 190 uint8_t fanspeed[CTA_FANS]; 191 uint8_t dies_active; 192 uint8_t pipes_enabled[CTA_CORES]; 193 194 /* Status debug data */ 195 uint16_t underruns; 196 uint16_t hw_errors[CTA_CORES]; 197 uint16_t fmatch_errors[CTA_CORES]; 198 199 /* Running total from debug messages */ 200 int tot_underruns; 201 uint16_t tot_hw_errors[CTA_CORES]; 202 uint64_t tot_hashes; 203 uint64_t tot_reset_hashes; 204 uint64_t tot_flushed_hashes; 205 uint8_t autovoltage; 206 uint8_t current_ps_percent; 207 uint16_t power_used; 208 uint16_t power_voltage; 209 uint16_t ipower_used; 210 uint16_t ipower_voltage; 211 uint16_t power_temps[2]; 212 213 bool autovoltage_complete; 214 215 /* Calculated totals based on work done and nonces found */ 216 uint64_t hashes; 217 uint64_t tot_calc_hashes; 218 219 /* Calculated totals based on shares returned */ 220 uint64_t share_hashes; 221 uint64_t tot_core_hashes[CTA_CORES]; 222 uint64_t tot_share_hashes; 223 struct timeval core_hash_start; 224 int requested; 225 uint16_t work_id; 226 int no_matching_work; 227 time_t last_pipe_nonce[1024]; 228 unsigned char pipe_bitmap[128]; 229 230 struct thr_info *thr; 231 pthread_mutex_t lock; 232 pthread_mutex_t sendlock; 233 pthread_cond_t wake_cond; 234 pthread_t read_thr; 235 cgsem_t reset_sem; 236 237 uint16_t irstat_vin[CTA_CORES]; 238 uint16_t irstat_iin[CTA_CORES]; 239 uint16_t irstat_vout[CTA_CORES]; 240 uint16_t irstat_iout[CTA_CORES]; 241 uint16_t irstat_temp1[CTA_CORES]; 242 uint16_t irstat_temp2[CTA_CORES]; 243 uint16_t irstat_pout[CTA_CORES]; 244 uint16_t irstat_pin[CTA_CORES]; 245 uint16_t irstat_efficiency[CTA_CORES]; 246 uint16_t irstat_status[CTA_CORES]; 247 248 uint64_t old_hashes[16 * 2]; 249 }; 250 251 #endif /* COINTERRA_H */