From 9cdd39c25fed0a5c7784220b0b0d37faf3a57900 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Fri, 21 Jan 2005 02:11:48 +0000 Subject: [PATCH] Some older PC Cards have a weird format for FUNCE tuples. They appear as type 0, rather than the usualy type 4. Assume that this format is from an old standard and go with it. The Fujitsu FMV-186A and Silicom Ethernet cards I have both have tuples with this format, and they are both pretty old cards. # if somebody knows for sure, please let me know. --- sys/dev/pccard/pccard_cis.c | 16 ++++++++++++++-- sys/dev/pccard/pccard_cis.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sys/dev/pccard/pccard_cis.c b/sys/dev/pccard/pccard_cis.c index 2fa88efd17cb..4286208460c9 100644 --- a/sys/dev/pccard/pccard_cis.c +++ b/sys/dev/pccard/pccard_cis.c @@ -1269,6 +1269,8 @@ pccard_parse_cis_tuple(struct pccard_tuple *tuple, void *arg) static int decode_funce(struct pccard_tuple *tuple, struct pccard_function *pf) { + int i; + int len; int type = pccard_tuple_read_1(tuple, 0); switch (pf->function) { @@ -1280,8 +1282,7 @@ decode_funce(struct pccard_tuple *tuple, struct pccard_function *pf) break; case PCCARD_FUNCTION_NETWORK: if (type == PCCARD_TPLFE_TYPE_LAN_NID) { - int i; - int len = pccard_tuple_read_1(tuple, 1); + len = pccard_tuple_read_1(tuple, 1); if (tuple->length < 2 + len || len > 8) { /* tuple length not enough or nid too long */ break; @@ -1291,6 +1292,17 @@ decode_funce(struct pccard_tuple *tuple, struct pccard_function *pf) = pccard_tuple_read_1(tuple, i + 2); } pf->pf_funce_lan_nidlen = len; + } else if (type == PCCARD_TPLFE_TYPE_LAN_OLD_NID) { + /* Some older cards have this format, no idea if it is standard */ + if (tuple->length != 13) + break; + len = pccard_tuple_read_1(tuple, 4); + if (len != 6) + break; + for (i = 0; i < len; i++) { + pf->pf_funce_lan_nid[i] + = pccard_tuple_read_1(tuple, i + 5); + } } break; default: diff --git a/sys/dev/pccard/pccard_cis.h b/sys/dev/pccard/pccard_cis.h index d6b9c3899f86..2db306416920 100644 --- a/sys/dev/pccard/pccard_cis.h +++ b/sys/dev/pccard/pccard_cis.h @@ -168,6 +168,7 @@ #define PCCARD_FUNCTION_SECURITY 9 #define PCCARD_FUNCTION_INSTRUMENT 10 #define CISTPL_FUNCE 0x22 +#define PCCARD_TPLFE_TYPE_LAN_OLD_NID 0x00 /* Old way? */ #define PCCARD_TPLFE_TYPE_LAN_TECH 0x01 #define PCCARD_TPLFE_TYPE_LAN_SPEED 0x02 #define PCCARD_TPLFE_TYPE_LAN_MEDIA 0x03