Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1396257 > unrolled thread

[PATCH 1/2] dell-smbios: Add a helper function for complex SMI requests

Started byMario Limonciello <mario_limonciello@dell.com>
First post2016-05-07 08:30 +0200
Last post2016-05-07 08:30 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2] dell-smbios: Add a helper function for complex SMI requests Mario Limonciello <mario_limonciello@dell.com> - 2016-05-07 08:30 +0200
    [PATCH 2/2] dell-laptop: Expose auxiliary MAC address if available Mario Limonciello <mario_limonciello@dell.com> - 2016-05-07 08:30 +0200

#1396257 — [PATCH 1/2] dell-smbios: Add a helper function for complex SMI requests

FromMario Limonciello <mario_limonciello@dell.com>
Date2016-05-07 08:30 +0200
Subject[PATCH 1/2] dell-smbios: Add a helper function for complex SMI requests
Message-ID<rw3Ut-4wr-1@gated-at.bofh.it>
More complex SMI requests can return data that exceeds the 4 32 byte
arguments that are traditionally part of a request.

To support more complex requests, the first input argument can be a
32 bit physical address with a buffer properly built in advance.

This helper function prepares the buffer as the BIOS will look for
it in these requests.

Signed-off-by: Mario Limonciello <mario_limonciello@dell.com>
---
 drivers/platform/x86/dell-smbios.c | 28 ++++++++++++++++++++++++++++
 drivers/platform/x86/dell-smbios.h |  1 +
 2 files changed, 29 insertions(+)

diff --git a/drivers/platform/x86/dell-smbios.c b/drivers/platform/x86/dell-smbios.c
index d2412ab..00b29df 100644
--- a/drivers/platform/x86/dell-smbios.c
+++ b/drivers/platform/x86/dell-smbios.c
@@ -92,6 +92,34 @@ void dell_smbios_send_request(int class, int select)
 }
 EXPORT_SYMBOL_GPL(dell_smbios_send_request);
 
+/* More complex requests are served by sending
+ * a pointer to a pre-allocated buffer
+ * Bytes 0:3 are the size of the return value
+ * Bytes 4:length are the returned value
+ *
+ * This helper function prepares it properly
+ * with the size length to be provided
+ *
+ * caller still needs to pre-allocate and clear
+ * the input buffer
+ */
+void dell_smbios_prepare_v2_call(u8 *input, size_t length)
+{
+	u32 i;
+	u32 *data = (u32 *) input;
+
+	data[0] = length - 4;
+	for (i = 4; i < length; i += 4) {
+		if (length - i > 4) {
+			input[i]   = 'D';
+			input[i+1] = 'S';
+			input[i+2] = 'C';
+			input[i+3] = 'I';
+		}
+	}
+}
+EXPORT_SYMBOL_GPL(dell_smbios_prepare_v2_call);
+
 struct calling_interface_token *dell_smbios_find_token(int tokenid)
 {
 	int i;
diff --git a/drivers/platform/x86/dell-smbios.h b/drivers/platform/x86/dell-smbios.h
index ec7d40a..5d4184c 100644
--- a/drivers/platform/x86/dell-smbios.h
+++ b/drivers/platform/x86/dell-smbios.h
@@ -41,6 +41,7 @@ struct calling_interface_buffer *dell_smbios_get_buffer(void);
 void dell_smbios_clear_buffer(void);
 void dell_smbios_release_buffer(void);
 void dell_smbios_send_request(int class, int select);
+void dell_smbios_prepare_v2_call(u8 *input, size_t length);
 
 struct calling_interface_token *dell_smbios_find_token(int tokenid);
 #endif
-- 
2.7.4

[toc] | [next] | [standalone]


#1396258 — [PATCH 2/2] dell-laptop: Expose auxiliary MAC address if available

FromMario Limonciello <mario_limonciello@dell.com>
Date2016-05-07 08:30 +0200
Subject[PATCH 2/2] dell-laptop: Expose auxiliary MAC address if available
Message-ID<rw3Ut-4wr-3@gated-at.bofh.it>
In reply to#1396257
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 | 62 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 2c2f02b..f818ddf 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,58 @@ 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)
+		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 +445,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 +2055,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);
 
@@ -2048,6 +2106,7 @@ static int __init dell_init(void)
 		backlight_update_status(dell_backlight_device);
 	}
 
+
 	return 0;
 
 fail_backlight:
@@ -2064,6 +2123,7 @@ fail_platform_driver:
 
 static void __exit dell_exit(void)
 {
+	kfree(auxiliary_mac_address);
 	debugfs_remove_recursive(dell_laptop_dir);
 	if (quirks && quirks->touchpad_led)
 		touchpad_led_exit();
-- 
2.7.4

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web