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

Commit 37a2d589 authored by Hemant Kumar's avatar Hemant Kumar Committed by Mayank Rana
Browse files

usb: f_gsi: Add ethernet as extended protocol for rmnet and dpl



For some targets rmnet and DPL data path goes over ethernet device.
Treat such rmnet and DPL as extended protocols and pass instance name
as gsi.function_name.extended_prot_name. Extended protocol id is used
to perform ethernet device specific operations for data path. Define
and use usb_prot_id enum which includes IPA accelerated protocol ids
as well as extended non-accelerated protocol ids. Create new control
device node for rmnet and DPL extended protocol instances.

Change-Id: I1a0a04151d83e1cddf49aa2254e4ea862e2504d8
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent 79038b82
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -589,6 +589,7 @@ config USB_CONFIGFS_F_GSI
	bool "USB GSI function"
	select USB_F_GSI
	select USB_RNDIS
	select USB_U_ETHER
	depends on USB_CONFIGFS
	help
	  The GSI function supports the IPA Generic Software Interface found
+174 −67

File changed.

Preview size limit exceeded, changes collapsed.

+32 −7
Original line number Diff line number Diff line
@@ -28,9 +28,14 @@
#include <linux/ipc_logging.h>
#include <linux/timer.h>

#include "u_ether.h"

#define GSI_RMNET_CTRL_NAME "rmnet_ctrl"
#define GSI_MBIM_CTRL_NAME "android_mbim"
#define GSI_DPL_CTRL_NAME "dpl_ctrl"
#define ETHER_RMNET_CTRL_NAME "rmnet_ctrl0"
#define ETHER_DPL_CTRL_NAME "dpl_ctrl0"

#define GSI_CTRL_NAME_LEN (sizeof(GSI_MBIM_CTRL_NAME)+2)
#define GSI_MAX_CTRL_PKT_SIZE 8192
#define GSI_CTRL_DTR (1 << 0)
@@ -118,6 +123,21 @@ enum rndis_class_id {
	RNDIS_ID_MAX,
};

enum usb_prot_id {
	/* accelerated: redefined from ipa_usb.h, do not change order */
	USB_PROT_RNDIS_IPA,
	USB_PROT_ECM_IPA,
	USB_PROT_RMNET_IPA,
	USB_PROT_MBIM_IPA,
	USB_PROT_DIAG_IPA,

	/* non-accelerated */
	USB_PROT_RMNET_ETHER,
	USB_PROT_DPL_ETHER,

	USB_PROT_MAX,
};

#define MAXQUEUELEN 128
struct event_queue {
	u8 event[MAXQUEUELEN];
@@ -232,6 +252,7 @@ struct gsi_data_port {
	enum connection_state sm_state;
	struct event_queue evt_q;
	wait_queue_head_t wait_for_ipa_ready;
	struct gether gether_port;

	/* Track these for debugfs */
	struct ipa_usb_xdci_chan_params ipa_in_channel_params;
@@ -241,7 +262,7 @@ struct gsi_data_port {

struct f_gsi {
	struct usb_function function;
	enum ipa_usb_teth_prot prot_id;
	enum usb_prot_id prot_id;
	int ctrl_id;
	int data_id;
	u32 vendorID;
@@ -295,21 +316,25 @@ static inline struct gsi_opts *to_gsi_opts(struct config_item *item)
			    func_inst.group);
}

static enum ipa_usb_teth_prot name_to_prot_id(const char *name)
static enum usb_prot_id name_to_prot_id(const char *name)
{
	if (!name)
		goto error;

	if (!strncasecmp(name, "rndis", MAX_INST_NAME_LEN))
		return IPA_USB_RNDIS;
		return USB_PROT_RNDIS_IPA;
	if (!strncasecmp(name, "ecm", MAX_INST_NAME_LEN))
		return IPA_USB_ECM;
		return USB_PROT_ECM_IPA;
	if (!strncasecmp(name, "rmnet", MAX_INST_NAME_LEN))
		return IPA_USB_RMNET;
		return USB_PROT_RMNET_IPA;
	if (!strncasecmp(name, "mbim", MAX_INST_NAME_LEN))
		return IPA_USB_MBIM;
		return USB_PROT_MBIM_IPA;
	if (!strncasecmp(name, "dpl", MAX_INST_NAME_LEN))
		return IPA_USB_DIAG;
		return USB_PROT_DIAG_IPA;
	if (!strncasecmp(name, "rmnet.ether", MAX_INST_NAME_LEN))
		return USB_PROT_RMNET_ETHER;
	if (!strncasecmp(name, "dpl.ether", MAX_INST_NAME_LEN))
		return USB_PROT_DPL_ETHER;

error:
	return -EINVAL;