Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b69c65bb authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "diag: Define new IPC mask for command request and response flow"

parents b3984317 d6b67122
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2015, 2017-2018 The Linux Foundation. All rights reserved.
/* Copyright (c) 2015, 2017-2019 The Linux Foundation. All rights reserved.
 */

#ifndef DIAGIPCLOG_H
@@ -16,6 +16,7 @@
#define DIAG_DEBUG_MASKS	0x0010
#define DIAG_DEBUG_POWER	0x0020
#define DIAG_DEBUG_BRIDGE	0x0040
#define DIAG_DEBUG_CMD_INFO	0x0080

#ifdef CONFIG_IPC_LOGGING
extern uint16_t diag_debug_mask;
+30 −7
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
 */

#include <linux/slab.h>
@@ -128,9 +128,10 @@ int diag_mux_queue_read(int proc)
int diag_mux_write(int proc, unsigned char *buf, int len, int ctx)
{
	struct diag_logger_t *logger = NULL;
	int peripheral;
	int peripheral = -EINVAL, type = -EINVAL, log_sink;
	unsigned char *offset = NULL;

	if (proc < 0 || proc >= NUM_MUX_PROC)
	if (proc < 0 || proc >= NUM_MUX_PROC || !buf)
		return -EINVAL;
	if (!diag_mux)
		return -EIO;
@@ -138,16 +139,38 @@ int diag_mux_write(int proc, unsigned char *buf, int len, int ctx)
	peripheral = diag_md_get_peripheral(ctx);
	if (peripheral < 0) {
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
			"diag:%s:%d invalid peripheral = %d\n",
			__func__, __LINE__, peripheral);
			"diag: invalid peripheral = %d\n", peripheral);
		return -EINVAL;
	}

	if (MD_PERIPHERAL_MASK(peripheral) & diag_mux->mux_mask)
	if (MD_PERIPHERAL_MASK(peripheral) & diag_mux->mux_mask) {
		logger = diag_mux->md_ptr;
	else
		log_sink = DIAG_MEMORY_DEVICE_MODE;
	} else {
		logger = diag_mux->usb_ptr;
		log_sink = DIAG_USB_MODE;
	}

	if (!proc) {
		type = GET_BUF_TYPE(ctx);
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
			"diag: Packet from PD: %d, type: %d, len: %d to be written to %s\n",
			peripheral, type, len,
			(log_sink ? "MD_device" : "USB"));

		if (type == TYPE_CMD) {
			if (driver->p_hdlc_disabled[peripheral])
				offset = buf + 4;
			else
				offset = buf;

			DIAG_LOG(DIAG_DEBUG_CMD_INFO,
				"diag: cmd rsp (%02x %02x %02x %02x) from PD: %d to be written to %s\n",
				*(offset), *(offset+1), *(offset+2),
				*(offset+3), peripheral,
				(log_sink ? "MD_device" : "USB"));
		}
	}
	if (logger && logger->log_ops && logger->log_ops->write)
		return logger->log_ops->write(proc, buf, len, ctx);
	return 0;
