2012-12-11 20:36:15

by Gabor Juhos

[permalink] [raw]
Subject: [PATCH 1/3] qca-swiss-army-knife: remove the artificial column size limitation

It is obsolete since the SHA1 checksums are used.

Signed-off-by: Gabor Juhos <[email protected]>
---
tools/initvals/initvals.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/tools/initvals/initvals.c b/tools/initvals/initvals.c
index 6522de6..4413e04 100644
--- a/tools/initvals/initvals.c
+++ b/tools/initvals/initvals.c
@@ -449,21 +449,11 @@ static void ath9k_hw_print_initval(const char *name, const u32 *array, u32 rows,
u32 p_columns;
u32 col, row;

- if (wide) {
+ if (wide)
p_columns = columns;
- } else {
+ else
p_columns = columns > 5 ? 5 : columns;

- /*
- * This checksum stuff is designed for columns <= 8),
- * and spreads the checksum over 64 bits but since currently
- * the initval max column size is 6 we only use the first 48
- * bits.
- */
- if (columns > 6)
- return;
- }
-
if (onedim)
printf("static const u32 %s[] = {\n", name);
else
--
1.7.10



2012-12-11 23:15:20

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH 3/3] qca-swiss-army-knife: automatically detect wide initval arrays

On Tue, Dec 11, 2012 at 12:36 PM, Gabor Juhos <[email protected]> wrote:
> The number of the columns to be printed usually equals
> with the actual columns. The only exceptions are the
> Modes arrays, where the last column is not used by
> ath9k.
>
> The patch modifies the 'ath9k_get_p_columns' helper
> so that can determine the correct number of columns
> based on the name of the array. The the patch also
> removes the 'wide' argument of various functions
> because that is not necessary anymore. Additionaly,
> the superfluous INI_PRINTW macro is removed as well.
>
> Signed-off-by: Gabor Juhos <[email protected]>

Thanks, applied and pushed all!

Luis

2012-12-11 20:36:15

by Gabor Juhos

[permalink] [raw]
Subject: [PATCH 2/3] qca-swiss-army-knife: add 'ath9k_get_p_columns' helper

The number of the columns to be printed is computed in
two different function. Add a helper function for that
and remove the duplicated code.

Signed-off-by: Gabor Juhos <[email protected]>
---
tools/initvals/initvals.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/tools/initvals/initvals.c b/tools/initvals/initvals.c
index 4413e04..94f5aba 100644
--- a/tools/initvals/initvals.c
+++ b/tools/initvals/initvals.c
@@ -443,17 +443,26 @@ static u32 ath9k_patch_initval(u32 idx, u32 val)
return val;
}

