Commit graph

11 commits

Author SHA1 Message Date
Phong Tran 6f8528e0be greybus: loopback: add more clean up when init connection fails
It should remove the object from sysfs when loopback
connection init error.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-14 09:49:04 -07:00
Alex Elder ac1c2840bd greybus: loopback: support module-initiated requests
There's no reason we can't support loopback pings or transfers
initiated by the module.  Allow it.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-12 10:25:14 -07:00
Alex Elder 48cc8b8bba greybus: loopback: define loopback functions symbolically
Add some symbols to indicate what kind of "function" the
loopback thread is supposed to be performing--the type of
traffic it generates over its connection.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-12 10:25:14 -07:00
Alex Elder 91262c3ab7 greybus: loopback: symbolically define max wait time
Use a symbolic constant to define the maximum time (number of
milliseconds) to delay between initiated operations.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-12 10:25:14 -07:00
Alex Elder 48f19ee824 greybus: loopback: fix an incorrect comment
Fix a comment that incorrectly says the delay between messages is
limited to 1024 msec; it actually must be <= 1000 msec.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-12 10:25:14 -07:00
Alex Elder 69f6034792 greybus: loopback: return the right error value
If an error occurs starting up the loopback thread, the error code
is not extracted properly.  Fix that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-12 10:25:14 -07:00
Alex Elder a04c640e5c greybus: loopback: fix the type attribute check
In gb_loopback_check_attr(), the value of gb->type is checked for
validity.  The only valid values are 0, 1, and 2.  But the check
allows the value 3.  Fix that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-12 10:25:14 -07:00
Johan Hovold 1ffc12be55 greybus: loopback: fix 64-bit divisions
The code uses 64-bit divisions, which should be avoided, and also
prevents the module from loading on 32-bit systems:

	gb_loopback: Unknown symbol __aeabi_uldivmod (err 0)

Fix by using the kernel's 64-bit by 32-bit division implementation
do_div.

Compile tested only. I did not look very closely at the code itself.
Perhaps this could be worked around in some other way, but this silences
the linker warning and allows the module to be loaded.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-16 10:26:33 +02:00
Greg Kroah-Hartman 7a51b9362b greybus: loopback: use the attribute groups, not group
We should use the attribute groups, not group, for the device, so
add and remove it.  No one should ever be updating a sysfs group for a
device, as that can be pretty dangerous if you don't duplicate _all_
existing attribute for that device, and I don't think we were doing that
here.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-31 23:02:34 +02:00
Greg Kroah-Hartman 5679f783b1 greybus: loopback: fix build breakage about SZ_4K
x86 doesn't include SZ_4K somehow so explicitly include <linux/sizes.h>
to fix the build breakage.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-31 23:01:45 +02:00
Alexandre Bailon 355a705815 greybus: Add loopback protocol
Add a simple Greybus protocol in order to stress USB and Greybus.
This protocol currently support 2 requests: ping and transfer.

ping request is useful to measure latency.
Kernel send a ping request and firmware should respond with a ping.

The transfer request request is useful to stress Greybus and USB.
Kernel can send data from 0 to 4k and the firmware must send back the data to kernel.

This behaviour of gb-loopback module is controlled via sysfs.
Curently, connection sysfs folder is updated with new entries:
- type: Type of loopback message to send
  * 0 => Don't send message
  * 1 => Send ping message continuously (message without payload)
  * 2 => Send transer message continuously (message with payload)
- size: Size of transfer message payload: 0-4096 bytes
- ms_wait: Time to wait between two messages: 0-1024 ms

Module also export some statistics about connection:
- latency: Time to send and receive one message
- frequency: Number of packet sent per second on this cport
- throughput: Quantity of data sent and received on this cport
- error
All this statistics are cleared everytime type, size or ms_wait entries are updated.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-31 22:53:59 +02:00