+2 −2
Original line number Diff line number Diff line
@@ -1029,8 +1029,8 @@ int diag_process_apps_pkt(unsigned char *buf, int len, int pid)
	entry.cmd_code_lo = (uint16_t)(*(uint16_t *)temp);
	temp += sizeof(uint16_t);

	pr_debug("diag: In %s, received cmd %02x %02x %02x\n",
		 __func__, entry.cmd_code, entry.subsys_id, entry.cmd_code_hi);
	DIAG_LOG(DIAG_DEBUG_CMD_INFO, "diag: received cmd %02x %02x %02x\n",
		 entry.cmd_code, entry.subsys_id, entry.cmd_code_hi);

	if (*buf == DIAG_CMD_LOG_ON_DMND && driver->log_on_demand_support &&
	    driver->feature[PERIPHERAL_MODEM].rcvd_feature_mask) {
+40 −2
Original line number Diff line number Diff line
@@ -444,6 +444,7 @@ static void diagfwd_data_read_untag_done(struct diagfwd_info *fwd_info,
	struct diagfwd_buf_t *temp_fwdinfo_upd = NULL;
	int flag_buf_1 = 0, flag_buf_2 = 0;
	uint8_t peripheral, temp_diagid_val;
	unsigned char *buf_offset = NULL;

	if (!fwd_info || !buf || len <= 0) {
		diag_ws_release();
@@ -498,9 +499,24 @@ static void diagfwd_data_read_untag_done(struct diagfwd_info *fwd_info,
		}

		while (processed < len) {
			/* Debug log to check diag_id header validity*/
			pr_debug("diag_fr:untagged packet buf contents: %02x %02x %02x %02x\n",
			 *temp_buf_main, *(temp_buf_main+1),
			 *(temp_buf_main+2), *(temp_buf_main+3));

			/* Debug log ONLY for CMD channel*/
			if (fwd_info->type == TYPE_CMD) {
				/* buf_offset taking into account
				 * diag_id header and non-hdlc header
				 */
				buf_offset = temp_buf_main + 8;

				DIAG_LOG(DIAG_DEBUG_CMD_INFO,
				"diag: cmd rsp (%02x %02x %02x %02x) received from peripheral: %d\n",
				*(buf_offset), *(buf_offset+1),
				*(buf_offset+2), *(buf_offset+3), peripheral);
			}

			packet_len =
				*(uint16_t *) (temp_buf_main + 2);
			if (packet_len > PERIPHERAL_BUF_SZ)
@@ -605,7 +621,7 @@ static void diagfwd_data_read_done(struct diagfwd_info *fwd_info,
{
	int err = 0;
	int write_len = 0;
	unsigned char *write_buf = NULL;
	unsigned char *write_buf = NULL, *buf_offset = NULL;
	struct diagfwd_buf_t *temp_buf = NULL;
	uint8_t hdlc_disabled = 0;

@@ -631,6 +647,16 @@ static void diagfwd_data_read_done(struct diagfwd_info *fwd_info,

	hdlc_disabled = driver->p_hdlc_disabled[fwd_info->peripheral];

	if (fwd_info->type == TYPE_CMD) {
		/*buf_offset taking into account non-hdlc header */
		buf_offset = buf + 4;

		DIAG_LOG(DIAG_DEBUG_CMD_INFO,
		"diag: cmd rsp(%02x %02x %02x %02x) received from peripheral: %d\n",
		*(buf_offset), *(buf_offset+1), *(buf_offset+2),
		*(buf_offset+3), fwd_info->peripheral);
	}

	if (!driver->feature[fwd_info->peripheral].encode_hdlc) {
		if (fwd_info->buf_1 && fwd_info->buf_1->data == buf) {
			temp_buf = fwd_info->buf_1;
@@ -1124,8 +1150,9 @@ int diagfwd_write(uint8_t peripheral, uint8_t type, void *buf, int len)
	int err = 0;
	uint8_t retry_count = 0;
	uint8_t max_retries = 3;
	unsigned char *temp_buf = NULL;

	if (peripheral >= NUM_PERIPHERALS || type >= NUM_TYPES)
	if (peripheral >= NUM_PERIPHERALS || type >= NUM_TYPES || !buf)
		return -EINVAL;

	if (type == TYPE_CMD || type == TYPE_DCI_CMD) {
@@ -1156,6 +1183,17 @@ int diagfwd_write(uint8_t peripheral, uint8_t type, void *buf, int len)
	if (!(fwd_info->p_ops && fwd_info->p_ops->write && fwd_info->ctxt))
		return -EIO;

	if (type == TYPE_CMD) {
		temp_buf = (unsigned char *)(buf);
		/* Only raw bytes is sent to peripheral,
		 * HDLC/NON-HDLC need not be considered
		 */
		DIAG_LOG(DIAG_DEBUG_CMD_INFO,
		"diag: cmd (%02x %02x %02x %02x) ready to be written to p: %d\n",
		*(temp_buf), *(temp_buf+1), *(temp_buf+2), *(temp_buf+3),
		peripheral);
	}

	while (retry_count < max_retries) {
		err = 0;
		err = fwd_info->p_ops->write(fwd_info->ctxt, buf, len);