qca-swiss-army-knife: Add a tool to dump EEPROM
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
--- tools/edump/Makefile.am | 1 + tools/edump/README | 31 ++++ tools/edump/autogen.sh | 8 + tools/edump/configure.ac | 25 +++ tools/edump/src/Makefile.am | 4 + tools/edump/src/edump.c | 315 +++++++++++++++++++++++++++++++++++ tools/edump/src/edump.h | 136 +++++++++++++++ tools/edump/src/eep_4k.c | 308 ++++++++++++++++++++++++++++++++++ tools/edump/src/eep_4k.h | 142 ++++++++++++++++ tools/edump/src/eep_9287.c | 303 ++++++++++++++++++++++++++++++++++ tools/edump/src/eep_9287.h | 133 +++++++++++++++ tools/edump/src/eep_common.h | 87 ++++++++++ tools/edump/src/eep_def.c | 382 +++++++++++++++++++++++++++++++++++++++++++ tools/edump/src/eep_def.h | 148 +++++++++++++++++ 14 files changed, 2023 insertions(+) create mode 100644 tools/edump/Makefile.am create mode 100644 tools/edump/README create mode 100755 tools/edump/autogen.sh create mode 100644 tools/edump/configure.ac create mode 100644 tools/edump/src/Makefile.am create mode 100644 tools/edump/src/edump.c create mode 100644 tools/edump/src/edump.h create mode 100644 tools/edump/src/eep_4k.c create mode 100644 tools/edump/src/eep_4k.h create mode 100644 tools/edump/src/eep_9287.c create mode 100644 tools/edump/src/eep_9287.h create mode 100644 tools/edump/src/eep_common.h create mode 100644 tools/edump/src/eep_def.c create mode 100644 tools/edump/src/eep_def.h
tools/edump/Makefile.am new file +1 -0
@@ -0,0 +1 @@ +SUBDIRS = src
tools/edump/README new file +31 -0
@@ -0,0 +1,31 @@ +This is a tool to dump the eeprom contents of WLAN chips supported by ath9k. + +Requirements +------------ + +libpcicaccess (http://cgit.freedesktop.org/xorg/lib/libpciaccess/) + +Installation +------------ + +./autogen.sh +./configure +make +make install + +Usage +----- + +To dump everything: "edump" or "edump -a" +To dump the base header: "edump -b" +To dump the modal header: "edump -m" + +Help +---- + +"edump --help" + +Bugs +---- + +Report them to "ath9k-devel at qualcomm.com"
tools/edump/autogen.sh new file +8 -0
@@ -0,0 +1,8 @@ +#!/bin/sh + +echo "Running autoreconf..." + +autoreconf -f -i -v +if [ $? -ne 0 ]; then + echo "autoreconf failed" +fi
tools/edump/configure.ac new file +25 -0
@@ -0,0 +1,25 @@ +AC_INIT([edump], [1.0], [ath9k-devel at qualcomm.com]) +AM_INIT_AUTOMAKE([-Wall -Werror foreign]) +AC_CONFIG_SRCDIR([src/edump.c]) +AC_CONFIG_HEADER([config.h]) + +# Checks for programs. +AC_PROG_CC +AM_PROG_CC_C_O +AC_PROG_INSTALL + +# Checks for header files. +AC_HEADER_STDC + +# Checks for libraries. +PKG_CHECK_MODULES([pciaccess], + [pciaccess >= 0.10.3], + [], + [AC_MSG_ERROR(libpciaccess-0.10.3 is required)]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST + +AC_CONFIG_FILES([Makefile + src/Makefile]) +AC_OUTPUT
tools/edump/src/Makefile.am new file +4 -0
@@ -0,0 +1,4 @@ +bin_PROGRAMS = edump +edump_CFLAGS = -Wall $(pciaccess_CFLAGS) +edump_LDADD = $(pciaccess_LIBS) +edump_SOURCES = eep_def.c eep_4k.c eep_9287.c edump.c
tools/edump/src/edump.c new file +315 -0
315 lines not on this page · raw message
tools/edump/src/edump.h new file +136 -0
136 lines not on this page · raw message
tools/edump/src/eep_4k.c new file +308 -0
308 lines not on this page · raw message
tools/edump/src/eep_4k.h new file +142 -0
142 lines not on this page · raw message
tools/edump/src/eep_9287.c new file +303 -0
303 lines not on this page · raw message
tools/edump/src/eep_9287.h new file +133 -0
133 lines not on this page · raw message
tools/edump/src/eep_common.h new file +87 -0
87 lines not on this page · raw message
tools/edump/src/eep_def.c new file +382 -0
382 lines not on this page · raw message
tools/edump/src/eep_def.h new file +148 -0
148 lines not on this page · raw message
Signature · 1 line
1.7.11.2
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
Quoted 1 line · Sujith Manoharan
Signed-off-by Sujith Manoharan <[email protected]>
Wow, awesome, applied and pushed, thanks!
Luis
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
In reply to Sujith ManoharanQuoted 6 lines · Sujith Manoharan
tools/edump/src/edump.c new file +6
-0+static int is_supported_chipset (struct pci_device *pdev) +{ +if (pdev->vendor_id !=ATHEROS_VENDOR_ID ) +return 0 ; + + if ((pdev->device_id != AR5416_DEVID_PCI) &&
tools/edump/src/edump.c line 104
Quoted 10 lines
tools/edump/src/edump.c new file +10
-0+ (pdev->device_id != AR5416_DEVID_PCIE) && + (pdev->device_id != AR9160_DEVID_PCI) && + (pdev->device_id != AR9280_DEVID_PCI) && + (pdev->device_id != AR9280_DEVID_PCIE) && + (pdev->device_id != AR9285_DEVID_PCIE) && + (pdev->device_id != AR9287_DEVID_PCI) && + (pdev->device_id != AR9287_DEVID_PCIE)) { +fprintf (stderr,"Device ID: 0x%x not supported\n" , pdev->device_id); +return 0 ; + }
Perhaps a switch () would be more suitable here.
Quoted 1 line
+++
b/tools/edump/src/eep_4k.c
..
Quoted 11 lines
tools/edump/src/eep_4k.c new file +11
-0+static bool fill_eeprom_4k (struct edump *edump) +{ +#define SIZE_EEPROM_4K (sizeof(struct ar5416_eeprom_4k) / sizeof(uint16_t)) + +uint16_t *eep_data = (uint16_t *)&edump->eeprom.map4k; +int addr, eep_start_loc =0 ; + + eep_start_loc =64 ; + +for (addr =0 ; addr <SIZE_EEPROM_4K ; addr++) { +if (!pci_eeprom_read (edump, addr + eep_start_loc, eep_data)) {
tools/edump/src/eep_4k.c line 49
Quoted 10 lines
tools/edump/src/eep_4k.c new file +10
-0+fprintf (stderr,"Unable to read eeprom region\n" ); +return false; + } + eep_data++; + } + +return true; + +#undef SIZE_EEPROM_4K +}
What is the define+undef about in each of these fill functions? I guess there could be a better solution for these sizes?
Even writing out sizeof(struct ar5416_eeprom_4k) / sizeof(uint16_t) in the loop condition would be an improvement IMO.
tools/edump/src/eep_4k.c line 239
Quoted 8 lines
tools/edump/src/eep_4k.c new file +8
-0+static void modal_eeprom_4k (struct edump *edump) +{ +#define PR (_token, _p, _val_fmt, _val) \ + do { \ + printf("%-23s %-2s", (_token), ":"); \ + printf("%s%"_val_fmt, _p, (_val)); \ + printf("\n"); \ + } while(0)
Several lovely two-letter macros which get undefined again. Not super awesome for code readability, which is really a shame, since the rest of the code looks rather good.
tools/edump/src/eep_4k.c line 250
Quoted 3 lines
tools/edump/src/eep_4k.c new file +3
-0+PR ("Ant Chain 0" ,"0x" ,"X" , pModal->antCtrlChain[0 ]); +PR ("Antenna Common" ,"0x" ,"X" , pModal->antCtrlCommon); +PR ("Antenna Gain Chain 0" ,"" ,"d" , pModal->antennaGainCh[0 ]);
..followed by 44 more lines with second and third parameter identical. What do you think about having two macros instead?
Quoted 1 line
+++
b/tools/edump/src/eep_9287.c
..
tools/edump/src/eep_9287.c line 239
Quoted 8 lines
tools/edump/src/eep_9287.c new file +8
-0+static void modal_eeprom_9287 (struct edump *edump) +{ +#define PR (_token, _p, _val_fmt, _val) \ + do { \ + printf("%-23s %-2s", (_token), ":"); \ + printf("%s%"_val_fmt, _p, (_val)); \ + printf("\n"); \ + } while(0)
..oh - is this an identical macro - with same lovely two letter name and same parameters?
Quoted 1 line
+++
b/tools/edump/src/eep_def.c
..
tools/edump/src/eep_def.c line 31
Quoted 3 lines
tools/edump/src/eep_def.c new file +3
-0+static bool fill_eeprom_def (struct edump *edump) +{ +#define SIZE_EEPROM_DEF (sizeof(struct ar5416_eeprom_def) / sizeof(uint16_t))
I don't see why these size defines aren't at least next to the structs.
Quoted 6 lines
tools/edump/src/eep_def.c new file +6
-0+static void modal_eeprom_def (struct edump *edump) +{ +#define PR (_token, _p, _val_fmt, _val) \ + do { \ + printf("%-23s %-8s", (_token), ":"); \ + if (pBase->opCapFlags & AR5416_OPFLAGS_11G) { \
tools/edump/src/eep_def.c line 248
Quoted 10 lines
tools/edump/src/eep_def.c new file +10
-0+ pModal = &(ar5416Eep->modalHeader[1 ]); \ +printf ("%s%-6" _val_fmt, _p, (_val)); \ + } \ +if (pBase->opCapFlags &AR5416_OPFLAGS_11A ) { \ + pModal = &(ar5416Eep->modalHeader[0 ]); \ +printf ("%8s%" _val_fmt"\n" , _p, (_val)); \ + }else { \ +printf ("\n" ); \ + } \ + }while (0 )
Yeah baby. Got another one!
Other than these handful points I think the code looks very good and it will certainly be helpful for many.
Is a commit to also do EEPROM writes likely to be accepted into qca-swiss-army-knife.git?
//Peter
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
Quoted 2 lines · Peter Stuge
Is a commit to also do EEPROM writes likely to be accepted into qca-swiss-army-knife.git?
EEPROM writing means you can modify a compliant card to be not compliant. For the kernel we now have things like CONFIG_CFG80211_CERTIFICATION_ONUS for these sorts of researcher / ODM type of code but for userspace we'd need to figure a similar reasonable solution. For CRDA we did the signing thing to ensure authenticity / integrity for end users but this is a bit different. Lets work on a solution and then perhaps we can review with folks.
Luis
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
Oh and as for the other stuff please feel free to send patches as I already merged and pushed Sujith's patch.
git://github.com/mcgrof/qca-swiss-army-knife.git
Luis
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
Quoted 1 line · Luis R. Rodriguez
I already merged and pushed
Yeah. That is a great strategy to not have to address any quality issues found during review.
//Peter
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
In reply to Luis R. RodriguezQuoted 4 lines · Luis R. Rodriguez
Quoted 2 lines
Is a commit to also do EEPROM writes likely to be accepted into qca-swiss-army-knife.git?
EEPROM writing means you can modify a compliant card to be not compliant.
Yes, and it also means you can modify a non-compliant card to be compliant.
Quoted 2 lines
For CRDA we did the signing thing to ensure authenticity / integrity for end users but this is a bit different.
Sure.
Quoted 1 line
Lets work on a solution and then perhaps we can review with folks.
I think that sounds good. Cool!
//Peter
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
Quoted 6 lines · Peter Stuge
Quoted 4 lines
Quoted 2 lines
Is a commit to also do EEPROM writes likely to be accepted into qca-swiss-army-knife.git?
EEPROM writing means you can modify a compliant card to be not compliant.
Yes, and it also means you can modify a non-compliant card to be compliant.
Without limiting the card to the lowest common denominator of old and new settings, to be clear. :)
//Peter
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
Quoted 10 lines · Peter Stuge
Quoted 6 lines · Peter Stuge
Quoted 4 lines
Quoted 2 lines
Is a commit to also do EEPROM writes likely to be accepted into qca-swiss-army-knife.git?
EEPROM writing means you can modify a compliant card to be not compliant.
Yes, and it also means you can modify a non-compliant card to be compliant.
Without limiting the card to the lowest common denominator of old and new settings, to be clear. :)
That does indeed sound like a nice feature to enable, indeed.
Luis
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
In reply to Peter StugeQuoted 5 lines · Peter Stuge
What is the define+undef about in each of these fill functions? I guess there could be a better solution for these sizes?
Even writing out
sizeof(struct ar5416_eeprom_4k)/sizeof(uint16_t)in the loop condition would be an improvement IMO.
How would that make the code more readable ?
Quoted 10 lines
Several lovely two-letter macros which get undefined again. Not super awesome for code readability, which is really a shame, since the rest of the code looks rather good.
tools/edump/src/eep_4k.c line 250
Quoted 3 lines
tools/edump/src/eep_4k.c new file +3
-0+PR ("Ant Chain 0" ,"0x" ,"X" , pModal->antCtrlChain[0 ]); +PR ("Antenna Common" ,"0x" ,"X" , pModal->antCtrlCommon); +PR ("Antenna Gain Chain 0" ,"" ,"d" , pModal->antennaGainCh[0 ]);..followed by 44 more lines with second and third parameter identical. What do you think about having two macros instead?
Care to show how ?
Quoted 2 lines
I don't see why these size defines aren't at least next to the structs.
Sure, they can be moved.
Quoted 10 lines
Quoted 10 lines
tools/edump/src/eep_def.c new file +10
-0+static void modal_eeprom_def (struct edump *edump) +{ +#define PR (_token, _p, _val_fmt, _val) \ + do { \ + printf("%-23s %-8s", (_token), ":"); \ + if (pBase->opCapFlags & AR5416_OPFLAGS_11G) { \ + pModal = &(ar5416Eep->modalHeader[1]); \ + printf("%s%-6"_val_fmt, _p, (_val)); \ + } \ + if (pBase->opCapFlags & AR5416_OPFLAGS_11A) { \
Quoted 8 lines
tools/edump/src/eep_def.c line 248
Quoted 6 lines
tools/edump/src/eep_def.c new file +6
-0+ pModal = &(ar5416Eep->modalHeader[0 ]); \ +printf ("%8s%" _val_fmt"\n" , _p, (_val)); \ + }else { \ +printf ("\n" ); \ + } \ + }while (0 )Yeah baby. Got another one!
Um, I am not sure what you are getting at ?. Some values need to be printed in HEX, some in decimal. We have dual-band cards, 2G only cards, 5G only cards. This is just a macro to handle all that..
But, patches are always welcome to improve things.
Sujith
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
Quoted 7 lines · Sujith Manoharan
Quoted 5 lines
What is the define+undef about in each of these fill functions? I guess there could be a better solution for these sizes?
Even writing out
sizeof(struct ar5416_eeprom_4k)/sizeof(uint16_t)in the loop condition would be an improvement IMO.How would that make the code more readable ?
It is obvious, and mixing cc scope (functions) with cpp (#define) is not.
Quoted 7 lines
Quoted 5 lines
tools/edump/src/eep_4k.c line 250
Quoted 3 lines
tools/edump/src/eep_4k.c new file +3
-0+PR ("Ant Chain 0" ,"0x" ,"X" , pModal->antCtrlChain[0 ]); +PR ("Antenna Common" ,"0x" ,"X" , pModal->antCtrlCommon); +PR ("Antenna Gain Chain 0" ,"" ,"d" , pModal->antennaGainCh[0 ]);..followed by 44 more lines with second and third parameter identical. What do you think about having two macros instead?
Care to show how ?
Yes.
Quoted 1 line
Quoted 1 line
Quoted 1 line
+#define
PR(_token, _p, _val_fmt, _val)\
..
Quoted 3 lines
Quoted 1 line
Yeah baby. Got another one!
Um, I am not sure what you are getting at ?.
The macros are horrible.
Quoted 1 line
just a macro to handle all that..
The point is that making it a single macro (wait, three!) was a bad idea.
Quoted 1 line
But, patches are always welcome to improve things.
Sure.
There are different responses to critical review. edump is a trivial utility but I'm anyway surprised about the fast and loose merge finger, since that leads to the above disinterest in critique.
//Peter
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
Quoted 3 lines · Peter Stuge
Quoted 1 line
But, patches are always welcome to improve things.
Sure.
We are waiting with bated breath.
Sujith
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
I dislike the name "edump". It's a tool to dump EEPROMs of ath9k chips, e.g. not a generic eeprom dumper.
PATCH 1/1 qca-swiss-army-knife: Add a tool to dump EEPROM
Hi,
For what it's worth, I've written some EEPROM dump routines in FreeBSD
- ath_ee_v14_print, ath_ee_v4k_print, ath_ee_9287_print.
They're BSD licenced. You're welcome to abuse them as much as possible.
Adrian
Quoted 6 lines · Holger Schurig
I dislike the name "edump". It's a tool to dump EEPROMs of ath9k chips, e.g. not a generic eeprom dumper.
_______________________________________________
ath9k-devel mailing list
ath9k-devel at lists.ath9k.org
https://lists.ath9k.org/mailman/listinfo/ath9k-devel