Module Name:    src
Committed By:   jmcneill
Date:           Fri Jan 17 11:54:50 UTC 2025

Modified Files:
        src/sys/dev/sdmmc: sdmmc_cis.c sdmmcvar.h

Log Message:
sdmmc: Capture lan_nid and expose sdmmc_cisptr

LAN NID contains the MAC address for networking adapters.

Device drivers may want to processor vendor specific tuple codes, so
expose sdmmc_cisptr to help this.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/sdmmc/sdmmc_cis.c
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/sdmmc/sdmmcvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/sdmmc/sdmmc_cis.c
diff -u src/sys/dev/sdmmc/sdmmc_cis.c:1.9 src/sys/dev/sdmmc/sdmmc_cis.c:1.10
--- src/sys/dev/sdmmc/sdmmc_cis.c:1.9	Sun Oct 13 18:21:20 2024
+++ src/sys/dev/sdmmc/sdmmc_cis.c	Fri Jan 17 11:54:50 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_cis.c,v 1.9 2024/10/13 18:21:20 jmcneill Exp $	*/
+/*	$NetBSD: sdmmc_cis.c,v 1.10 2025/01/17 11:54:50 jmcneill Exp $	*/
 /*	$OpenBSD: sdmmc_cis.c,v 1.1 2006/06/01 21:53:41 uwe Exp $	*/
 
 /*
@@ -20,7 +20,7 @@
 /* Routines to decode the Card Information Structure of SD I/O cards */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.9 2024/10/13 18:21:20 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.10 2025/01/17 11:54:50 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -41,7 +41,6 @@ __KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,
 #define DPRINTF(s)	/**/
 #endif
 
-static uint32_t sdmmc_cisptr(struct sdmmc_function *);
 static void decode_funce_common(struct sdmmc_function *, struct sdmmc_cis *,
 				int, uint32_t);
 static void decode_funce_function(struct sdmmc_function *, struct sdmmc_cis *,
@@ -49,7 +48,7 @@ static void decode_funce_function(struct
 static void decode_vers_1(struct sdmmc_function *, struct sdmmc_cis *, int,
 			  uint32_t);
 
-static uint32_t
+uint32_t
 sdmmc_cisptr(struct sdmmc_function *sf)
 {
 	uint32_t cisptr = 0;
@@ -108,7 +107,6 @@ decode_funce_lan_nid(struct sdmmc_functi
 {
 	struct sdmmc_function *sf0 = sf->sc->sc_fn0;
 	device_t dev = sf->sc->sc_dev;
-	uint8_t mac[6] __unused;
 	int i;
 
 	if (tpllen != 8) {
@@ -117,13 +115,19 @@ decode_funce_lan_nid(struct sdmmc_functi
 		return;
 	}
 
+	if (sdmmc_io_read_1(sf0, reg++) != 6) {
+		aprint_error_dev(dev,
+		    "CISTPL_FUNCE(lan_nid) invalid\n");
+	}
+
 	for (i = 0; i < 6; i++) {
-		mac[i] = sdmmc_io_read_1(sf0, reg++);
+		cis->lan_nid[i] = sdmmc_io_read_1(sf0, reg++);
 	}
 
 	DPRINTF(
 	    ("CISTPL_FUNCE: LAN_NID=%02x:%02x:%02x:%02x:%02x:%02x\n",
-	    mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]));
+	    cis->lan_nid[0], cis->lan_nid[1], cis->lan_nid[2],
+	    cis->lan_nid[3], cis->lan_nid[4], cis->lan_nid[5]));
 }
 
 static void

Index: src/sys/dev/sdmmc/sdmmcvar.h
diff -u src/sys/dev/sdmmc/sdmmcvar.h:1.37 src/sys/dev/sdmmc/sdmmcvar.h:1.38
--- src/sys/dev/sdmmc/sdmmcvar.h:1.37	Fri Oct 18 11:03:52 2024
+++ src/sys/dev/sdmmc/sdmmcvar.h	Fri Jan 17 11:54:50 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmcvar.h,v 1.37 2024/10/18 11:03:52 jmcneill Exp $	*/
+/*	$NetBSD: sdmmcvar.h,v 1.38 2025/01/17 11:54:50 jmcneill Exp $	*/
 /*	$OpenBSD: sdmmcvar.h,v 1.13 2009/01/09 10:55:22 jsg Exp $	*/
 
 /*
@@ -187,6 +187,7 @@ struct sdmmc_cis {
 	u_char		 cis1_minor;
 	char		 cis1_info_buf[256];
 	char		*cis1_info[4];
+	uint8_t		 lan_nid[6];
 };
 
 /*
@@ -393,6 +394,7 @@ int	sdmmc_io_function_enable(struct sdmm
 void	sdmmc_io_function_disable(struct sdmmc_function *);
 int	sdmmc_io_function_abort(struct sdmmc_function *);
 
+uint32_t sdmmc_cisptr(struct sdmmc_function *);
 int	sdmmc_read_cis(struct sdmmc_function *, struct sdmmc_cis *);
 void	sdmmc_print_cis(struct sdmmc_function *);
 void	sdmmc_check_cis_quirks(struct sdmmc_function *);

Reply via email to