Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3334557rdb; Wed, 13 Sep 2023 09:00:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoq22hhcVKhXhMrpev4ubMqhhL18Bkiu4kVWK0lsulPrjwdt6rd48lFS2jG0b8PaUS9AgZ X-Received: by 2002:a17:90b:4b47:b0:263:eb0e:5681 with SMTP id mi7-20020a17090b4b4700b00263eb0e5681mr4499500pjb.3.1694620819700; Wed, 13 Sep 2023 09:00:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694620819; cv=none; d=google.com; s=arc-20160816; b=rz+D9Vm5PDhdWqQcNn63vISNYeUQN2QN6nX4kE5amHwL2BHcT/f3HJFxvmyrUseIS1 tl7mQ8YhBCgIiHY7DSL0wBd9eX13gEDoqrUVi87QWYqS1Xe26zYCeGO9o4uCQr3dCHnc zew1mEonXjshmy2Yk9QyU+V8fVCrq3yaHe9gW1qsHM52ZpiinKVnkQW0jQQyWKnOv78P hnFuuVK8ffutGw6/s+upvcf3YBP0uMhJOI+1KZXa+ZDk1MK/7gNFx1yNawfPXGbz9XF/ xn/BvEptcVrPL6rdw4UF1hcKog9zm7T8VJG+/SfVLtBkiAKyk4kwQv79OU8PVUoNhE7V WXXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=8oFlWNsBoPiP27e6QLLTn7WyeRku9K4oycwIoawQoLA=; fh=4fDsS0Ve0IStj6Ttr6IRJuIxbyW9UA8sXaGsFMe3f/Y=; b=yxrvbYAXzoKToGCLUwbDCBi/qgC+jFj8ZBVv3ssMNpoBIsFl1z7KdolzHcmPRefp92 W+exAwCCM1kX00vfdU0S5rBD5exuXbqtq+cr3cpuiCPKWMYcQvMBCJh0Ig3TsHPOxdWK oH5cffJ5VYbAlZRf8oFsFip2kI0cZWiL8JtHyN9sXCqLakOETxbrmwr1k+8SzZrED2Pe ZmocRsPClvAn01Uz9wz7iy3pIRNjWAJxANUhCYpfPv4lrrX5Pasfh7GSrmuXOUrpL+0i VhVjqvT07UlS80TidM84290ig1ABb5ul3x3CLg4sAKDa7oS9vCdr815U2P2m80N5Veax WRpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gZ1Qjuo2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id 13-20020a17090a08cd00b002680f4e8969si1729402pjn.95.2023.09.13.09.00.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:00:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gZ1Qjuo2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 1935D801BB7F; Wed, 13 Sep 2023 08:59:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230216AbjIMP65 (ORCPT + 99 others); Wed, 13 Sep 2023 11:58:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbjIMP64 (ORCPT ); Wed, 13 Sep 2023 11:58:56 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D720CCD for ; Wed, 13 Sep 2023 08:58:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694620685; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8oFlWNsBoPiP27e6QLLTn7WyeRku9K4oycwIoawQoLA=; b=gZ1Qjuo2rcmLWcbNoUVTVfrYy+1YmwNyl6A2+VnGJeHeUVPUzxpaaVFrA5shGh4pdh3Jh7 9yFbKkvGmrUg9PYkuVGF0pK8vDCzftvf89aCPSNC703yzdFSWB+DfLfZBuMC2qiH4X6dTd CVaCgxpchY2PZaoNzlU3oPi4ElyPBmw= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-637-X_4_YaQoOq2SDaphS8e5Xg-1; Wed, 13 Sep 2023 11:58:04 -0400 X-MC-Unique: X_4_YaQoOq2SDaphS8e5Xg-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-51d981149b5so4645556a12.3 for ; Wed, 13 Sep 2023 08:58:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694620683; x=1695225483; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8oFlWNsBoPiP27e6QLLTn7WyeRku9K4oycwIoawQoLA=; b=joh13HmanqTYGN/DE+4y7tj0YTxJxPrd6rP43m8Nd2UMpBrzweUjDyvyMVxJkXBJnm PbYvInlPH9+x7ZAuqAIzuaN3p6wXXjBVeOtoAC/mgyYHq7ZhZvq5amBiWpm7FAHCyujI jXXkD0Qo08Am+xsX2RKmuSHbVccFE3bZjNDnLMo2UK9iqUc+omu0PQLyC+Ecr98DFfK1 k/9po0HW+eNr9isIZLoMIEHVWe9iS5JVxBylcqRmmccDKWi0mtg0Wnrj9S576RQFj5GB inwmXdByw7KN9/MccgcePzw2K5qKlgLP53Fc6jb4ea+R9nDhMcgWvPTuwPPEa1FI5VE/ KtCg== X-Gm-Message-State: AOJu0YxywOupjWOq8/EXdNfYwijHW3KSGGr+xlxcApYGkg5LO36akI5v jGYc8ogr266ZNNF4ac6KBCoEm76scAnA8TXu+Vdb6WLYth4UsHWHxYwhaB8uq1OlDkH9emwgqXI 3w9QyU7hm/D5IJrjKIe48zERF X-Received: by 2002:a05:6402:1484:b0:52f:b00a:99be with SMTP id e4-20020a056402148400b0052fb00a99bemr2638847edv.33.1694620683026; Wed, 13 Sep 2023 08:58:03 -0700 (PDT) X-Received: by 2002:a05:6402:1484:b0:52f:b00a:99be with SMTP id e4-20020a056402148400b0052fb00a99bemr2638832edv.33.1694620682667; Wed, 13 Sep 2023 08:58:02 -0700 (PDT) Received: from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec? (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id o1-20020a056402444100b0052ff9bae873sm336955edb.5.2023.09.13.08.58.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Sep 2023 08:58:02 -0700 (PDT) Message-ID: Date: Wed, 13 Sep 2023 17:58:01 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] platform/x86: thinkpad_acpi: sysfs interface to auxmac Content-Language: en-US, nl To: Fernando Eckhardt Valle , hmh@hmh.eng.br, markgross@kernel.org, ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, mpearson-lenovo@squebb.ca References: <20230906195204.4478-1-fevalle@ipt.br> From: Hans de Goede In-Reply-To: <20230906195204.4478-1-fevalle@ipt.br> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Sep 2023 08:59:00 -0700 (PDT) X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Hi Fernando, On 9/6/23 21:52, Fernando Eckhardt Valle wrote: > Newer Thinkpads have a feature called Mac Address Passthrough. > This patch provides a sysfs interface that userspace can use > to get this auxiliary mac address. > > Signed-off-by: Fernando Eckhardt Valle Thank you for your patch. At a minimum for this patch to be accepted you will need to document the new sysfs interface in: Documentation/admin-guide/laptops/thinkpad-acpi.rst But I wonder if we should export this information to userspace in this way ? The reason why I'm wondering is because mac-address passthrough in case of using e.g. Lenovo Thunderbolt docks is already supported by the kernel by code for this in drivers/net/usb/r8152.c : https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/usb/r8152.c#n1613 So I'm wondering if we really need this, is there a planned userspace API consumer of the new sysfs interface ? Or is this only intended as a way for a user to query this, iow is this purely intended for informational purposes ? Regards, Hans > --- > drivers/platform/x86/thinkpad_acpi.c | 77 ++++++++++++++++++++++++++++ > 1 file changed, 77 insertions(+) > > diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c > index d70c89d32..0b1c36b0d 100644 > --- a/drivers/platform/x86/thinkpad_acpi.c > +++ b/drivers/platform/x86/thinkpad_acpi.c > @@ -10785,6 +10785,78 @@ static struct ibm_struct dprc_driver_data = { > .name = "dprc", > }; > > +/* > + * Auxmac > + * > + * This auxiliary mac address is enabled in the bios through the > + * Mac Address Passthrough feature. In most cases, there are three > + * possibilities: Internal Mac, Second Mac, and disabled. > + * > + */ > + > +#define AUXMAC_LEN 12 > +#define AUXMAC_START 9 > +#define AUXMAC_STRLEN 22 > +static char auxmac[AUXMAC_LEN]; > + > +static int auxmac_init(struct ibm_init_struct *iibm) > +{ > + acpi_status status; > + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; > + union acpi_object *obj; > + > + status = acpi_evaluate_object(NULL, "\\MACA", NULL, &buffer); > + > + if (ACPI_FAILURE(status)) > + return -ENODEV; > + > + obj = (union acpi_object *)buffer.pointer; > + > + if (obj->type != ACPI_TYPE_STRING || obj->string.length != AUXMAC_STRLEN) { > + pr_info("Invalid buffer for mac addr passthrough.\n"); > + goto auxmacinvalid; > + } > + > + if (strncmp(obj->string.pointer + 0x8, "#", 1) != 0 || > + strncmp(obj->string.pointer + 0x15, "#", 1) != 0) { > + pr_info("Invalid header for mac addr passthrough.\n"); > + goto auxmacinvalid; > + } > + > + memcpy(auxmac, obj->string.pointer + AUXMAC_START, AUXMAC_LEN); > + kfree(obj); > + return 0; > + > +auxmacinvalid: > + kfree(obj); > + memcpy(auxmac, "unavailable", 11); > + return 0; > +} > + > +static struct ibm_struct auxmac_data = { > + .name = "auxmac", > +}; > + > +static ssize_t auxmac_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + if (strncmp(auxmac, "XXXXXXXXXXXX", AUXMAC_LEN) == 0) > + memcpy(auxmac, "disabled", 9); > + > + return sysfs_emit(buf, "%s\n", auxmac); > +} > +static DEVICE_ATTR_RO(auxmac); > + > +static struct attribute *auxmac_attributes[] = { > + &dev_attr_auxmac.attr, > + NULL > +}; > + > +static const struct attribute_group auxmac_attr_group = { > + .attrs = auxmac_attributes, > +}; > + > /* --------------------------------------------------------------------- */ > > static struct attribute *tpacpi_driver_attributes[] = { > @@ -10843,6 +10915,7 @@ static const struct attribute_group *tpacpi_groups[] = { > &proxsensor_attr_group, > &kbdlang_attr_group, > &dprc_attr_group, > + &auxmac_attr_group, > NULL, > }; > > @@ -11414,6 +11487,10 @@ static struct ibm_init_struct ibms_init[] __initdata = { > .init = tpacpi_dprc_init, > .data = &dprc_driver_data, > }, > + { > + .init = auxmac_init, > + .data = &auxmac_data, > + }, > }; > > static int __init set_ibm_param(const char *val, const struct kernel_param *kp)