Commit Graph

55 Commits

Author SHA1 Message Date
Bjorn Andersson
cb2dcc4ccb dm: Transition all senders to use dm_send()
Transition all calls to hdlc_enqueue on the client out-queue to use
dm_send(). This reduces the need for clients to know the workings of the
transmition and knowledge of the diag_client struct.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-24 22:10:29 -08:00
Bjorn Andersson
365aa41212 dm: Introduce Diagnostic Monitor abstraction
Move common helpers related to "diag clients" into a "Diagnostics
Monitor" implementation. This becomes necessary in order to support
non-HDLC encoding between the DM and device transparently to the
rest of the implementation.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-24 22:10:17 -08:00
Bjorn Andersson
31dd6573b9 hdlc: Decode HDLC data from a circular buffer
In order to support any sort of fragmentation in a stream based
transport, such as TCP/IP, the data is read into a circular buffer and
the HDLC decoder is turned into a reentrant consumer of said circular
buffer.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-24 21:38:46 -08:00
Bjorn Andersson
ce085f6055 circ_buf: Introduce circular buffer structure
This introduces a circular buffer and a read operation to store stream
data, from e.g. a TCP stream.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-24 21:38:46 -08:00
Bjorn Andersson
02ad780abc peripheral: Split data receive path in hdlc and raw
Split the two code paths related to handling of HDLC encoded vs raw
packets coming from the remote processor, this in order to facilitate
further rework of the HDLC decoder.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-24 21:38:46 -08:00
Bjorn Andersson
e57aa9a1ad dm: Encode forwarded responses
As we don't support dropping the HDLC encoding on the pipe between diag
and the DM we should encode the messages before putting them on the
wire. This was accidentally changed in a previous commit, but QXDM on
Mac doesn't seem to care about this.

Fixes: ed3c97ac76 ("diag: Add dynamic peripheral support")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 22:15:48 -08:00
Bjorn Andersson
c43b1b8ba4 peripheral: Abstract encoding logic related to send
The choice of encoding for outgoing messages is that of the peripheral,
so move this to the peripheral implementation to hide this from the
router.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 21:47:13 -08:00
Bjorn Andersson
851aa55136 uart: Correct file descriptor for read watch
As the code was moved around the wrong variable was used as read file
descriptor. Fix this.

Fixes: 258e749d6f ("diag: transport: Add support for UART connection to host PC")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 21:47:06 -08:00
Bjorn Andersson
dc9107f918 common_cmds: Remove uneccesary conditional
The masks in the request object can't be NULL, so remove the
conditional.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 21:46:27 -08:00
Bjorn Andersson
1be63d9bf8 common_cmds: Free mask pointer and use alloca()
The mask pointer was not freed, do this and simplify the code by
replacing the malloc with alloca().

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 21:45:13 -08:00
Bjorn Andersson
b639558f83 app_cmds: Fix memory leak and simplify implementation
The response object wasn't freed, use alloca() instead to allocate the
object on the stack. Also replace strncpy with strcpy as we specifically
allocate buffers sized to the two strings.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 21:41:48 -08:00
Bjorn Andersson
098f30c1c1 app_cmds: Cleanup DIAG_CMD_DIAG_VERSION_ID handler
The version id response consists of a command id and a hard coded
version id, so simplify the implementation.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 21:40:33 -08:00
Bjorn Andersson
7eeb864ca0 doc: Add udev rules example
This example of udev rules creates creates human readable names for
rpmsg_char control and endpoint device nodes as well as automatically
create endpoint devices for the various DIAG related channels found on
MSM8916.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 17:08:43 -08:00
Bjorn Andersson
ffe331aeb4 common_cmds: Correct and clean up OP_GET_BUILD_MASK
The response definition for OP_GET_BUILD_MASK was missing the range,
so add this and the associated logic. And while reworking that tidy up
the implementation a little bit.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 16:36:09 -08:00
Eyal Ilsar
27e54af3d3 diag: peripheral: Move data and command channel handlers to peripheral
Moved the incoming peripheral packet handling to the scope of the
peripheral.  Note that kept the essentially identical handlers separate
for debugging and possible future deviation in handling.

