Commit 84cfad02 authored by Bryan O'Donoghue's avatar Bryan O'Donoghue Committed by Greg Kroah-Hartman

greybus: loopback: add bitmask of connections to include in test

Feature add which enables the ability to select a bit-mask of connections
to run when executing a loopback test set. This is a feature add to
facilitate testing on the firmware side minus the necessity to recompile
firmware to support unicast (v) multicast (v) bitmask.
Signed-off-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 4b0ea00c
...@@ -42,6 +42,7 @@ struct gb_loopback_device { ...@@ -42,6 +42,7 @@ struct gb_loopback_device {
wait_queue_head_t wq; wait_queue_head_t wq;
int type; int type;
u32 mask;
u32 size; u32 size;
u32 iteration_max; u32 iteration_max;
u32 iteration_count; u32 iteration_count;
...@@ -267,6 +268,8 @@ gb_dev_loopback_rw_attr(ms_wait, d); ...@@ -267,6 +268,8 @@ gb_dev_loopback_rw_attr(ms_wait, d);
gb_dev_loopback_rw_attr(iteration_max, u); gb_dev_loopback_rw_attr(iteration_max, u);
/* The current index of the for (i = 0; i < iteration_max; i++) loop */ /* The current index of the for (i = 0; i < iteration_max; i++) loop */
gb_dev_loopback_ro_attr(iteration_count); gb_dev_loopback_ro_attr(iteration_count);
/* A bit-mask of destination connecitons to include in the test run */
gb_dev_loopback_rw_attr(mask, u);
#define dev_stats_attrs(name) \ #define dev_stats_attrs(name) \
&dev_attr_##name##_min.attr, \ &dev_attr_##name##_min.attr, \
...@@ -283,6 +286,7 @@ static struct attribute *loopback_attrs[] = { ...@@ -283,6 +286,7 @@ static struct attribute *loopback_attrs[] = {
&dev_attr_ms_wait.attr, &dev_attr_ms_wait.attr,
&dev_attr_iteration_count.attr, &dev_attr_iteration_count.attr,
&dev_attr_iteration_max.attr, &dev_attr_iteration_max.attr,
&dev_attr_mask.attr,
&dev_attr_error.attr, &dev_attr_error.attr,
NULL, NULL,
}; };
...@@ -322,6 +326,11 @@ static void gb_loopback_push_latency_ts(struct gb_loopback *gb, ...@@ -322,6 +326,11 @@ static void gb_loopback_push_latency_ts(struct gb_loopback *gb,
kfifo_in(&gb->kfifo_ts, (unsigned char *)te, sizeof(*te)); kfifo_in(&gb->kfifo_ts, (unsigned char *)te, sizeof(*te));
} }
static int gb_loopback_active(struct gb_loopback *gb)
{
return (gb_dev.mask == 0 || (gb_dev.mask & gb->lbid));
}
static int gb_loopback_sink(struct gb_loopback *gb, u32 len) static int gb_loopback_sink(struct gb_loopback *gb, u32 len)
{ {
struct timeval ts, te; struct timeval ts, te;
...@@ -574,6 +583,8 @@ static int gb_loopback_calculate_aggregate_stats(void) ...@@ -574,6 +583,8 @@ static int gb_loopback_calculate_aggregate_stats(void)
ts_min = 0; ts_min = 0;
te_max = 0; te_max = 0;
list_for_each_entry(gb, &gb_dev.list, entry) { list_for_each_entry(gb, &gb_dev.list, entry) {
if (!gb_loopback_active(gb))
continue;
if (kfifo_out(&gb->kfifo_ts, &ts, sizeof(ts)) < sizeof(ts)) if (kfifo_out(&gb->kfifo_ts, &ts, sizeof(ts)) < sizeof(ts))
goto error; goto error;
if (kfifo_out(&gb->kfifo_ts, &te, sizeof(te)) < sizeof(te)) if (kfifo_out(&gb->kfifo_ts, &te, sizeof(te)) < sizeof(te))
...@@ -653,10 +664,14 @@ static int gb_loopback_fn(void *data) ...@@ -653,10 +664,14 @@ static int gb_loopback_fn(void *data)
break; break;
mutex_lock(&gb_dev.mutex); mutex_lock(&gb_dev.mutex);
if (!gb_loopback_active(gb))
goto unlock_continue;
if (gb_dev.iteration_max) { if (gb_dev.iteration_max) {
/* Determine overall lowest count */ /* Determine overall lowest count */
low_count = gb->iteration_count; low_count = gb->iteration_count;
list_for_each_entry(gb_list, &gb_dev.list, entry) { list_for_each_entry(gb_list, &gb_dev.list, entry) {
if (!gb_loopback_active(gb_list))
continue;
if (gb_list->iteration_count < low_count) if (gb_list->iteration_count < low_count)
low_count = gb_list->iteration_count; low_count = gb_list->iteration_count;
} }
...@@ -670,8 +685,7 @@ static int gb_loopback_fn(void *data) ...@@ -670,8 +685,7 @@ static int gb_loopback_fn(void *data)
if (gb_dev.iteration_count == gb_dev.iteration_max) { if (gb_dev.iteration_count == gb_dev.iteration_max) {
gb_loopback_calculate_aggregate_stats(); gb_loopback_calculate_aggregate_stats();
gb_dev.type = 0; gb_dev.type = 0;
mutex_unlock(&gb_dev.mutex); goto unlock_continue;
continue;
} }
} }
size = gb_dev.size; size = gb_dev.size;
...@@ -706,6 +720,7 @@ static int gb_loopback_fn(void *data) ...@@ -706,6 +720,7 @@ static int gb_loopback_fn(void *data)
gb->iteration_count++; gb->iteration_count++;
mutex_unlock(&gb->mutex); mutex_unlock(&gb->mutex);
unlock_continue:
mutex_unlock(&gb_dev.mutex); mutex_unlock(&gb_dev.mutex);
sleep: sleep:
if (ms_wait) if (ms_wait)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment