From 3edc4ff927cde65a8d3b3169c50e825b9ca441d3 Mon Sep 17 00:00:00 2001 From: Bhadram Varka Date: Tue, 11 Mar 2025 05:48:43 +0000 Subject: [PATCH] nvethernet: Add nvidia,use-random-mac-addr DT property Adding support for generating the random MAC address if nvidia,use-random-mac-addr is set with value 1. Below property should be there insider ethernet DT nodes - nvidia,use-random-mac-addr = <1>; Recommendation is to use only for MODS setup. This should not be enabled in the production DT. Bug 5142789 Change-Id: I87db90685bb9769358eda4edc226b929ccdce67f Signed-off-by: Bhadram Varka Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3317020 Reviewed-by: mobile promotions Tested-by: mobile promotions Reviewed-by: Srinivas Ramachandran GVS: buildbot_gerritrpt Tested-by: Lovie Wang --- drivers/net/ethernet/nvidia/nvethernet/ether_linux.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c index d5c79613..4c9f5581 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c @@ -5384,6 +5384,7 @@ static int ether_get_mac_address(struct ether_priv_data *pdata) unsigned char local_addr[ETH_ALEN] = {0}; /* Default choesn node property name for MAC address */ char str_mac_address[ETH_MAC_STR_LEN] = "nvidia,ether-mac"; + unsigned int use_random_mac_addr = 0x0; unsigned int offset = 0; unsigned int mac_addr_idx = 0x0; int ret = 0; @@ -5415,6 +5416,9 @@ static int ether_get_mac_address(struct ether_priv_data *pdata) sprintf(str_mac_address, "nvidia,ether-mac%d", offset); } + if (of_property_read_u32(np, "nvidia,use-random-mac-addr", &use_random_mac_addr) < 0) + use_random_mac_addr = OSI_DISABLE; + ret = ether_get_mac_address_dtb("/chosen", str_mac_address, mac_addr); /* If return value is valid update eth_mac_addr */ if (ret == 0) { @@ -5430,8 +5434,7 @@ static int ether_get_mac_address(struct ether_priv_data *pdata) ret = of_get_mac_address(np, addr); if (ret < 0) { dev_err(dev, "No Mac address local DT!\n"); - //TBD: use local mac addr for T264 bring up - if (osi_core->pre_sil == OSI_ENABLE) { + if (use_random_mac_addr == OSI_ENABLE) { dev_err(dev, "Using local random mac addr!\n"); eth_random_addr(local_addr); addr = local_addr;