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

Commit 12c1f428 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "diag: Split data stream for User PDs on LPASS"

parents c96d3a6e 839f1bb5
Loading
Loading
Loading
Loading
+94 −82
Original line number Diff line number Diff line
/* Copyright (c) 2008-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2008-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -28,8 +28,7 @@
#define DIAG_SET_FEATURE_MASK(x) (feature_bytes[(x)/8] |= (1 << (x & 0x7)))

#define diag_check_update(x)	\
	(!info || (info && (info->peripheral_mask & MD_PERIPHERAL_MASK(x))) \
	|| (info && (info->peripheral_mask & MD_PERIPHERAL_PD_MASK(x)))) \
	(!info || (info && (info->peripheral_mask & MD_PERIPHERAL_MASK(x)))) \

struct diag_mask_info msg_mask;
struct diag_mask_info msg_bt_mask;
@@ -87,16 +86,15 @@ static int diag_apps_responds(void)

static void diag_send_log_mask_update(uint8_t peripheral, int equip_id)
{
	int i;
	int err = 0;
	int send_once = 0;
	int err = 0, send_once = 0, i;
	int header_len = sizeof(struct diag_ctrl_log_mask);
	uint8_t *buf = NULL, *temp = NULL;
	uint8_t upd = 0;
	uint32_t mask_size = 0;
	uint32_t mask_size = 0, pd_mask = 0;
	struct diag_ctrl_log_mask ctrl_pkt;
	struct diag_mask_info *mask_info = NULL;
	struct diag_log_mask_t *mask = NULL;
	struct diagfwd_info *fwd_info = NULL;

	if (peripheral >= NUM_PERIPHERALS)
		return;
@@ -108,13 +106,14 @@ static void diag_send_log_mask_update(uint8_t peripheral, int equip_id)
		return;
	}

	MD_PERIPHERAL_PD_MASK(TYPE_CNTL, peripheral, pd_mask);

	if (driver->md_session_mask != 0) {
		if (driver->md_session_mask & MD_PERIPHERAL_MASK(peripheral)) {
			if (driver->md_session_map[peripheral])
				mask_info =
				driver->md_session_map[peripheral]->log_mask;
		} else if (driver->md_session_mask &
				MD_PERIPHERAL_PD_MASK(peripheral)) {
		} else if (driver->md_session_mask & pd_mask) {
			upd = diag_mask_to_pd_value(driver->md_session_mask);
			if (upd && driver->md_session_map[upd])
				mask_info =
@@ -213,12 +212,12 @@ static void diag_send_event_mask_update(uint8_t peripheral)
{
	uint8_t *buf = NULL, *temp = NULL;
	uint8_t upd = 0;
	uint32_t pd_mask = 0;
	int num_bytes = EVENT_COUNT_TO_BYTES(driver->last_event_id);
	int write_len = 0, err = 0, i = 0, temp_len = 0;
	struct diag_ctrl_event_mask header;
	struct diag_mask_info *mask_info = NULL;
	int num_bytes = EVENT_COUNT_TO_BYTES(driver->last_event_id);
	int write_len = 0;
	int err = 0;
	int temp_len = 0;
	struct diagfwd_info *fwd_info = NULL;

	if (num_bytes <= 0 || num_bytes > driver->event_mask_size) {
		pr_debug("diag: In %s, invalid event mask length %d\n",
@@ -236,13 +235,14 @@ static void diag_send_event_mask_update(uint8_t peripheral)
		return;
	}

	MD_PERIPHERAL_PD_MASK(TYPE_CNTL, peripheral, pd_mask);

	if (driver->md_session_mask != 0) {
		if (driver->md_session_mask & MD_PERIPHERAL_MASK(peripheral)) {
			if (driver->md_session_map[peripheral])
				mask_info =
				driver->md_session_map[peripheral]->event_mask;
		} else if (driver->md_session_mask &
				MD_PERIPHERAL_PD_MASK(peripheral)) {
		} else if (driver->md_session_mask & pd_mask) {
			upd = diag_mask_to_pd_value(driver->md_session_mask);
			if (upd && driver->md_session_map[upd])
				mask_info =
@@ -310,17 +310,16 @@ static void diag_send_event_mask_update(uint8_t peripheral)

static void diag_send_msg_mask_update(uint8_t peripheral, int first, int last)
{
	int i;
	int err = 0;
	int i, err = 0, temp_len = 0;
	int header_len = sizeof(struct diag_ctrl_msg_mask);
	int temp_len = 0;
	uint8_t *buf = NULL, *temp = NULL;
	uint8_t upd = 0;
	uint32_t mask_size = 0;
	uint8_t msg_mask_tbl_count_local;
	uint32_t mask_size = 0, pd_mask = 0;
	struct diag_mask_info *mask_info = NULL;
	struct diag_msg_mask_t *mask = NULL;
	struct diag_ctrl_msg_mask header;
	uint8_t msg_mask_tbl_count_local;
	struct diagfwd_info *fwd_info = NULL;

	if (peripheral >= NUM_PERIPHERALS)
		return;
@@ -332,13 +331,14 @@ static void diag_send_msg_mask_update(uint8_t peripheral, int first, int last)
		return;
	}

	MD_PERIPHERAL_PD_MASK(TYPE_CNTL, peripheral, pd_mask);

	if (driver->md_session_mask != 0) {
		if (driver->md_session_mask & MD_PERIPHERAL_MASK(peripheral)) {
			if (driver->md_session_map[peripheral])
				mask_info =
				driver->md_session_map[peripheral]->msg_mask;
		} else if (driver->md_session_mask &
				MD_PERIPHERAL_PD_MASK(peripheral)) {
		} else if (driver->md_session_mask & pd_mask) {
			upd = diag_mask_to_pd_value(driver->md_session_mask);
			if (upd && driver->md_session_map[upd])
				mask_info =
@@ -510,7 +510,7 @@ static void diag_send_feature_mask_update(uint8_t peripheral)
	if (driver->supports_apps_hdlc_encoding)
		DIAG_SET_FEATURE_MASK(F_DIAG_APPS_HDLC_ENCODE);
	if (driver->supports_apps_header_untagging) {
		if (peripheral == PERIPHERAL_MODEM) {
		if (driver->feature[peripheral].untag_header) {
			DIAG_SET_FEATURE_MASK(F_DIAG_PKT_HEADER_UNTAG);
			driver->peripheral_untag[peripheral] =
				ENABLE_PKT_HEADER_UNTAGGING;
@@ -707,18 +707,15 @@ static int diag_cmd_set_msg_mask(unsigned char *src_buf, int src_len,
				 unsigned char *dest_buf, int dest_len,
				 struct diag_md_session_t *info)
{
	int i;
	int write_len = 0;
	uint32_t mask_size = 0, offset = 0;
	uint32_t *temp = NULL;
	int write_len = 0, i = 0, found = 0, peripheral;
	int header_len = sizeof(struct diag_msg_build_mask_t);
	int found = 0;
	uint32_t mask_size = 0;
	uint32_t offset = 0;
	struct diag_msg_mask_t *mask = NULL;
	struct diag_msg_build_mask_t *req = NULL;
	struct diag_msg_build_mask_t rsp;
	struct diag_mask_info *mask_info = NULL;
	struct diag_msg_mask_t *mask_next = NULL;
	uint32_t *temp = NULL;

	mask_info = (!info) ? &msg_mask : info->msg_mask;
	if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0 ||
@@ -826,11 +823,18 @@ static int diag_cmd_set_msg_mask(unsigned char *src_buf, int src_len,
		mask_size = dest_len - write_len;
	memcpy(dest_buf + write_len, src_buf + header_len, mask_size);
	write_len += mask_size;
	for (i = 0; i < NUM_PERIPHERALS; i++) {
	for (i = 0; i < NUM_MD_SESSIONS; i++) {
		if (i == APPS_DATA)
			continue;
		if (!diag_check_update(i))
			continue;
		if (i > NUM_PERIPHERALS)
			peripheral = diag_search_peripheral_by_pd(i);
		else
			peripheral = i;
		mutex_lock(&driver->md_session_lock);
		diag_send_msg_mask_update(i, req->ssid_first, req->ssid_last);
		diag_send_msg_mask_update(peripheral, req->ssid_first,
			req->ssid_last);
		mutex_unlock(&driver->md_session_lock);
	}
end:
@@ -841,8 +845,7 @@ static int diag_cmd_set_all_msg_mask(unsigned char *src_buf, int src_len,
				     unsigned char *dest_buf, int dest_len,
				     struct diag_md_session_t *info)
{
	int i;
	int write_len = 0;
	int i, write_len = 0, peripheral;
	int header_len = sizeof(struct diag_msg_config_rsp_t);
	struct diag_msg_config_rsp_t rsp;
	struct diag_msg_config_rsp_t *req = NULL;
@@ -902,11 +905,17 @@ static int diag_cmd_set_all_msg_mask(unsigned char *src_buf, int src_len,
	memcpy(dest_buf, &rsp, header_len);
	write_len += header_len;

	for (i = 0; i < NUM_PERIPHERALS; i++) {
	for (i = 0; i < NUM_MD_SESSIONS; i++) {
		if (i == APPS_DATA)
			continue;
		if (!diag_check_update(i))
			continue;
		if (i > NUM_PERIPHERALS)
			peripheral = diag_search_peripheral_by_pd(i);
		else
			peripheral = i;
		mutex_lock(&driver->md_session_lock);
		diag_send_msg_mask_update(i, ALL_SSID, ALL_SSID);
		diag_send_msg_mask_update(peripheral, ALL_SSID, ALL_SSID);
		mutex_unlock(&driver->md_session_lock);
	}

@@ -953,9 +962,7 @@ static int diag_cmd_update_event_mask(unsigned char *src_buf, int src_len,
				      unsigned char *dest_buf, int dest_len,
				      struct diag_md_session_t *info)
{
	int i;
	int write_len = 0;
	int mask_len = 0;
	int i, write_len = 0, mask_len = 0, peripheral;
	int header_len = sizeof(struct diag_event_mask_config_t);
	struct diag_event_mask_config_t rsp;
	struct diag_event_mask_config_t *req;
@@ -1002,11 +1009,17 @@ static int diag_cmd_update_event_mask(unsigned char *src_buf, int src_len,
	memcpy(dest_buf + write_len, mask_info->ptr, mask_len);
	write_len += mask_len;

	for (i = 0; i < NUM_PERIPHERALS; i++) {
	for (i = 0; i < NUM_MD_SESSIONS; i++) {
		if (i == APPS_DATA)
			continue;
		if (!diag_check_update(i))
			continue;
		if (i > NUM_PERIPHERALS)
			peripheral = diag_search_peripheral_by_pd(i);
		else
			peripheral = i;
		mutex_lock(&driver->md_session_lock);
		diag_send_event_mask_update(i);
		diag_send_event_mask_update(peripheral);
		mutex_unlock(&driver->md_session_lock);
	}

@@ -1017,8 +1030,7 @@ static int diag_cmd_toggle_events(unsigned char *src_buf, int src_len,
				  unsigned char *dest_buf, int dest_len,
				  struct diag_md_session_t *info)
{
	int i;
	int write_len = 0;
	int write_len = 0, i, peripheral;
	uint8_t toggle = 0;
	struct diag_event_report_t header;
	struct diag_mask_info *mask_info = NULL;
@@ -1056,11 +1068,17 @@ static int diag_cmd_toggle_events(unsigned char *src_buf, int src_len,
	 */
	header.cmd_code = DIAG_CMD_EVENT_TOGGLE;
	header.padding = 0;
	for (i = 0; i < NUM_PERIPHERALS; i++) {
	for (i = 0; i < NUM_MD_SESSIONS; i++) {
		if (i == APPS_DATA)
			continue;
		if (!diag_check_update(i))
			continue;
		if (i > NUM_PERIPHERALS)
			peripheral = diag_search_peripheral_by_pd(i);
		else
			peripheral = i;
		mutex_lock(&driver->md_session_lock);
		diag_send_event_mask_update(i);
		diag_send_event_mask_update(peripheral);
		mutex_unlock(&driver->md_session_lock);
	}
	memcpy(dest_buf, &header, sizeof(header));
@@ -1207,19 +1225,17 @@ static int diag_cmd_set_log_mask(unsigned char *src_buf, int src_len,
				 unsigned char *dest_buf, int dest_len,
				 struct diag_md_session_t *info)
{
	int i;
	int write_len = 0;
	int i, peripheral, write_len = 0;
	int status = LOG_STATUS_SUCCESS;
	int read_len = 0;
	int payload_len = 0;
	int read_len = 0, payload_len = 0;
	int req_header_len = sizeof(struct diag_log_config_req_t);
	int rsp_header_len = sizeof(struct diag_log_config_set_rsp_t);
	uint32_t mask_size = 0;
	struct diag_log_config_req_t *req;
	struct diag_log_config_set_rsp_t rsp;
	struct diag_log_mask_t *mask = NULL;
	unsigned char *temp_buf = NULL;
	struct diag_mask_info *mask_info = NULL;
	unsigned char *temp_buf = NULL;

	mask_info = (!info) ? &log_mask : info->log_mask;
	if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0 ||
@@ -1331,11 +1347,17 @@ static int diag_cmd_set_log_mask(unsigned char *src_buf, int src_len,
	memcpy(dest_buf + write_len, src_buf + read_len, payload_len);
	write_len += payload_len;

	for (i = 0; i < NUM_PERIPHERALS; i++) {
	for (i = 0; i < NUM_MD_SESSIONS; i++) {
		if (i == APPS_DATA)
			continue;
		if (!diag_check_update(i))
			continue;
		if (i > NUM_PERIPHERALS)
			peripheral = diag_search_peripheral_by_pd(i);
		else
			peripheral = i;
		mutex_lock(&driver->md_session_lock);
		diag_send_log_mask_update(i, req->equip_id);
		diag_send_log_mask_update(peripheral, req->equip_id);
		mutex_unlock(&driver->md_session_lock);
	}
end:
@@ -1349,8 +1371,7 @@ static int diag_cmd_disable_log_mask(unsigned char *src_buf, int src_len,
	struct diag_mask_info *mask_info = NULL;
	struct diag_log_mask_t *mask = NULL;
	struct diag_log_config_rsp_t header;
	int write_len = 0;
	int i;
	int write_len = 0, i, peripheral;

	mask_info = (!info) ? &log_mask : info->log_mask;
	if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0 ||
@@ -1392,11 +1413,17 @@ static int diag_cmd_disable_log_mask(unsigned char *src_buf, int src_len,
	header.status = LOG_STATUS_SUCCESS;
	memcpy(dest_buf, &header, sizeof(struct diag_log_config_rsp_t));
	write_len += sizeof(struct diag_log_config_rsp_t);
	for (i = 0; i < NUM_PERIPHERALS; i++) {
	for (i = 0; i < NUM_MD_SESSIONS; i++) {
		if (i == APPS_DATA)
			continue;
		if (!diag_check_update(i))
			continue;
		if (i > NUM_PERIPHERALS)
			peripheral = diag_search_peripheral_by_pd(i);
		else
			peripheral = i;
		mutex_lock(&driver->md_session_lock);
		diag_send_log_mask_update(i, ALL_EQUIP_ID);
		diag_send_log_mask_update(peripheral, ALL_EQUIP_ID);
		mutex_unlock(&driver->md_session_lock);
	}

@@ -1430,8 +1457,7 @@ int diag_create_msg_mask_table_entry(struct diag_msg_mask_t *msg_mask,

static int diag_create_msg_mask_table(void)
{
	int i;
	int err = 0;
	int i, err = 0;
	struct diag_msg_mask_t *mask = (struct diag_msg_mask_t *)msg_mask.ptr;
	struct diag_ssid_range_t range;

@@ -1452,8 +1478,7 @@ static int diag_create_msg_mask_table(void)

static int diag_create_build_time_mask(void)
{
	int i;
	int err = 0;
	int i, err = 0;
	const uint32_t *tbl = NULL;
	uint32_t tbl_size = 0;
	struct diag_msg_mask_t *build_mask = NULL;
@@ -1649,8 +1674,7 @@ static void __diag_mask_exit(struct diag_mask_info *mask_info)

int diag_log_mask_copy(struct diag_mask_info *dest, struct diag_mask_info *src)
{
	int i;
	int err = 0;
	int i, err = 0;
	struct diag_log_mask_t *src_mask = NULL;
	struct diag_log_mask_t *dest_mask = NULL;

@@ -1716,8 +1740,7 @@ void diag_log_mask_free(struct diag_mask_info *mask_info)

static int diag_msg_mask_init(void)
{
	int err = 0;
	int i;
	int err = 0, i;

	err = __diag_mask_init(&msg_mask, MSG_MASK_SIZE, APPS_BUF_SIZE);
	if (err)
@@ -1738,12 +1761,10 @@ static int diag_msg_mask_init(void)

int diag_msg_mask_copy(struct diag_mask_info *dest, struct diag_mask_info *src)
{
	int i;
	int err = 0;
	int i, err = 0, mask_size = 0;
	struct diag_msg_mask_t *src_mask = NULL;
	struct diag_msg_mask_t *dest_mask = NULL;
	struct diag_ssid_range_t range;
	int mask_size = 0;

	if (!src || !dest)
		return -EINVAL;
@@ -1857,8 +1878,7 @@ static void diag_build_time_mask_exit(void)

static int diag_log_mask_init(void)
{
	int err = 0;
	int i;
	int err = 0, i;

	err = __diag_mask_init(&log_mask, LOG_MASK_SIZE, APPS_BUF_SIZE);
	if (err)
@@ -1891,8 +1911,7 @@ static void diag_log_mask_exit(void)

static int diag_event_mask_init(void)
{
	int err = 0;
	int i;
	int err = 0, i;

	err = __diag_mask_init(&event_mask, EVENT_MASK_SIZE, APPS_BUF_SIZE);
	if (err)
@@ -1945,11 +1964,8 @@ static void diag_event_mask_exit(void)
int diag_copy_to_user_msg_mask(char __user *buf, size_t count,
			       struct diag_md_session_t *info)
{
	int i;
	int err = 0;
	int len = 0;
	int copy_len = 0;
	int total_len = 0;
	int i, err = 0, len = 0;
	int copy_len = 0, total_len = 0;
	struct diag_msg_mask_userspace_t header;
	struct diag_mask_info *mask_info = NULL;
	struct diag_msg_mask_t *mask = NULL;
@@ -2029,11 +2045,8 @@ int diag_copy_to_user_msg_mask(char __user *buf, size_t count,
int diag_copy_to_user_log_mask(char __user *buf, size_t count,
			       struct diag_md_session_t *info)
{
	int i;
	int err = 0;
	int len = 0;
	int copy_len = 0;
	int total_len = 0;
	int i, err = 0, len = 0;
	int copy_len = 0, total_len = 0;
	struct diag_log_mask_userspace_t header;
	struct diag_log_mask_t *mask = NULL;
	struct diag_mask_info *mask_info = NULL;
@@ -2128,8 +2141,7 @@ void diag_send_updates_peripheral(uint8_t peripheral)
int diag_process_apps_masks(unsigned char *buf, int len,
			    struct diag_md_session_t *info)
{
	int size = 0;
	int sub_cmd = 0;
	int size = 0, sub_cmd = 0;
	int (*hdlr)(unsigned char *src_buf, int src_len,
		    unsigned char *dest_buf, int dest_len,
		    struct diag_md_session_t *info) = NULL;
+28 −7
Original line number Diff line number Diff line
/* Copyright (c) 2008-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2008-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -69,12 +69,17 @@
#define DIAG_CON_CDSP		(0x0040)	/* Bit mask for CDSP */

#define DIAG_CON_UPD_WLAN		(0x1000) /*Bit mask for WLAN PD*/
#define DIAG_CON_UPD_AUDIO		(0x2000) /*Bit mask for AUDIO PD*/
#define DIAG_CON_UPD_SENSORS	(0x4000) /*Bit mask for SENSORS PD*/

#define DIAG_CON_NONE		(0x0000)	/* Bit mask for No SS*/
#define DIAG_CON_ALL		(DIAG_CON_APSS | DIAG_CON_MPSS \
				| DIAG_CON_LPASS | DIAG_CON_WCNSS \
				| DIAG_CON_SENSORS | DIAG_CON_WDSP \
				| DIAG_CON_CDSP)
#define DIAG_CON_UPD_ALL	(DIAG_CON_UPD_WLAN)
#define DIAG_CON_UPD_ALL	(DIAG_CON_UPD_WLAN \
				| DIAG_CON_UPD_AUDIO \
				| DIAG_CON_UPD_SENSORS)

#define DIAG_STM_MODEM	0x01
#define DIAG_STM_LPASS	0x02
@@ -214,16 +219,23 @@
#define APPS_DATA		(NUM_PERIPHERALS)

#define UPD_WLAN		7
#define NUM_UPD			1
#define MAX_PERIPHERAL_UPD			1
#define UPD_AUDIO		8
#define UPD_SENSORS		9
#define NUM_UPD			3

#define MAX_PERIPHERAL_UPD			2
/* Number of sessions possible in Memory Device Mode. +1 for Apps data */
#define NUM_MD_SESSIONS		(NUM_PERIPHERALS \
					+ NUM_UPD + 1)

#define MD_PERIPHERAL_MASK(x)	(1 << x)

#define MD_PERIPHERAL_PD_MASK(x)					\
	((x == PERIPHERAL_MODEM) ? (1 << UPD_WLAN) : 0)\
#define MD_PERIPHERAL_PD_MASK(x, peripheral, pd_mask)	\
do {						\
	fwd_info = &peripheral_info[x][peripheral];	\
	for (i = 0; i <= fwd_info->num_pd - 2; i++)	\
		pd_mask |= (1 << fwd_info->upd_diag_id[i].pd);\
} while (0)

/*
 * Number of stm processors includes all the peripherals and
@@ -306,6 +318,8 @@ struct diag_cmd_diag_id_query_req_t {
struct diag_id_tbl_t {
	struct list_head link;
	uint8_t diag_id;
	uint8_t pd_val;
	uint8_t peripheral;
	char *process_name;
} __packed;
struct diag_id_t {
@@ -452,6 +466,10 @@ struct diag_logging_mode_param_t {
	uint32_t peripheral_mask;
	uint32_t pd_mask;
	uint8_t mode_param;
	uint8_t diag_id;
	uint8_t pd_val;
	uint8_t reserved;
	int peripheral;
} __packed;

struct diag_md_session_t {
@@ -693,7 +711,10 @@ int diag_cmd_chk_polling(struct diag_cmd_reg_entry_t *entry);
int diag_mask_param(void);
void diag_clear_masks(struct diag_md_session_t *info);
uint8_t diag_mask_to_pd_value(uint32_t peripheral_mask);

int diag_query_pd(char *process_name);
int diag_search_peripheral_by_pd(uint8_t pd_val);
uint8_t diag_search_diagid_by_pd(uint8_t pd_val,
	uint8_t *diag_id, int *peripheral);
void diag_record_stats(int type, int flag);

struct diag_md_session_t *diag_md_session_get_pid(int pid);
+172 −42
Original line number Diff line number Diff line
/* Copyright (c) 2008-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2008-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -395,25 +395,23 @@ static uint32_t diag_translate_kernel_to_user_mask(uint32_t peripheral_mask)
		ret |= DIAG_CON_CDSP;
	if (peripheral_mask & MD_PERIPHERAL_MASK(UPD_WLAN))
		ret |= DIAG_CON_UPD_WLAN;
	if (peripheral_mask & MD_PERIPHERAL_MASK(UPD_AUDIO))
		ret |= DIAG_CON_UPD_AUDIO;
	if (peripheral_mask & MD_PERIPHERAL_MASK(UPD_SENSORS))
		ret |= DIAG_CON_UPD_SENSORS;
	return ret;
}

uint8_t diag_mask_to_pd_value(uint32_t peripheral_mask)
{
	uint8_t upd = 0;
	uint32_t pd_mask = 0;

	pd_mask = diag_translate_kernel_to_user_mask(peripheral_mask);
	switch (pd_mask) {
	case DIAG_CON_UPD_WLAN:
		upd = UPD_WLAN;
		break;
	default:
		DIAG_LOG(DIAG_DEBUG_MASKS,
		"asking for mask update with no pd mask set\n");
	}
	for (upd = UPD_WLAN; upd < NUM_MD_SESSIONS; upd++) {
		if (peripheral_mask & (1 << upd))
			return upd;
	}
	return 0;
}

int diag_mask_param(void)
{
@@ -1621,18 +1619,19 @@ static uint32_t diag_translate_mask(uint32_t peripheral_mask)
		ret |= (1 << PERIPHERAL_CDSP);
	if (peripheral_mask & DIAG_CON_UPD_WLAN)
		ret |= (1 << UPD_WLAN);

	if (peripheral_mask & DIAG_CON_UPD_AUDIO)
		ret |= (1 << UPD_AUDIO);
	if (peripheral_mask & DIAG_CON_UPD_SENSORS)
		ret |= (1 << UPD_SENSORS);
	return ret;
}

static int diag_switch_logging(struct diag_logging_mode_param_t *param)
{
	int new_mode, i = 0;
	int curr_mode;
	int err = 0;
	uint8_t do_switch = 1;
	uint32_t peripheral_mask = 0;
	uint8_t peripheral, upd;
	int curr_mode, err = 0;
	uint8_t do_switch = 1, peripheral = 0;
	uint32_t peripheral_mask = 0, pd_mask = 0;

	if (!param)
		return -EINVAL;
@@ -1644,30 +1643,42 @@ static int diag_switch_logging(struct diag_logging_mode_param_t *param)
	}

	if (param->pd_mask) {
		switch (param->pd_mask) {
		case DIAG_CON_UPD_WLAN:
			peripheral = PERIPHERAL_MODEM;
			upd = UPD_WLAN;
		pd_mask = diag_translate_mask(param->pd_mask);
		for (i = UPD_WLAN; i < NUM_MD_SESSIONS; i++) {
			if (pd_mask & (1 << i)) {
				if (diag_search_diagid_by_pd(i, &param->diag_id,
					&param->peripheral)) {
					param->pd_val = i;
					break;
		default:
				}
			}
		}
		if (!param->diag_id) {
			DIAG_LOG(DIAG_DEBUG_USERSPACE,
			"asking for mode switch with no pd mask set\n");
			"diag_id support is not present for the pd mask = %d\n",
			param->pd_mask);
			return -EINVAL;
		}

		DIAG_LOG(DIAG_DEBUG_USERSPACE,
			"diag: pd_mask = %d, diag_id = %d, peripheral = %d, pd_val = %d\n",
			param->pd_mask, param->diag_id,
			param->peripheral, param->pd_val);

		peripheral = param->peripheral;
		if (driver->md_session_map[peripheral] &&
			(MD_PERIPHERAL_MASK(peripheral) &
			diag_mux->mux_mask)) {
			DIAG_LOG(DIAG_DEBUG_USERSPACE,
			"diag_fr: User PD is already logging onto active peripheral logging\n");
			i = upd - UPD_WLAN;
			i = param->pd_val - UPD_WLAN;
			driver->pd_session_clear[i] = 0;
			return -EINVAL;
		}
		peripheral_mask =
			diag_translate_mask(param->pd_mask);
		param->peripheral_mask = peripheral_mask;
		i = upd - UPD_WLAN;
		i = param->pd_val - UPD_WLAN;
		if (!driver->pd_session_clear[i]) {
			driver->pd_logging_mode[i] = 1;
			driver->num_pd_session += 1;
@@ -2023,11 +2034,126 @@ static int diag_ioctl_hdlc_toggle(unsigned long ioarg)
	return 0;
}

/*
 * diag_search_peripheral_by_pd(uint8_t pd_val)
 *
 * Function will return peripheral by searching pd in the
 * diag_id table.
 *
 */

int diag_search_peripheral_by_pd(uint8_t pd_val)
{
	struct list_head *start;
	struct list_head *temp;
	struct diag_id_tbl_t *item = NULL;

	mutex_lock(&driver->diag_id_mutex);
	list_for_each_safe(start, temp, &driver->diag_id_list) {
		item = list_entry(start, struct diag_id_tbl_t, link);
		if (pd_val == item->pd_val) {
			mutex_unlock(&driver->diag_id_mutex);
			return item->peripheral;
		}
	}
	mutex_unlock(&driver->diag_id_mutex);
	return -EINVAL;
}

/*
 * diag_search_diagid_by_pd(uint8_t pd_val,
 *	uint8_t *diag_id, int *peripheral)
 *
 * Function will update the peripheral and diag_id
 * from the pd passed as an argument.
 *
 */

uint8_t diag_search_diagid_by_pd(uint8_t pd_val,
	uint8_t *diag_id, int *peripheral)
{
	struct list_head *start;
	struct list_head *temp;
	struct diag_id_tbl_t *item = NULL;

	mutex_lock(&driver->diag_id_mutex);
	list_for_each_safe(start, temp, &driver->diag_id_list) {
		item = list_entry(start, struct diag_id_tbl_t, link);
		if (pd_val == item->pd_val) {
			*peripheral = item->peripheral;
			*diag_id = item->diag_id;
			mutex_unlock(&driver->diag_id_mutex);
			return 1;
		}
	}
	mutex_unlock(&driver->diag_id_mutex);
	return 0;
}

/*
 * diag_query_pd_name(char *process_name, char *search_str)
 *
 * The function searches the pd string in the control packet string
 * from the peripheral
 *
 */

static int diag_query_pd_name(char *process_name, char *search_str)
{
	if (!process_name)
		return -EINVAL;

	if (strnstr(process_name, search_str, strlen(process_name)))
		return 1;

	return 0;
}

/*
 * diag_query_pd_name(char *process_name, char *search_str)
 *
 * The function returns the PD information based on the presence of
 * the pd specific string in the control packet's string from peripheral.
 *
 */

int diag_query_pd(char *process_name)
{
	if (!process_name)
		return -EINVAL;

	if (diag_query_pd_name(process_name, "modem/root_pd"))
		return PERIPHERAL_MODEM;
	if (diag_query_pd_name(process_name, "adsp/root_pd"))
		return PERIPHERAL_LPASS;
	if (diag_query_pd_name(process_name, "slpi/root_pd"))
		return PERIPHERAL_SENSORS;
	if (diag_query_pd_name(process_name, "cdsp/root_pd"))
		return PERIPHERAL_CDSP;
	if (diag_query_pd_name(process_name, "wlan_pd"))
		return UPD_WLAN;
	if (diag_query_pd_name(process_name, "audio_pd"))
		return UPD_AUDIO;
	if (diag_query_pd_name(process_name, "sensor_pd"))
		return UPD_SENSORS;

	return -EINVAL;
}

/*
 * diag_ioctl_query_pd_logging(struct diag_logging_mode_param_t *param)
 *
 * IOCTL handler based on the parameter received will check on which peripheral
 * the PD is present and validate if the peripheral supports the diag_id and
 * tagging feature.
 *
 */

static int diag_ioctl_query_pd_logging(struct diag_logging_mode_param_t *param)
{
	int ret = -EINVAL;
	int peripheral;
	char *p_str = NULL;
	int ret = -EINVAL, i = 0;
	int peripheral = -EINVAL;
	uint32_t pd_mask = 0;

	if (!param)
		return -EINVAL;
@@ -2038,17 +2164,21 @@ static int diag_ioctl_query_pd_logging(struct diag_logging_mode_param_t *param)
		return -EINVAL;
	}

	switch (param->pd_mask) {
	case DIAG_CON_UPD_WLAN:
		peripheral = PERIPHERAL_MODEM;
		p_str = "MODEM";
	if (param->pd_mask) {
		pd_mask = diag_translate_mask(param->pd_mask);
		for (i = UPD_WLAN; i < NUM_MD_SESSIONS; i++) {
			if (pd_mask & (1 << i)) {
				peripheral = diag_search_peripheral_by_pd(i);
				break;
	default:
			}
		}
		if (peripheral < 0) {
			DIAG_LOG(DIAG_DEBUG_USERSPACE,
		"Invalid pd mask, returning EINVAL\n");
			"diag_id support is not present for the pd mask = %d\n",
			param->pd_mask);
			return -EINVAL;
		}

	}
	mutex_lock(&driver->diag_cntl_mutex);
	DIAG_LOG(DIAG_DEBUG_USERSPACE,
	"diag: %s: Untagging support on APPS is %s\n", __func__,
@@ -2056,8 +2186,8 @@ static int diag_ioctl_query_pd_logging(struct diag_logging_mode_param_t *param)
	"present" : "absent"));

	DIAG_LOG(DIAG_DEBUG_USERSPACE,
	"diag: %s: Tagging support on %s is %s\n",
	__func__, p_str,
	"diag: %s: Tagging support on peripheral = %d is %s\n",
	__func__, peripheral,
	(driver->feature[peripheral].untag_header ?
	"present" : "absent"));

@@ -3747,7 +3877,7 @@ static int __init diagchar_init(void)
		goto fail;
	mutex_init(&driver->diag_id_mutex);
	INIT_LIST_HEAD(&driver->diag_id_list);
	diag_add_diag_id_to_list(DIAG_ID_APPS, "APPS");
	diag_add_diag_id_to_list(DIAG_ID_APPS, "APPS", APPS_DATA, APPS_DATA);
	pr_debug("diagchar initialized now");
	ret = diagfwd_bridge_init();
	if (ret)
+6 −3
Original line number Diff line number Diff line
@@ -965,6 +965,8 @@ int diag_process_apps_pkt(unsigned char *buf, int len,
	struct diag_cmd_reg_entry_t entry;
	struct diag_cmd_reg_entry_t *temp_entry = NULL;
	struct diag_cmd_reg_t *reg_item = NULL;
	struct diagfwd_info *fwd_info = NULL;
	uint32_t pd_mask = 0;

	if (!buf)
		return -EIO;
@@ -1004,10 +1006,11 @@ int diag_process_apps_pkt(unsigned char *buf, int len,
		reg_item = container_of(temp_entry, struct diag_cmd_reg_t,
					entry);
		if (info) {
			MD_PERIPHERAL_PD_MASK(TYPE_CMD, reg_item->proc,
				pd_mask);
			if ((MD_PERIPHERAL_MASK(reg_item->proc) &
				info->peripheral_mask) ||
				(MD_PERIPHERAL_PD_MASK(reg_item->proc) &
				info->peripheral_mask))
				(pd_mask & info->peripheral_mask))
				write_len = diag_send_data(reg_item, buf, len);
		} else {
			if (MD_PERIPHERAL_MASK(reg_item->proc) &
+39 −31

File changed.

Preview size limit exceeded, changes collapsed.

Loading