Signed-off-by: Eyal Ilsar <eilsar@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 16:36:09 -08:00
Eyal Ilsar
5b69368b97 diag: control: Add handling of deregistering control command (cmdid=27)
Implemented and registered handler for deregistering control command.

Signed-off-by: Eyal Ilsar <eilsar@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 16:36:09 -08:00
Eyal Ilsar
2dfd76ed2b diag: router: Add handling of Event Report Control command (cmd_id=96)
Implemented and registered a handler for the Event Report Control command
request.

Signed-off-by: Eyal Ilsar <eilsar@codeaurora.org>
[bjorn: Moved implementation to common_cmds.c,
	removed uncessary error handling of unkown status values,
	use return value to return bad command errors]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 16:36:09 -08:00
Eyal Ilsar
b06f733fbb diag: router: Add handling of Event Set Mask (cmd_id=130)
Implemented and registered a handler for the Event Set Mask command
request.

Signed-off-by: Eyal Ilsar <eilsar@codeaurora.org>
[bjorn: Moved implementation to common_cmds.c,
	replaced posix_memalign with malloc,
	use return value to send bad response,
	provide broadcast helper]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 16:36:09 -08:00
Eyal Ilsar
c899297d36 diag: router: Add handling of Event Get Mask (cmd_id=129)
Implemented and registered a handler for the Event Get Mask command
request.

Signed-off-by: Eyal Ilsar <eilsar@codeaurora.org>
[bjorn: Moved implementation to common_cmds.c,
	replace posix_memalign with malloc,
	use return code to signal errors]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 16:36:09 -08:00
Eyal Ilsar
266bfc4a4f diag: router: Add handling of Extended Message Configuration (cmd_id=125)
Implemented and registered a handler for the Extended Message
Configuration command request.

Signed-off-by: Eyal Ilsar <eilsar@codeaurora.org>
[bjorn: Replace posix_memalign with malloc,
	use return value to respond with error message,
	moved implementation to common_cmds.c,
	add peripheral broadcast helper for message masks,
	reworked GET_MSG_MASK to not modify the incoming buffer]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 16:36:09 -08:00
Eyal Ilsar
2955443bcc diag: router: Add handling of Logging Configuration command (cmd_id=115)
Implemented and registered a handler for the Logging Configuration command
request.

Signed-off-by: Eyal Ilsar <eilsar@codeaurora.org>
[bjorn: Move handler to common_cmds.c,
	abstract broadcasting the logmask to all peripherals,
	replace posix_memalign with malloc]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 16:36:09 -08:00
Eyal Ilsar
c040e70aa9 diag: router: Added handling of common commands
Signed-off-by: Eyal Ilsar <eilsar@codeaurora.org>
[bjorn: Split out from previous commit, added registration helper]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 16:36:09 -08:00
Eyal Ilsar
2df3b16ae4 diag: router: Add support for centralised handling of masks commands
Added initialisation of masks and broadcasting of MSG masks to new
peripherals.

Signed-off-by: Eyal Ilsar <eilsar@codeaurora.org>
[bjorn: Split out common_cmds handling to separate commit,
	broadcast message masks when new peripherals arrive,
	replace posix_memalign with malloc]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 16:36:09 -08:00
Eyal Ilsar
11b7deecf7 diag: router: Increase receive buffer sizes
Increased buffer size to accommodate for masks in command packets.

Signed-off-by: Eyal Ilsar <eilsar@codeaurora.org>
[bjorn: Extracted from another patch]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 16:36:09 -08:00
Eyal Ilsar
d2d6ff67af diag: control: Add support for sending masks to peripherals
1) Added masks support to features mask.
2) Implemented a call to create and send LOG mask control response packet
for a specific equipment id to a peripheral.
3) Implemented a call to create and send MSG mask control response packet
for a specific ssid range to a peripheral.
4) Implemented a call to create and send EVENT mask control response packet
to a peripheral.

Signed-off-by: Eyal Ilsar <eilsar@codeaurora.org>
[bjorn: Dropped posix_memalign usage, fixed up peripherial interfacing]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2018-01-23 16:36:09 -08:00