From: Mario Limonciello <mario_limonciello@dell.com>
To: dvhart@infradead.org
Cc: LKML <linux-kernel@vger.kernel.org>,
platform-driver-x86@vger.kernel.org,
Mario Limonciello <mario_limonciello@dell.com>
Subject: [PATCH v2 2/2] dell-laptop: Expose auxiliary MAC address if available
Date: Sat, 7 May 2016 10:52:44 -0500 [thread overview]
Message-ID: <1462636364-25644-2-git-send-email-mario_limonciello@dell.com> (raw)
In-Reply-To: <1462636364-25644-1-git-send-email-mario_limonciello@dell.com>
System with Type-C ports have a feature to expose an auxiliary
persistent MAC address. This address is burned in at the
factory.
The intention of this address is to update the MAC address on
Type-C docks containing an ethernet adapter to match the
auxiliary address of the system connected to them.
Signed-off-by: Mario Limonciello <mario_limonciello@dell.com>
---
drivers/platform/x86/dell-laptop.c | 66 +++++++++++++++++++++++++++++++++++++-
1 file changed, 65 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 2c2f02b..7a1fe08 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -87,6 +87,7 @@ static struct rfkill *wifi_rfkill;
static struct rfkill *bluetooth_rfkill;
static struct rfkill *wwan_rfkill;
static bool force_rfkill;
+static char *auxiliary_mac_address;
module_param(force_rfkill, bool, 0444);
MODULE_PARM_DESC(force_rfkill, "enable rfkill on non whitelisted models");
@@ -273,6 +274,59 @@ static const struct dmi_system_id dell_quirks[] __initconst = {
{ }
};
+/* get_aux_mac
+ * returns the auxiliary mac address
+ * for assigning to a Type-C ethernet device
+ * such as that found in the Dell TB15 dock
+ */
+static int get_aux_mac(void)
+{
+ struct calling_interface_buffer *buffer;
+ int ret;
+ unsigned char *address =
+ (unsigned char *) __get_free_page(GFP_KERNEL | GFP_DMA32);
+
+ buffer = dell_smbios_get_buffer();
+
+ /* prepare a 17 byte buffer */
+ dell_smbios_prepare_v2_call(address, 17);
+ buffer->input[0] = virt_to_phys(address);
+ dell_smbios_send_request(11, 6);
+ ret = buffer->output[0];
+
+ if (ret != 0) {
+ auxiliary_mac_address = NULL;
+ goto auxout;
+ }
+ dell_smbios_clear_buffer();
+
+ /* address will be stored in byte 4-> */
+ auxiliary_mac_address = kmalloc(13, GFP_KERNEL);
+ memcpy(auxiliary_mac_address, &address[4], 13);
+
+ auxout:
+ free_page((unsigned long)address);
+ dell_smbios_release_buffer();
+ return dell_smbios_error(ret);
+
+}
+
+static ssize_t auxiliary_mac_show(struct device *dev,
+ struct device_attribute *attr, char *page)
+{
+ return sprintf(page, "%s\n", auxiliary_mac_address);
+}
+
+static DEVICE_ATTR_RO(auxiliary_mac);
+static struct attribute *dell_attributes[] = {
+ &dev_attr_auxiliary_mac.attr,
+ NULL
+};
+static const struct attribute_group dell_attr_group = {
+.attrs = dell_attributes,
+};
+
+
/*
* Derived from information in smbios-wireless-ctl:
*
@@ -392,7 +446,6 @@ static const struct dmi_system_id dell_quirks[] __initconst = {
* cbArg1, byte0 = 0x13
* cbRes1 Standard return codes (0, -1, -2)
*/
-
static int dell_rfkill_set(void *data, bool blocked)
{
struct calling_interface_buffer *buffer;
@@ -2003,6 +2056,12 @@ static int __init dell_init(void)
goto fail_rfkill;
}
+ ret = get_aux_mac();
+ if (!ret) {
+ sysfs_create_group(&platform_device->dev.kobj,
+ &dell_attr_group);
+ }
+
if (quirks && quirks->touchpad_led)
touchpad_led_init(&platform_device->dev);
@@ -2064,6 +2123,11 @@ fail_platform_driver:
static void __exit dell_exit(void)
{
+ if (auxiliary_mac_address)
+ sysfs_remove_group(&platform_device->dev.kobj,
+ &dell_attr_group);
+
+ kfree(auxiliary_mac_address);
debugfs_remove_recursive(dell_laptop_dir);
if (quirks && quirks->touchpad_led)
touchpad_led_exit();
--
2.7.4
next prev parent reply other threads:[~2016-05-07 15:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-07 15:52 [PATCH v2 1/2] dell-smbios: Add a helper function for complex SMI requests Mario Limonciello
2016-05-07 15:52 ` Mario Limonciello [this message]
2016-05-09 12:13 ` [PATCH v2 2/2] dell-laptop: Expose auxiliary MAC address if available Michał Kępień
2016-05-09 14:22 ` Mario_Limonciello
2016-05-09 12:02 ` [PATCH v2 1/2] dell-smbios: Add a helper function for complex SMI requests Michał Kępień
2016-05-09 14:22 ` Mario_Limonciello
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462636364-25644-2-git-send-email-mario_limonciello@dell.com \
--to=mario_limonciello@dell.com \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®