greybus: loopback: update throughput metrics to improve granularity
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Mon, 13 Jul 2015 19:20:51 +0000 (20:20 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Mon, 13 Jul 2015 22:42:01 +0000 (15:42 -0700)
Throughput capture should account for the entire size of the data going out
on the wire. In addition throughput should be captured for each supported
loopback operation.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/loopback.c

index f490648648cef12de2e90a0432bb9af9a5639d20..b92232b7a8812f17ebde7c581e418b64f1020f10 100644 (file)
@@ -340,10 +340,26 @@ static void gb_loopback_freq_update(struct gb_loopback *gb)
        gb_loopback_update_stats(&gb->frequency, gb->elapsed_nsecs);
 }
 
-static void gb_loopback_bw_update(struct gb_loopback *gb, int error)
+static void gb_loopback_throughput_update(struct gb_loopback *gb)
 {
-       if (!error)
-               gb->throughput.sum += gb->size * 2;
+       u32 aggregate_size = sizeof(struct gb_operation_msg_hdr) * 2;
+
+       switch (gb->type) {
+       case GB_LOOPBACK_TYPE_PING:
+               break;
+       case GB_LOOPBACK_TYPE_SINK:
+               aggregate_size += sizeof(struct gb_loopback_transfer_request) +
+                                 gb->size;
+               break;
+       case GB_LOOPBACK_TYPE_TRANSFER:
+               aggregate_size += sizeof(struct gb_loopback_transfer_request) +
+                                 sizeof(struct gb_loopback_transfer_response) +
+                                 gb->size * 2;
+               break;
+       default:
+               return;
+       }
+       gb->throughput.sum += aggregate_size;
        gb_loopback_update_stats(&gb->throughput, gb->elapsed_nsecs);
 }
 
@@ -393,8 +409,7 @@ static int gb_loopback_fn(void *data)
                gb->elapsed_nsecs = timeval_to_ns(&gb->te) -
                                        timeval_to_ns(&gb->ts);
                gb_loopback_freq_update(gb);
-               if (gb->type == GB_LOOPBACK_TYPE_PING)
-                       gb_loopback_bw_update(gb, error);
+               gb_loopback_throughput_update(gb);
                gb_loopback_latency_update(gb, &tlat);
                if (gb->elapsed_nsecs >= NSEC_PER_SEC)
                        gb->ts = gb->te;