Commit 6b2a39d298c8214c013a5a306a5c45c78cb7c589

Con Kolivas 2013-10-20T11:23:42

Add op stats1 processing for the hashfast driver.

diff --git a/driver-hashfast.c b/driver-hashfast.c
index b48195c..faf859b 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -520,6 +520,71 @@ static void hfa_update_die_statistics(struct hashfast_info *info, struct hf_head
 	l->stats_overrun += s->stats_overrun;
 }
 
+static void hfa_update_stats1(struct cgpu_info *hashfast, struct hashfast_info *info,
+			      struct hf_header *h)
+{
+	struct hf_long_usb_stats1 *s1 = &info->stats1;
+	struct hf_usb_stats1 *sd = (struct hf_usb_stats1 *)(h + 1);
+
+	s1->usb_rx_preambles += sd->usb_rx_preambles;
+	s1->usb_rx_receive_byte_errors += sd->usb_rx_receive_byte_errors;
+	s1->usb_rx_bad_hcrc += sd->usb_rx_bad_hcrc;
+
+	s1->usb_tx_attempts += sd->usb_tx_attempts;
+	s1->usb_tx_packets += sd->usb_tx_packets;
+	s1->usb_tx_timeouts += sd->usb_tx_timeouts;
+	s1->usb_tx_incompletes += sd->usb_tx_incompletes;
+	s1->usb_tx_endpointstalled += sd->usb_tx_endpointstalled;
+	s1->usb_tx_disconnected += sd->usb_tx_disconnected;
+	s1->usb_tx_suspended += sd->usb_tx_suspended;
+
+	s1->uart_tx_queue_dma += sd->uart_tx_queue_dma;
+	s1->uart_tx_interrupts += sd->uart_tx_interrupts;
+
+	s1->uart_rx_preamble_ints += sd->uart_rx_preamble_ints;
+	s1->uart_rx_missed_preamble_ints += sd->uart_rx_missed_preamble_ints;
+	s1->uart_rx_header_done += sd->uart_rx_header_done;
+	s1->uart_rx_data_done += sd->uart_rx_data_done;
+	s1->uart_rx_bad_hcrc += sd->uart_rx_bad_hcrc;
+	s1->uart_rx_bad_dma += sd->uart_rx_bad_dma;
+	s1->uart_rx_short_dma += sd->uart_rx_short_dma;
+	s1->uart_rx_buffers_full += sd->uart_rx_buffers_full;
+
+	if (sd->max_tx_buffers >  s1->max_tx_buffers)
+		s1->max_tx_buffers = sd->max_tx_buffers;
+	if (sd->max_rx_buffers >  s1->max_rx_buffers)
+		s1->max_rx_buffers = sd->max_rx_buffers;
+
+	applog(LOG_DEBUG, "HFA %d: OP_USB_STATS1:", hashfast->device_id);
+	applog(LOG_DEBUG, "      usb_rx_preambles:             %6d", sd->usb_rx_preambles);
+	applog(LOG_DEBUG, "      usb_rx_receive_byte_errors:   %6d", sd->usb_rx_receive_byte_errors);
+	applog(LOG_DEBUG, "      usb_rx_bad_hcrc:              %6d", sd->usb_rx_bad_hcrc);
+
+	applog(LOG_DEBUG, "      usb_tx_attempts:              %6d", sd->usb_tx_attempts);
+	applog(LOG_DEBUG, "      usb_tx_packets:               %6d", sd->usb_tx_packets);
+	applog(LOG_DEBUG, "      usb_tx_timeouts:              %6d", sd->usb_tx_timeouts);
+	applog(LOG_DEBUG, "      usb_tx_incompletes:           %6d", sd->usb_tx_incompletes);
+	applog(LOG_DEBUG, "      usb_tx_endpointstalled:       %6d", sd->usb_tx_endpointstalled);
+	applog(LOG_DEBUG, "      usb_tx_disconnected:          %6d", sd->usb_tx_disconnected);
+	applog(LOG_DEBUG, "      usb_tx_suspended:             %6d", sd->usb_tx_suspended);
+
+	applog(LOG_DEBUG, "      uart_tx_queue_dma:            %6d", sd->uart_tx_queue_dma);
+	applog(LOG_DEBUG, "      uart_tx_interrupts:           %6d", sd->uart_tx_interrupts);
+
+	applog(LOG_DEBUG, "      uart_rx_preamble_ints:        %6d", sd->uart_rx_preamble_ints);
+	applog(LOG_DEBUG, "      uart_rx_missed_preamble_ints: %6d", sd->uart_rx_missed_preamble_ints);
+	applog(LOG_DEBUG, "      uart_rx_header_done:          %6d", sd->uart_rx_header_done);
+	applog(LOG_DEBUG, "      uart_rx_data_done:            %6d", sd->uart_rx_data_done);
+	applog(LOG_DEBUG, "      uart_rx_bad_hcrc:             %6d", sd->uart_rx_bad_hcrc);
+	applog(LOG_DEBUG, "      uart_rx_bad_dma:              %6d", sd->uart_rx_bad_dma);
+	applog(LOG_DEBUG, "      uart_rx_short_dma:            %6d", sd->uart_rx_short_dma);
+	applog(LOG_DEBUG, "      uart_rx_buffers_full:         %6d", sd->uart_rx_buffers_full);
+
+	applog(LOG_DEBUG, "      max_tx_buffers:               %6d", sd->max_tx_buffers);
+	applog(LOG_DEBUG, "      max_rx_buffers:               %6d", sd->max_rx_buffers);
+
+    }
+
 static void *hfa_read(void *arg)
 {
 	struct thr_info *thr = (struct thr_info *)arg;
@@ -552,7 +617,11 @@ static void *hfa_read(void *arg)
 				hfa_update_die_statistics(info, h);
 				break;
 			case OP_USB_STATS1:
+				hfa_update_stats1(hashfast, info, h);
+				break;
 			default:
+				applog(LOG_WARNING, "HFA %d: Unhandled operation code %d",
+				       hashfast->device_id, h->operation_code);
 				break;
 		}
 	}
