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

Commit c2b5adaf 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 ee129a06 dc5e63d9
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -457,7 +457,9 @@ 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 (peripheral == PERIPHERAL_MODEM ||
			peripheral == PERIPHERAL_LPASS ||
			peripheral == PERIPHERAL_CDSP) {
			DIAG_SET_FEATURE_MASK(F_DIAG_PKT_HEADER_UNTAG);
			driver->peripheral_untag[peripheral] =
				ENABLE_PKT_HEADER_UNTAGGING;
+51 −43
Original line number Diff line number Diff line
@@ -129,6 +129,37 @@ void diag_md_close_all()
	diag_ws_reset(DIAG_WS_MUX);
}

static int diag_md_get_peripheral(int ctxt)
{
	int peripheral;

	if (driver->num_pd_session) {
		peripheral = GET_PD_CTXT(ctxt);
		switch (peripheral) {
		case UPD_WLAN:
		case UPD_AUDIO:
		case UPD_SENSORS:
			break;
		case DIAG_ID_MPSS:
		case DIAG_ID_LPASS:
		case DIAG_ID_CDSP:
		default:
			peripheral =
				GET_BUF_PERIPHERAL(ctxt);
			if (peripheral > NUM_PERIPHERALS)
				peripheral = -EINVAL;
			break;
		}
	} else {
		/* Account for Apps data as well */
		peripheral = GET_BUF_PERIPHERAL(ctxt);
		if (peripheral > NUM_PERIPHERALS)
			peripheral = -EINVAL;
	}

	return peripheral;
}

