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

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

Merge "usb: f_gsi: Allow user to specify MAC address for RNDIS/ECM"

parents 3cda9468 11476d37
Loading
Loading
Loading
Loading
+63 −8
Original line number Diff line number Diff line
@@ -24,6 +24,16 @@ static bool qti_packet_debug;
module_param(qti_packet_debug, bool, 0644);
MODULE_PARM_DESC(qti_packet_debug, "Print QTI Packet's Raw Data");

/* initial value, changed by "ifconfig usb0 hw ether xx:xx:xx:xx:xx:xx" */
static char *gsi_dev_addr;
module_param(gsi_dev_addr, charp, 0644);
MODULE_PARM_DESC(gsi_dev_addr, "QC Device Ethernet Address");

/* this address is invisible to ifconfig */
static char *gsi_host_addr;
module_param(gsi_host_addr, charp, 0644);
MODULE_PARM_DESC(gsi_host_addr, "QC Host Ethernet Address");

static struct workqueue_struct *ipa_usb_wq;
static struct f_gsi *__gsi[USB_PROT_MAX];
static void *ipc_log_ctxt;
@@ -2420,6 +2430,9 @@ static void gsi_disable(struct usb_function *f)

	atomic_set(&gsi->connected, 0);

	del_timer(&gsi->gsi_rw_timer);
	gsi->debugfs_rw_timer_enable = 0;

	if (gsi->prot_id == USB_PROT_RNDIS_IPA)
		rndis_uninit(gsi->params);

@@ -2490,6 +2503,16 @@ static void gsi_suspend(struct usb_function *f)
	post_event(&gsi->d_port, EVT_SUSPEND);
	queue_work(gsi->d_port.ipa_usb_wq, &gsi->d_port.usb_ipa_w);
	log_event_dbg("gsi suspended");

	/*
	 * If host suspended bus without receiving notification request then
	 * initiate remote-wakeup. As driver won't be able to do it later since
	 * notification request is already queued.
	 */
	if (gsi->c_port.notify_req_queued && usb_gsi_remote_wakeup_allowed(f)) {
		mod_timer(&gsi->gsi_rw_timer, jiffies + msecs_to_jiffies(2000));
		log_event_dbg("%s: pending response, arm rw_timer\n", __func__);
	}
}

static void gsi_resume(struct usb_function *f)
@@ -2507,6 +2530,10 @@ static void gsi_resume(struct usb_function *f)
		f->func_is_suspended)
		return;

	/* Keep timer enabled if user enabled using debugfs */
	if (!gsi->debugfs_rw_timer_enable)
		del_timer(&gsi->gsi_rw_timer);

	if (gsi->c_port.notify && !gsi->c_port.notify->desc)
		config_ep_by_speed(cdev->gadget, f, gsi->c_port.notify);

@@ -2797,6 +2824,26 @@ static void ipa_ready_callback(void *user_data)
	wake_up_interruptible(&gsi->d_port.wait_for_ipa_ready);
}

static void gsi_get_ether_addr(const char *str, u8 *dev_addr)
{
	if (str) {
		unsigned int i;

		for (i = 0; i < ETH_ALEN; i++) {
			unsigned char num;

			if ((*str == '.') || (*str == ':'))
				str++;
			num = hex_to_bin(*str++) << 4;
			num |= hex_to_bin(*str++);
			dev_addr[i] = num;
		}
		if (is_valid_ether_addr(dev_addr))
			return;
	}
	random_ether_addr(dev_addr);
}

static int gsi_bind(struct usb_configuration *c, struct usb_function *f)
{
	struct usb_composite_dev *cdev = c->cdev;
@@ -2869,8 +2916,12 @@ static int gsi_bind(struct usb_configuration *c, struct usb_function *f)
		rndis_set_param_medium(gsi->params, RNDIS_MEDIUM_802_3, 0);

		/* export host's Ethernet address in CDC format */
		random_ether_addr(gsi->d_port.ipa_init_params.device_ethaddr);
		random_ether_addr(gsi->d_port.ipa_init_params.host_ethaddr);
		gsi_get_ether_addr(gsi_dev_addr,
				   gsi->d_port.ipa_init_params.device_ethaddr);

		gsi_get_ether_addr(gsi_host_addr,
				   gsi->d_port.ipa_init_params.host_ethaddr);

		log_event_dbg("setting host_ethaddr=%pM, device_ethaddr = %pM",
				gsi->d_port.ipa_init_params.host_ethaddr,
				gsi->d_port.ipa_init_params.device_ethaddr);
@@ -3082,8 +3133,12 @@ static int gsi_bind(struct usb_configuration *c, struct usb_function *f)
		info.notify_buf_len = GSI_CTRL_NOTIFY_BUFF_LEN;

		/* export host's Ethernet address in CDC format */
		random_ether_addr(gsi->d_port.ipa_init_params.device_ethaddr);
		random_ether_addr(gsi->d_port.ipa_init_params.host_ethaddr);
		gsi_get_ether_addr(gsi_dev_addr,
				   gsi->d_port.ipa_init_params.device_ethaddr);

		gsi_get_ether_addr(gsi_host_addr,
				   gsi->d_port.ipa_init_params.host_ethaddr);

		log_event_dbg("setting host_ethaddr=%pM, device_ethaddr = %pM",
				gsi->d_port.ipa_init_params.host_ethaddr,
				gsi->d_port.ipa_init_params.device_ethaddr);