All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Chia-Lin Kao \(AceLan\) via Intel-wired-lan" <intel-wired-lan@osuosl.org>
To: Dima Ruinskiy <dima.ruinskiy@intel.com>
Cc: intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com,
	 allen.lan@intel.com
Subject: Re: [Intel-wired-lan] [PATCH iwl-next] igc: Support ACPI-based MAC passthrough
Date: Tue, 4 Aug 2026 14:04:41 +0800	[thread overview]
Message-ID: <anGApbcat6ka_LyS@acelan-Precision-5480> (raw)
In-Reply-To: <20260708134424.3289011-1-dima.ruinskiy@intel.com>

On Wed, Jul 08, 2026 at 04:44:24PM +0300, Dima Ruinskiy wrote:
> Some systems implement a system MAC address object in the ACPI table,
> using either \\_SB.AMAC or \\MACA object names. This system MAC address,
> when enabled, is intended to override the permanent MAC address of the
> network controller.
>
> Implement lookup of the relevant ACPI object names and use them to
> initialize the MAC address.
>
> On systems where the feature is disabled or unsupported, the ACPI objects
> do not exist or do not contain a valid Ethernet MAC, causing a fallback
> to the existing MAC address initialization path.
This patch works as expected and solves the connection issue when the
MAC passthrough feature is enabled.

Tested-by: Chia-Lin Kao (AceLan) <acelan.kao@canonical.com>
>
> Assisted-by: GitHub-Copilot:claude-opus-4.7
> Signed-off-by: Dima Ruinskiy <dima.ruinskiy@intel.com>
> ---
>  drivers/net/ethernet/intel/igc/igc_main.c | 64 ++++++++++++++++++++++-
>  1 file changed, 62 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
> index 82800a4a6d6c..83eb8953e954 100644
> --- a/drivers/net/ethernet/intel/igc/igc_main.c
> +++ b/drivers/net/ethernet/intel/igc/igc_main.c
> @@ -11,6 +11,8 @@
>  #include <net/pkt_sched.h>
>  #include <linux/bpf_trace.h>
>  #include <net/xdp_sock_drv.h>
> +#include <linux/acpi.h>
> +#include <linux/hex.h>
>  #include <linux/pci.h>
>  #include <linux/mdio.h>
>
> @@ -7116,6 +7118,57 @@ static enum hrtimer_restart igc_qbv_scheduling_timer(struct hrtimer *timer)
>  	return HRTIMER_NORESTART;
>  }
>
> +static bool igc_get_acpi_mac_passthru(u8 *mac)
> +{
> +	static const struct {
> +		const char *name;
> +		acpi_object_type type;
> +		u32 length;
> +	} sources[] = {
> +		{ "\\_SB.AMAC", ACPI_TYPE_BUFFER, 23 },
> +		{ "\\MACA",     ACPI_TYPE_STRING, 22 },
> +	};
> +	struct acpi_buffer buffer;
> +	union acpi_object *obj;
> +	bool mac_found = false;
> +	acpi_status status;
> +	u8 buf[ETH_ALEN];
> +	int i;
> +
> +	if (!IS_ENABLED(CONFIG_ACPI))
> +		return false;
> +
> +	for (i = 0; i < ARRAY_SIZE(sources) && !mac_found; i++) {
> +		buffer.length = ACPI_ALLOCATE_BUFFER;
> +		buffer.pointer = NULL;
> +
> +		status = acpi_evaluate_object(NULL, (char *)sources[i].name,
> +					      NULL, &buffer);
> +		if (ACPI_FAILURE(status))
> +			continue;
> +
> +		obj = buffer.pointer;
> +		if (!obj || obj->type != sources[i].type ||
> +		    obj->string.length != sources[i].length)
> +			goto free_obj;
> +
> +		if (strncmp(obj->string.pointer, "_AUXMAC_#", 9) ||
> +		    obj->string.pointer[21] != '#')
> +			goto free_obj;
> +
> +		if (hex2bin(buf, obj->string.pointer + 9, ETH_ALEN) ||
> +		    !is_valid_ether_addr(buf))
> +			goto free_obj;
> +
> +		ether_addr_copy(mac, buf);
> +		mac_found = true;
> +free_obj:
> +		kfree(obj);
> +	}
> +
> +	return mac_found;
> +}
> +
>  /**
>   * igc_probe - Device Initialization Routine
>   * @pdev: PCI device information struct
> @@ -7279,9 +7332,16 @@ static int igc_probe(struct pci_dev *pdev,
>  	}
>
>  	if (eth_platform_get_mac_address(&pdev->dev, hw->mac.addr)) {
> -		/* copy the MAC address out of the NVM */
> -		if (hw->mac.ops.read_mac_addr(hw))
> +		/* Look for a system-provided MAC in the ACPI table before
> +		 * falling back to reading the address from the NVM.
> +		 */
> +		if (igc_get_acpi_mac_passthru(hw->mac.addr)) {
> +			netdev->addr_assign_type = NET_ADDR_STOLEN;
> +			dev_info(&pdev->dev, "Using ACPI pass-thru MAC addr %pM\n",
> +				 hw->mac.addr);
> +		} else if (hw->mac.ops.read_mac_addr(hw)) {
>  			dev_err(&pdev->dev, "NVM Read Error\n");
> +		}
>  	}
>
>  	eth_hw_addr_set(netdev, hw->mac.addr);
> --
> 2.44.0
>

      reply	other threads:[~2026-08-04  6:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 13:44 [Intel-wired-lan] [PATCH iwl-next] igc: Support ACPI-based MAC passthrough Dima Ruinskiy
2026-08-04  6:04 ` Chia-Lin Kao (AceLan) via Intel-wired-lan [this message]

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=anGApbcat6ka_LyS@acelan-Precision-5480 \
    --to=intel-wired-lan@osuosl.org \
    --cc=acelan.kao@canonical.com \
    --cc=allen.lan@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=dima.ruinskiy@intel.com \
    --cc=intel-wired-lan@lists.osuosl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.