diff --git a/driver-hashfast.h b/driver-hashfast.h
index acb5a0f..60fe98a 100644
--- a/driver-hashfast.h
+++ b/driver-hashfast.h
@@ -30,6 +30,40 @@ struct hf_long_statistics {
 	uint64_t stats_overrun;                     // Overrun in statistics reporting
 } __attribute__((packed,aligned(4)));
 
+// Matching fields for hf_usb_stats1, but large #'s for local accumulation, per device
+struct hf_long_usb_stats1 {
+	// USB incoming
+	uint64_t usb_rx_preambles;
+	uint64_t usb_rx_receive_byte_errors;
+	uint64_t usb_rx_bad_hcrc;
+
+	// USB outgoing
+	uint64_t usb_tx_attempts;
+	uint64_t usb_tx_packets;
+	uint64_t usb_tx_timeouts;
+	uint64_t usb_tx_incompletes;
+	uint64_t usb_tx_endpointstalled;
+	uint64_t usb_tx_disconnected;
+	uint64_t usb_tx_suspended;
+
+	// UART transmit
+	uint64_t uart_tx_queue_dma;
+	uint64_t uart_tx_interrupts;
+
+	// UART receive
+	uint64_t uart_rx_preamble_ints;
+	uint64_t uart_rx_missed_preamble_ints;
+	uint64_t uart_rx_header_done;
+	uint64_t uart_rx_data_done;
+	uint64_t uart_rx_bad_hcrc;
+	uint64_t uart_rx_bad_dma;
+	uint64_t uart_rx_short_dma;
+	uint64_t uart_rx_buffers_full;
+
+	uint8_t  max_tx_buffers;
+	uint8_t  max_rx_buffers;
+} __attribute__((packed,aligned(8)));
+
 struct hashfast_info {
 	int asic_count;                             // # of chips in the chain
 	int core_count;                             // # of cores per chip
@@ -39,6 +73,7 @@ struct hashfast_info {
 	uint16_t hash_sequence;                     // The next hash sequence # to be sent
 	struct hf_g1_die_data *die_status;          // Array of per-die voltage, current, temperature sensor data
 	struct hf_long_statistics *die_statistics;  // Array of per-die error counters
+	struct hf_long_usb_stats1 stats1;
 	int hash_clock_rate;                        // Hash clock rate to use, in Mhz
 	struct hf_usb_init_base usb_init_base;      // USB Base information from USB_INIT
 	struct hf_config_data config_data;          // Configuration data used from USB_INIT