-static void ath9k_hw_print_initval(const char *name, const u32 *array, u32 rows,
- u32 columns, bool onedim, bool wide)
+static u32 ath9k_get_p_columns(u32 columns, bool wide)
{
u32 p_columns;
- u32 col, row;

if (wide)
p_columns = columns;
else
p_columns = columns > 5 ? 5 : columns;

+ return p_columns;
+}
+
+static void ath9k_hw_print_initval(const char *name, const u32 *array, u32 rows,
+ u32 columns, bool onedim, bool wide)
+{
+ u32 p_columns;
+ u32 col, row;
+
+ p_columns = ath9k_get_p_columns(columns, wide);
+
if (onedim)
printf("static const u32 %s[] = {\n", name);
else
@@ -508,10 +517,7 @@ static char *ath9k_hw_check_initval(const u32 *array, u32 rows, u32 columns,
u32 p_columns;
u32 col, row;

- if (wide)
- p_columns = columns;
- else
- p_columns = columns > 5 ? 5 : columns;
+ p_columns = ath9k_get_p_columns(columns, wide);

SHA1_Init(&ctx);
for (row = 0; row < rows; row++) {
--
1.7.10


2012-12-11 20:36:19

by Gabor Juhos

[permalink] [raw]
Subject: [PATCH 3/3] qca-swiss-army-knife: automatically detect wide initval arrays

The number of the columns to be printed usually equals
with the actual columns. The only exceptions are the
Modes arrays, where the last column is not used by
ath9k.

The patch modifies the 'ath9k_get_p_columns' helper
so that can determine the correct number of columns
based on the name of the array. The the patch also
removes the 'wide' argument of various functions
because that is not necessary anymore. Additionaly,
the superfluous INI_PRINTW macro is removed as well.

Signed-off-by: Gabor Juhos <[email protected]>
---
tools/initvals/initvals.c | 55 +++++++++++++++++++++------------------------
1 file changed, 26 insertions(+), 29 deletions(-)

diff --git a/tools/initvals/initvals.c b/tools/initvals/initvals.c
index 94f5aba..3f2c7cd 100644
--- a/tools/initvals/initvals.c
+++ b/tools/initvals/initvals.c
@@ -356,10 +356,10 @@ struct initval_family {
#define INI_PRINT_DUP(_array, _ref) do { \
if (check) { \
char *sha1sum; \
- sha1sum = ath9k_hw_check_initval((const u32 *) &_array,\
+ sha1sum = ath9k_hw_check_initval(#_array, \
+ (const u32 *) &_array,\
ARRAY_SIZE(_array), \
- ARRAY_SIZE((_array)[0]), \
- false); \
+ ARRAY_SIZE((_array)[0])); \
printf("%s "#_array"\n", sha1sum); \
} else { \
if (sizeof(_ref) == sizeof(_array) && \
@@ -370,30 +370,26 @@ struct initval_family {
ath9k_hw_print_initval(#_array, (const u32 *) _array, \
ARRAY_SIZE(_array), \
ARRAY_SIZE((_array)[0]), \
- false, \
false); \
} \
} while (0)

-#define _INI_PRINT(_label, _array, _wide) do { \
+#define INI_PRINT(_array) do { \
if (check) { \
char *sha1sum; \
- sha1sum = ath9k_hw_check_initval((const u32 *) &_array,\
+ sha1sum = ath9k_hw_check_initval(#_array, \
+ (const u32 *) &_array,\
ARRAY_SIZE(_array), \
- ARRAY_SIZE((_array)[0]), \
- _wide); \
- printf("%s " _label "\n", sha1sum); \
+ ARRAY_SIZE((_array)[0])); \
+ printf("%s " #_array "\n", sha1sum); \
} else { \
- ath9k_hw_print_initval((_label), (const u32 *) _array, \
+ ath9k_hw_print_initval(#_array, (const u32 *) _array, \
ARRAY_SIZE(_array), \
ARRAY_SIZE((_array)[0]), \
- false, \
- _wide); \
+ false); \
} \
} while (0)

-#define INI_PRINT(_array) _INI_PRINT(#_array, _array, false)
-#define INI_PRINTW(_array) _INI_PRINT(#_array, _array, true)

#define INI_PRINT_ONEDIM(_array) do { \
if (check) { \
@@ -443,25 +439,26 @@ static u32 ath9k_patch_initval(u32 idx, u32 val)
return val;
}

-static u32 ath9k_get_p_columns(u32 columns, bool wide)
+static u32 ath9k_get_p_columns(const char *name, u32 columns)
{
- u32 p_columns;
-
- if (wide)
- p_columns = columns;
- else
- p_columns = columns > 5 ? 5 : columns;
+ if (columns == 6 && strstr(name, "Modes")) {
+ /*
+ * The last column contain values for Turbo mode.
+ * Don't print that because it is not used in ath9k.
+ */
+ return 5;
+ }

- return p_columns;
+ return columns;
}

static void ath9k_hw_print_initval(const char *name, const u32 *array, u32 rows,
- u32 columns, bool onedim, bool wide)
+ u32 columns, bool onedim)
{
u32 p_columns;
u32 col, row;

- p_columns = ath9k_get_p_columns(columns, wide);
+ p_columns = ath9k_get_p_columns(name, columns);

if (onedim)
printf("static const u32 %s[] = {\n", name);
@@ -508,8 +505,8 @@ static void ath9k_hw_print_initval(const char *name, const u32 *array, u32 rows,
printf("};\n\n");
}

-static char *ath9k_hw_check_initval(const u32 *array, u32 rows, u32 columns,
- bool wide)
+static char *ath9k_hw_check_initval(const char *name, const u32 *array,
+ u32 rows, u32 columns)
{
SHA1_CTX ctx;
unsigned char digest[SHA1_DIGEST_SIZE];
@@ -517,7 +514,7 @@ static char *ath9k_hw_check_initval(const u32 *array, u32 rows, u32 columns,
u32 p_columns;
u32 col, row;

- p_columns = ath9k_get_p_columns(columns, wide);
+ p_columns = ath9k_get_p_columns(name, columns);

SHA1_Init(&ctx);
for (row = 0; row < rows; row++) {
@@ -775,7 +772,7 @@ static void ar955x_1p0_hw_print_initvals(bool check)
INI_PRINT(ar955x_1p0_baseband_core_txfir_coeff_japan_2484);
INI_PRINT(ar955x_1p0_baseband_postamble);
INI_PRINT(ar955x_1p0_radio_core);
- INI_PRINTW(ar955x_1p0_modes_xpa_tx_gain_table);
+ INI_PRINT(ar955x_1p0_modes_xpa_tx_gain_table);
INI_PRINT(ar955x_1p0_mac_core);
INI_PRINT(ar955x_1p0_common_rx_gain_table);
INI_PRINT(ar955x_1p0_baseband_core);
@@ -784,7 +781,7 @@ static void ar955x_1p0_hw_print_initvals(bool check)
INI_PRINT(ar955x_1p0_common_wo_xlna_rx_gain_bounds);
INI_PRINT(ar955x_1p0_mac_postamble);
INI_PRINT(ar955x_1p0_common_rx_gain_bounds);
- INI_PRINTW(ar955x_1p0_modes_no_xpa_tx_gain_table);
+ INI_PRINT(ar955x_1p0_modes_no_xpa_tx_gain_table);
INI_PRINT(ar955x_1p0_soc_postamble);
INI_PRINT(ar955x_1p0_modes_fast_clock);
}
--
1.7.10