int diag_md_write(int id, unsigned char *buf, int len, int ctx)
{
	int i;
@@ -144,26 +175,13 @@ int diag_md_write(int id, unsigned char *buf, int len, int ctx)
	if (!buf || len < 0)
		return -EINVAL;

	if (driver->pd_logging_mode) {
		peripheral = GET_PD_CTXT(ctx);
		switch (peripheral) {
		case UPD_WLAN:
			break;
		case DIAG_ID_MPSS:
		default:
			peripheral = GET_BUF_PERIPHERAL(ctx);
			if (peripheral > NUM_PERIPHERALS)
				return -EINVAL;
			break;
		}
	} else {
		/* Account for Apps data as well */
		peripheral = GET_BUF_PERIPHERAL(ctx);
		if (peripheral > NUM_PERIPHERALS)
	peripheral =
		diag_md_get_peripheral(ctx);
	if (peripheral < 0)
		return -EINVAL;
	}

	session_info = diag_md_session_get_peripheral(peripheral);
	session_info =
		diag_md_session_get_peripheral(peripheral);
	if (!session_info)
		return -EIO;

@@ -243,31 +261,15 @@ int diag_md_copy_to_user(char __user *buf, int *pret, size_t buf_size,
			entry = &ch->tbl[j];
			if (entry->len <= 0)
				continue;
			if (driver->pd_logging_mode) {
				peripheral = GET_PD_CTXT(entry->ctx);
				switch (peripheral) {
				case UPD_WLAN:
					break;
				case DIAG_ID_MPSS:
				default:
					peripheral =
						GET_BUF_PERIPHERAL(entry->ctx);
					if (peripheral > NUM_PERIPHERALS)
						goto drop_data;
					break;
				}
			} else {
				/* Account for Apps data as well */
				peripheral = GET_BUF_PERIPHERAL(entry->ctx);
				if (peripheral > NUM_PERIPHERALS)

			peripheral = diag_md_get_peripheral(entry->ctx);
			if (peripheral < 0)
				goto drop_data;
			}

			session_info =
			diag_md_session_get_peripheral(peripheral);
			if (!session_info) {
				mutex_unlock(&driver->diagfwd_untag_mutex);
				return -EIO;
				goto drop_data;
			}

			if (session_info && info &&
@@ -363,9 +365,15 @@ int diag_md_close_peripheral(int id, uint8_t peripheral)
	spin_lock_irqsave(&ch->lock, flags);
	for (i = 0; i < ch->num_tbl_entries && !found; i++) {
		entry = &ch->tbl[i];
		if ((GET_BUF_PERIPHERAL(entry->ctx) != peripheral) ||
			(GET_PD_CTXT(entry->ctx) != peripheral))

		if (peripheral > NUM_PERIPHERALS) {
			if (GET_PD_CTXT(entry->ctx) != peripheral)
				continue;
		} else {
			if (GET_BUF_PERIPHERAL(entry->ctx) !=
					peripheral)
				continue;
		}
		found = 1;
		if (ch->ops && ch->ops->write_done) {
			ch->ops->write_done(entry->buf, entry->len,
+9 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
#include "diag_mux.h"
#include "diag_usb.h"
#include "diag_memorydevice.h"

#include "diag_ipc_logging.h"

struct diag_mux_state_t *diag_mux;
static struct diag_logger_t usb_logger;
@@ -146,7 +146,15 @@ int diag_mux_write(int proc, unsigned char *buf, int len, int ctx)
		case DIAG_ID_MPSS:
			upd = PERIPHERAL_MODEM;
			break;
		case DIAG_ID_LPASS:
			upd = PERIPHERAL_LPASS;
			break;
		case DIAG_ID_CDSP:
			upd = PERIPHERAL_CDSP;
			break;
		case UPD_WLAN:
		case UPD_AUDIO:
		case UPD_SENSORS:
			break;
		default:
			pr_err("diag: invalid pd ctxt= %d\n", upd);
+15 −4
Original line number Diff line number Diff line
@@ -76,7 +76,9 @@
				| 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
@@ -222,6 +224,10 @@
#define DIAG_ID_APPS		1
#define DIAG_ID_MPSS		2
#define DIAG_ID_WLAN		3
#define DIAG_ID_LPASS		4
#define DIAG_ID_CDSP		5
#define DIAG_ID_AUDIO		6
#define DIAG_ID_SENSORS		7

/* Number of sessions possible in Memory Device Mode. +1 for Apps data */
#define NUM_MD_SESSIONS		(NUM_PERIPHERALS \
@@ -598,10 +604,15 @@ struct diagchar_dev {
	int in_busy_dcipktdata;
	int logging_mode;
	int logging_mask;
	int pd_logging_mode;
	int pd_logging_mode[NUM_UPD];
	int pd_session_clear[NUM_UPD];
	int num_pd_session;
	int cpd_len_1;
	int cpd_len_2;
	int cpd_len_1[NUM_PERIPHERALS];
	int cpd_len_2[NUM_PERIPHERALS];
	int upd_len_1_a[NUM_PERIPHERALS];
	int upd_len_1_b[NUM_PERIPHERALS];
	int upd_len_2_a;
	int upd_len_2_b;
	int mask_check;
	uint32_t md_session_mask;
	uint8_t md_session_mode;
+104 −32
Original line number Diff line number Diff line
@@ -397,6 +397,10 @@ 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;
}
int diag_mask_param(void)
@@ -426,8 +430,8 @@ void diag_clear_masks(struct diag_md_session_t *info)

static void diag_close_logging_process(const int pid)
{
	int i;
	int session_peripheral_mask;
	int i, j;
	int session_mask;
	struct diag_md_session_t *session_info = NULL;
	struct diag_logging_mode_param_t params;

@@ -443,27 +447,34 @@ static void diag_close_logging_process(const int pid)
	mutex_unlock(&driver->diag_maskclear_mutex);

	mutex_lock(&driver->diagchar_mutex);
	session_peripheral_mask = session_info->peripheral_mask;

	session_mask = session_info->peripheral_mask;
	diag_md_session_close(session_info);
	mutex_unlock(&driver->diagchar_mutex);

	for (i = 0; i < NUM_MD_SESSIONS; i++)
		if (MD_PERIPHERAL_MASK(i) & session_peripheral_mask)
		if (MD_PERIPHERAL_MASK(i) & session_mask)
			diag_mux_close_peripheral(DIAG_LOCAL_PROC, i);

	params.req_mode = USB_MODE;
	params.mode_param = 0;
	params.peripheral_mask =
		diag_translate_kernel_to_user_mask(session_peripheral_mask);
	if (driver->pd_logging_mode)
		diag_translate_kernel_to_user_mask(session_mask);

	for (i = UPD_WLAN; i < NUM_MD_SESSIONS; i++) {
		if (session_mask &
			MD_PERIPHERAL_MASK(i)) {
			j = i - UPD_WLAN;
			driver->pd_session_clear[j] = 1;
			driver->pd_logging_mode[j] = 0;
			driver->num_pd_session -= 1;
			params.pd_mask =
		diag_translate_kernel_to_user_mask(session_peripheral_mask);

	if (session_peripheral_mask & MD_PERIPHERAL_MASK(UPD_WLAN)) {
		driver->pd_logging_mode--;
		driver->num_pd_session--;
			diag_translate_kernel_to_user_mask(session_mask);
		} else
			params.pd_mask = 0;
	}
	mutex_lock(&driver->diagchar_mutex);

	diag_switch_logging(&params);

	mutex_unlock(&driver->diagchar_mutex);
}

@@ -1562,17 +1573,22 @@ 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;
	int new_mode, i;
	int curr_mode;
	int err = 0;
	uint8_t do_switch = 1;
	uint32_t peripheral_mask = 0;
	uint8_t peripheral, upd;

	if (!param)
		return -EINVAL;
@@ -1583,10 +1599,28 @@ static int diag_switch_logging(struct diag_logging_mode_param_t *param)
		return -EINVAL;
	}

	if (param->pd_mask) {
		switch (param->pd_mask) {
		case DIAG_CON_UPD_WLAN:
		if (driver->md_session_map[PERIPHERAL_MODEM] &&
			(MD_PERIPHERAL_MASK(PERIPHERAL_MODEM) &
			peripheral = PERIPHERAL_MODEM;
			upd = UPD_WLAN;
			break;
		case DIAG_CON_UPD_AUDIO:
			peripheral = PERIPHERAL_LPASS;
			upd = UPD_AUDIO;
			break;
		case DIAG_CON_UPD_SENSORS:
			peripheral = PERIPHERAL_LPASS;
			upd = UPD_SENSORS;
			break;
		default:
			DIAG_LOG(DIAG_DEBUG_USERSPACE,
			"asking for mode switch with no pd mask set\n");
			return -EINVAL;
		}

		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");
@@ -1595,15 +1629,16 @@ static int diag_switch_logging(struct diag_logging_mode_param_t *param)
		peripheral_mask =
			diag_translate_mask(param->pd_mask);
		param->peripheral_mask = peripheral_mask;
		driver->pd_logging_mode++;
		driver->num_pd_session++;
		break;

	default:
		i = upd - UPD_WLAN;
		if (!driver->pd_session_clear[i]) {
			driver->pd_logging_mode[i] = 1;
			driver->num_pd_session += 1;
			driver->pd_session_clear[i] = 0;
		}
	} else {
		peripheral_mask =
			diag_translate_mask(param->peripheral_mask);
		param->peripheral_mask = peripheral_mask;
		break;
	}

	switch (param->req_mode) {
@@ -1945,9 +1980,36 @@ static int diag_ioctl_hdlc_toggle(unsigned long ioarg)
	return 0;
}

static int diag_ioctl_query_pd_logging(unsigned long ioarg)
static int diag_ioctl_query_pd_logging(struct diag_logging_mode_param_t *param)
{
	int ret = -EINVAL;
	int peripheral;
	char *p_str = NULL;

	if (!param)
		return -EINVAL;

	if (!param->pd_mask) {
		DIAG_LOG(DIAG_DEBUG_USERSPACE,
			"query with no pd mask set, returning error\n");
		return -EINVAL;
	}

	switch (param->pd_mask) {
	case DIAG_CON_UPD_WLAN:
		peripheral = PERIPHERAL_MODEM;
		p_str = "MODEM";
		break;
	case DIAG_CON_UPD_AUDIO:
	case DIAG_CON_UPD_SENSORS:
		peripheral = PERIPHERAL_LPASS;
		p_str = "LPASS";
		break;
	default:
		DIAG_LOG(DIAG_DEBUG_USERSPACE,
		"Invalid pd mask, returning EINVAL\n");
		return -EINVAL;
	}

	DIAG_LOG(DIAG_DEBUG_USERSPACE,
	"diag: %s: Untagging support on APPS is %s\n", __func__,
@@ -1955,12 +2017,13 @@ static int diag_ioctl_query_pd_logging(unsigned long ioarg)
	"present" : "absent"));

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

	if (driver->supports_apps_header_untagging &&
		driver->feature[PERIPHERAL_MODEM].untag_header)
		driver->feature[peripheral].untag_header)
		ret = 0;

	return ret;
@@ -2206,7 +2269,10 @@ long diagchar_compat_ioctl(struct file *filp,
		result = diag_ioctl_hdlc_toggle(ioarg);
		break;
	case DIAG_IOCTL_QUERY_PD_LOGGING:
		result = diag_ioctl_query_pd_logging(ioarg);
		if (copy_from_user((void *)&mode_param, (void __user *)ioarg,
				   sizeof(mode_param)))
			return -EFAULT;
		result = diag_ioctl_query_pd_logging(&mode_param);
		break;
	}
	return result;
@@ -2332,7 +2398,10 @@ long diagchar_ioctl(struct file *filp,
		result = diag_ioctl_hdlc_toggle(ioarg);
		break;
	case DIAG_IOCTL_QUERY_PD_LOGGING:
		result = diag_ioctl_query_pd_logging(ioarg);
		if (copy_from_user((void *)&mode_param, (void __user *)ioarg,
				   sizeof(mode_param)))
			return -EFAULT;
		result = diag_ioctl_query_pd_logging(&mode_param);
		break;
	}
	return result;
@@ -3474,7 +3543,10 @@ static int __init diagchar_init(void)
			poolsize_usb_apps + 1 + (NUM_PERIPHERALS * 6));
	driver->num_clients = max_clients;
	driver->logging_mode = DIAG_USB_MODE;
	driver->pd_logging_mode = 0;
	for (i = 0; i < NUM_UPD; i++) {
		driver->pd_logging_mode[i] = 0;
		driver->pd_session_clear[i] = 0;
	}
	driver->num_pd_session = 0;
	driver->mask_check = 0;
	driver->in_busy_pktdata = 0;
Loading