mtd: use the full-id as the keyword for some nand chips
Subsystems (2)
v5 cover mtd: use the full-id as the keyword for some nand chips
As time goes on, we begin to meet the situation that we can not get enough information from some nand chips's id data. Take some Toshiba's nand chips for example.
I have 4 Toshiba's nand chips in my hand:
TC58NVG2S0F, TC58NVG3S0F, TC58NVG5D2, TC58NVG6D2
When we read these chips' datasheets, we will get the geometry of these chips:
TC58NVG2S0F : 4096 + 224 TC58NVG3S0F : 4096 + 232 TC58NVG5D2 : 8192 + 640 TC58NVG6D2 : 8192 + 640
But we can not parse out the correct oob size for these chips from the id data. So it is time to add some new fields to the nand_flash_dev{},
and update the detection mechanisms.
v4 --> v4:
[1] remove the id_len field.
[2] based on Artem "mtd: nand: use more reasonable integer types"
[3] add more comments.
v3 --> v4:
[1] rewrite the code based on the latest l2-mtd.
[2] add the full-id nand in the nand_flash_lds.
v2 --> v3:
[1] remove the duplicated header.
[2] remove the field "ecc_len" in nand_flash_dev{}.
[3] fix some coding style warnings.
[4] add more comments
Huang Shijie (3):
mtd: add a new field for nand_flash_dev{}
mtd: add the support to parse out the full-id nand type
mtd: add 4 Toshiba nand chips for the full-id case
drivers/mtd/nand/nand_base.c | 36 +++++++++++++++++++++++++++++++++--- drivers/mtd/nand/nand_ids.c | 22 ++++++++++++++++++++++ include/linux/mtd/nand.h | 2 ++ 3 files changed, 57 insertions(+), 3 deletions(-)
PATCH v5 1/3 mtd: add a new field for nand_flash_dev{}
As time goes on, we begin to meet the situation that we can not get enough information from some nand chips's id data. Take some Toshiba's nand chips for example. I have 4 Toshiba's nand chips in my hand:
TC58NVG2S0F, TC58NVG3S0F, TC58NVG5D2, TC58NVG6D2
When we read these chips' datasheets, we will get the geometry of these chips:
TC58NVG2S0F : 4096 + 224 TC58NVG3S0F : 4096 + 232 TC58NVG5D2 : 8192 + 640 TC58NVG6D2 : 8192 + 640
But we can not parse out the correct oob size for these chips from the id data.
This patch adds @oobsize for the nand_flash_dev{} to store the oob size for these nands.
--- include/linux/mtd/nand.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/mtd/nand.h +2 -0
@@ -581,6 +581,7 @@ struct nand_chip {* @chipsize: total chip size in MiB * @erasesize: eraseblock size in bytes (determined from the extended ID if 0) * @options: stores various chip bit options +* @oobsize: OOB size */ struct nand_flash_dev {char *name;
@@ -595,6 +596,7 @@ struct nand_flash_dev {unsigned int chipsize;unsigned int erasesize;unsigned int options; +unsigned int oobsize; };/**
Signature · 1 line
1.7.1
PATCH v5 2/3 mtd: add the support to parse out the full-id nand type
In reply to Huang ShijieWhen we meet a full-id nand type which @mfr_id is true, we can use the find_full_id_nand() to parse out the neccessary information for a nand chip.
If we meet a non full-id nand type, we can handle it in the lagacy way.
--- drivers/mtd/nand/nand_base.c | 36 +++++++++++++++++++++++++++++++++--- 1 files changed, 33 insertions(+), 3 deletions(-)
drivers/mtd/nand/nand_base.c +33 -3
@@ -3123,6 +3123,30 @@ static void nand_decode_bbm_options(struct mtd_info *mtd, chip->bbt_options |=NAND_BBT_SCAN2NDPAGE ; } +static inline bool is_full_id_nand (struct nand_flash_dev *type) +{ +return type->mfr_id; +} + +static bool find_full_id_nand (struct mtd_info *mtd,struct nand_chip *chip, +struct nand_flash_dev *type,u8 *id_data,int *busw) +{ +if (!strncmp (type->id, id_data,8 )) { + mtd->writesize = type->pagesize; + mtd->erasesize = type->erasesize; + mtd->oobsize = type->oobsize; + + chip->cellinfo = id_data[2 ]; + chip->chipsize = (uint64_t )type->chipsize <<20 ; + chip->options |= type->options; + + *busw = type->options &NAND_BUSWIDTH_16 ; + +return true; + } +return false; +} +/* * Get the flash and manufacturer id and lookup if the type is supported. */
@@ -3174,9 +3198,15 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,if (!type) type = nand_flash_ids; -for (; type->name !=NULL ; type++) -if (*dev_id == type->dev_id) -break ; +for (; type->name !=NULL ; type++) { +if (is_full_id_nand (type)) { +if (find_full_id_nand (mtd, chip, type, id_data, &busw)) + goto ident_done; + }else { +if (*dev_id == type->dev_id) +break ; + } + } chip->onfi_version =0 ;if (!type->name || !type->pagesize) {
Signature · 1 line
1.7.1
Re: [PATCH v5 2/3] mtd: add the support to parse out the full-id nand type
Hi Huang,
A few nitpicks, and a few real comments.
Quoted 2 lines · Huang Shijie
When we meet a full-id nand type which @mfr_id is true, we can use the
find_full_id_nand()to parse out the neccessary information for a
s/neccessary/necessary
Quoted 3 lines
nand chip.
If we meet a non full-id nand type, we can handle it in the lagacy way.
s/lagacy/legacy
Quoted 10 lines
Signed-off-by Huang Shijie <[email protected]>--- drivers/mtd/nand/nand_base.c | 36 +++++++++++++++++++++++++++++++++--- 1 files changed, 33 insertions(+), 3 deletions(-)drivers/mtd/nand/nand_base.c +0
-0
drivers/mtd/nand/nand_base.c static void nand_decode_bbm_options(struct mtd_info *mtd, · line 3129
Quoted 7 lines
drivers/mtd/nand/nand_base.c +4
-0@@ -3123,6 +3123,30 @@ static void nand_decode_bbm_options(struct mtd_info *mtd, chip->bbt_options |=NAND_BBT_SCAN2NDPAGE ; } +static inline bool is_full_id_nand (struct nand_flash_dev *type) +{ +return type->mfr_id; +}
If we restore the id_len field (as I recommended in reply to the cover letter), then I think this check would be better performed as:
return !type->id_len;
That would really be a more specific and accurate test and can compensate for some wildly unlikely case in which a manufacturer uses manufacturer ID = 0.
Quoted 25 lines
drivers/mtd/nand/nand_base.c +19
-0+static bool find_full_id_nand (struct mtd_info *mtd,struct nand_chip *chip, +struct nand_flash_dev *type,u8 *id_data,int *busw) +{ +if (!strncmp (type->id, id_data,8 )) { + mtd->writesize = type->pagesize; + mtd->erasesize = type->erasesize; + mtd->oobsize = type->oobsize; + + chip->cellinfo = id_data[2 ]; + chip->chipsize = (uint64_t )type->chipsize <<20 ; + chip->options |= type->options; + + *busw = type->options &NAND_BUSWIDTH_16 ; + +return true; + } +return false; +} +/* * Get the flash and manufacturer id and lookup if the type is supported. */ @@ -3174,9 +3198,15 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,if (!type) type = nand_flash_ids;
drivers/mtd/nand/nand_base.c static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, · line 3206
Quoted 10 lines
drivers/mtd/nand/nand_base.c +6
-3-for (; type->name !=NULL ; type++) -if (*dev_id == type->dev_id) -break ; +for (; type->name !=NULL ; type++) { +if (is_full_id_nand (type)) { +if (find_full_id_nand (mtd, chip, type, id_data, &busw)) + goto ident_done; + }else { +if (*dev_id == type->dev_id)
Combine the previous two lines to:
} else if (*dev_id == type->dev_id) {
drivers/mtd/nand/nand_base.c static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, · line 3212
Quoted 6 lines
drivers/mtd/nand/nand_base.c +3
-0+break ; + } + } chip->onfi_version =0 ;if (!type->name || !type->pagesize) {
Brian
PATCH v5 3/3 mtd: add 4 Toshiba nand chips for the full-id case
In reply to Huang ShijieI have 4 Toshiba nand chips which can not be parsed out by the id data. We can not get the oob size from the id data. So add them as the full-id nand chips in the first of nand_flash_ids.
The nand_get_flash_type() scans the full id nands firstly.
If a full-id nand matchs, it will not continue to parse other non-full-id nand types, else it will continue to parse the non-full-id nands.
--- drivers/mtd/nand/nand_ids.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-)
drivers/mtd/nand/nand_ids.c +22 -0
@@ -10,6 +10,7 @@*/ #include <linux/module.h> #include <linux/mtd/nand.h> +#include <linux/sizes.h> #define LP_OPTIONS NAND_SAMSUNG_LP_OPTIONS#define LP_OPTIONS16 (LP_OPTIONS | NAND_BUSWIDTH_16)
@@ -22,6 +23,27 @@* extended chip ID. */ struct nand_flash_dev nand_flash_ids[] = { +/* +* The full-id nands may share the same Device ID with the non-full-id +* nands. In order to distinguish the two type nands, we put the +* full-id nands in the first of the table. So the nand_get_flash_type() +* scans the full id nands firstly. If a full-id nand matchs, it will +* not continue to parse other non-full-id nand types, else it will +* continue to parse the non-full-id nands. +*/ + {"TC58NVG2S0F 4G 3.3V 8-bit" , + { .id = {0x98 ,0xdc ,0x90 ,0x26 ,0x76 ,0x15 ,0x01 ,0x08 } }, +SZ_4K ,SZ_512 ,SZ_256K ,0 ,224 }, + {"TC58NVG3S0F 8G 3.3V 8-bit" , + { .id = {0x98 ,0xd3 ,0x90 ,0x26 ,0x76 ,0x15 ,0x02 ,0x08 } }, +SZ_4K ,SZ_1K ,SZ_256K ,0 ,232 }, + {"TC58NVG5D2 32G 3.3V 8-bit" , + { .id = {0x98 ,0xd7 ,0x94 ,0x32 ,0x76 ,0x56 ,0x09 ,0x00 } }, +SZ_8K ,SZ_4K ,SZ_1M ,0 ,640 }, + {"TC58NVG6D2 64G 3.3V 8-bit" , + { .id = {0x98 ,0xde ,0x94 ,0x82 ,0x76 ,0x56 ,0x04 ,0x20 } }, +SZ_8K ,SZ_8K ,SZ_2M ,0 ,640 }, +LEGACY_ID_NAND ("NAND 4MiB 5V 8-bit" ,0x6B ,512 ,4 ,0x2000 ,0 ),LEGACY_ID_NAND ("NAND 4MiB 3,3V 8-bit" ,0xE3 ,512 ,4 ,0x2000 ,0 ),LEGACY_ID_NAND ("NAND 4MiB 3,3V 8-bit" ,0xE5 ,512 ,4 ,0x2000 ,0 ),
Signature · 1 line
1.7.1
Re: [PATCH v5 3/3] mtd: add 4 Toshiba nand chips for the full-id case
Quoted 27 lines · Huang Shijie
I have 4 Toshiba nand chips which can not be parsed out by the id data. We can not get the oob size from the id data. So add them as the full-id nand chips in the first of
nand_flash_ids.The
nand_get_flash_type()scans the full id nands firstly.
If a full-id nand matchs, it will not continue to parse other non-full-id nand types, else it will continue to parse the non-full-id nands.Signed-off-by Huang Shijie <[email protected]>--- drivers/mtd/nand/nand_ids.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-)drivers/mtd/nand/nand_ids.c +1
-0@@ -10,6 +10,7 @@*/ #include <linux/module.h> #include <linux/mtd/nand.h> +#include <linux/sizes.h> #define LP_OPTIONS NAND_SAMSUNG_LP_OPTIONS#define LP_OPTIONS16 (LP_OPTIONS | NAND_BUSWIDTH_16)@@ -22,6 +23,27 @@* extended chip ID.
drivers/mtd/nand/nand_ids.c line 33
Quoted 10 lines
drivers/mtd/nand/nand_ids.c +8
-0*/ struct nand_flash_dev nand_flash_ids[] = { +/* +* The full-id nands may share the same Device ID with the non-full-id +* nands. In order to distinguish the two type nands, we put the +* full-id nands in the first of the table. So the nand_get_flash_type() +* scans the full id nands firstly. If a full-id nand matchs, it will +* not continue to parse other non-full-id nand types, else it will +* continue to parse the non-full-id nands. +*/
There are a few grammar/language issues (nands -> NAND chips, id -> ID, firstly -> first). Also, I don't think you need to explain the full search here. I would rewrite this whole paragraph as:
"Some incompatible NAND chips share device ID's and so must be listed by full ID. We list them first so that we can easily identify the most specific match."
Quoted 6 lines
drivers/mtd/nand/nand_ids.c +6
-0+ {"TC58NVG2S0F 4G 3.3V 8-bit" , + { .id = {0x98, 0xdc, 0x90, 0x26, 0x76, 0x15, 0x01, 0x08} }, + SZ_4K, SZ_512, SZ_256K, 0, 224}, + {"TC58NVG3S0F 8G 3.3V 8-bit", + { .id = {0x98, 0xd3, 0x90, 0x26, 0x76, 0x15, 0x02, 0x08} }, + SZ_4K, SZ_1K, SZ_256K, 0, 232},
drivers/mtd/nand/nand_ids.c line 49
Quoted 10 lines
drivers/mtd/nand/nand_ids.c +7
-0+ {"TC58NVG5D2 32G 3.3V 8-bit" , + { .id = {0x98, 0xd7, 0x94, 0x32, 0x76, 0x56, 0x09, 0x00} }, + SZ_8K, SZ_4K, SZ_1M, 0, 640}, + {"TC58NVG6D2 64G 3.3V 8-bit", + { .id = {0x98, 0xde, 0x94, 0x82, 0x76, 0x56, 0x04, 0x20} }, + SZ_8K, SZ_8K, SZ_2M, 0, 640}, +LEGACY_ID_NAND ("NAND 4MiB 5V 8-bit" ,0x6B ,512 ,4 ,0x2000 ,0 ),LEGACY_ID_NAND ("NAND 4MiB 3,3V 8-bit" ,0xE3 ,512 ,4 ,0x2000 ,0 ), LEGACY_ID_NAND("NAND 4MiB 3,3V 8-bit", 0xE5, 512, 4, 0x2000, 0),
Brian
Re: [PATCH v5 3/3] mtd: add 4 Toshiba nand chips for the full-id case
Quoted 33 lines · Brian Norris
Quoted 32 lines · Huang Shijie
I have 4 Toshiba nand chips which can not be parsed out by the id data. We can not get the oob size from the id data. So add them as the full-id nand chips in the first of
nand_flash_ids.The
nand_get_flash_type()scans the full id nands firstly.
If a full-id nand matchs, it will not continue to parse other non-full-id nand types, else it will continue to parse the non-full-id nands.Signed-off-by Huang Shijie<[email protected]>--- drivers/mtd/nand/nand_ids.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-)drivers/mtd/nand/nand_ids.c +4
-0@@ -10,6 +10,7 @@*/ #include <linux/module.h> #include <linux/mtd/nand.h> +#include <linux/sizes.h> #define LP_OPTIONS NAND_SAMSUNG_LP_OPTIONS#define LP_OPTIONS16 (LP_OPTIONS | NAND_BUSWIDTH_16)@@ -22,6 +23,27 @@* extended chip ID. */ struct nand_flash_dev nand_flash_ids[] = { +/* +* The full-id nands may share the same Device ID with the non-full-id +* nands. In order to distinguish the two type nands, we put the
Quoted 9 lines
drivers/mtd/nand/nand_ids.c line 33
Quoted 5 lines
drivers/mtd/nand/nand_ids.c +5
-0+* full-id nands in the first of the table. So the nand_get_flash_type() +* scans the full id nands firstly. If a full-id nand matchs, it will +* not continue to parse other non-full-id nand types, else it will +* continue to parse the non-full-id nands. +*/ There are a few grammar/language issues (nands -> NAND chips, id -> ID, firstly -> first). Also, I don't think you need to explain the full search here. I would rewrite this whole paragraph as:
sorry for my poor english.
Quoted 4 lines
"Some incompatible NAND chips share device ID's and so must be listed by full ID. We list them first so that we can easily identify the most specific match."
thanks. I will use this description.
Huang Shijie
Re: [PATCH v5 3/3] mtd: add 4 Toshiba nand chips for the full-id case
Quoted 1 line · Huang Shijie
sorry for my poor english.
No need to apologize.
Thanks for braving through the 6 iterations of this! We were going to need this eventually anyway. Now that the dust is settling, your v6 is looking pretty good. I'll have a closer look later and probably give my Acked/Reviewed-by.
Brian
Quoted 12 lines · Huang Shijie
As time goes on, we begin to meet the situation that we can not get enough information from some nand chips's id data. Take some Toshiba's nand chips for example.
I have 4 Toshiba's nand chips in my hand:TC58NVG2S0F, TC58NVG3S0F, TC58NVG5D2, TC58NVG6D2When we read these chips' datasheets, we will get the geometry of these chips:
TC58NVG2S0F : 4096 + 224 TC58NVG3S0F : 4096 + 232 TC58NVG5D2 : 8192 + 640 TC58NVG6D2 : 8192 + 640
Quoted 8 lines
But we can not parse out the correct oob size for these chips from the id data. So it is time to add some new fields to the nand_flash_dev{},
and update the detection mechanisms.v4 --> v4:
[1] remove theid_lenfield.
[2] based on Artem "mtd: nand: use more reasonable integer types"
[3] add more comments.
Sorry for not posting this earlier, but why don't we want an id_len field? NAND chips often only have a 5-byte or 6-byte ID "defined" in their datasheet, and so the next few bytes aren't guaranteed to be any particular value. Wouldn't we want to accommodate for any potential variation in the "undefined" bytes? (These bytes do typically have a pattern, and in fact, we currently rely on that fact.) Also, I can easily foresee a situation in which someone might want to support NAND based solely on the datasheet, not waiting till they get a sample of that chip in their hands. In that case, they cannot specify a full 8 bytes in the table; they can (and should) only specify the few substring found in their datasheet.
Really, the only argument I see for dropping id_len is to save space. I think this is a bad choice.
... <snip> ...
Brian
Quoted 34 lines · Brian Norris
Quoted 12 lines · Huang Shijie
As time goes on, we begin to meet the situation that we can not get enough information from some nand chips's id data. Take some Toshiba's nand chips for example.
I have 4 Toshiba's nand chips in my hand:TC58NVG2S0F, TC58NVG3S0F, TC58NVG5D2, TC58NVG6D2When we read these chips' datasheets, we will get the geometry of these chips:
TC58NVG2S0F : 4096 + 224 TC58NVG3S0F : 4096 + 232 TC58NVG5D2 : 8192 + 640 TC58NVG6D2 : 8192 + 640Quoted 8 lines
But we can not parse out the correct oob size for these chips from the id data. So it is time to add some new fields to the nand_flash_dev{},
and update the detection mechanisms.v4 --> v4:
[1] remove theid_lenfield.
[2] based on Artem "mtd: nand: use more reasonable integer types"
[3] add more comments.Sorry for not posting this earlier, but why don't we want an
id_lenfield? NAND chips often only have a 5-byte or 6-byte ID "defined" in their datasheet, and so the next few bytes aren't guaranteed to be any particular value. Wouldn't we want to accommodate for any potential variation in the "undefined" bytes? (These bytes do typically have a pattern, and in fact, we currently rely on that fact.) Also, I can easily foresee a situation in which someone might want to support NAND based solely on the datasheet, not waiting till they get a sample of that chip in their hands. In that case, they cannot specify a full 8 bytes in the table; they can (and should) only specify the few substring found in their datasheet.
Quoted 2 lines
Really, the only argument I see for dropping
id_lenis to save space. I think this is a bad choice.
Let's take a flash which has 5 bytes ID length, suppose it is {1, 2, 3, 4, 5}. The 8-byte table value for this flash would be:
{1, 2, 3, 4, 5, 0, 0, 0}. When we read the ID sequence, we need to start with allocating an 8-byte array and initializing it to 0. Then we read the 5-byte ID and end up with: {1, 2, 3, 4, 5, 0, 0, 0}. And we successfully match the table entry.
That was my thinking.
There is a potential problem: there may be a flash with 6 bytes ID with value {1, 2, 3, 4, 5, 0}, in which case the algorithm would not work.
However, I consider this to be very unlikely. And even if this unlikely situation happens, it will probably be noticed and we could fix this with adding the ID length field.
My rationale is avoiding over-designing and trying to cover low probability theoretical cases.
But yes, I did not really strongly opposed the field, it was more that I asked questions from Huang about why is this needed, and expected to hear some justification. Huang preferred to answer that he does not really need this, and I just thought that if this is all he can say, then he should not add it.
This is often, generally, the role of maintainer who cannot get into all the details - ask questions and validate the answers. Generally, good answers have correlation with quality code.
You did provide good arguments thanks! If my rationally is not convincing enough and you think this is not over-engineering, let's have the ID length field.
BTW, Huang, I think we should introduce a Macro instead of the '8' constant. And if ATM we do not have 8-byte ID's in our table, we should make the macro to contain a smaller number. This number can be increased when needed.
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 35 lines · Artem Bityutskiy
Quoted 34 lines · Brian Norris
Quoted 12 lines · Huang Shijie
As time goes on, we begin to meet the situation that we can not get enough information from some nand chips's id data. Take some Toshiba's nand chips for example.
I have 4 Toshiba's nand chips in my hand:TC58NVG2S0F, TC58NVG3S0F, TC58NVG5D2, TC58NVG6D2When we read these chips' datasheets, we will get the geometry of these chips:
TC58NVG2S0F : 4096 + 224 TC58NVG3S0F : 4096 + 232 TC58NVG5D2 : 8192 + 640 TC58NVG6D2 : 8192 + 640Quoted 8 lines
But we can not parse out the correct oob size for these chips from the id data. So it is time to add some new fields to the nand_flash_dev{},
and update the detection mechanisms.v4 --> v4:
[1] remove theid_lenfield.
[2] based on Artem "mtd: nand: use more reasonable integer types"
[3] add more comments.Sorry for not posting this earlier, but why don't we want an
id_lenfield? NAND chips often only have a 5-byte or 6-byte ID "defined" in their datasheet, and so the next few bytes aren't guaranteed to be any particular value. Wouldn't we want to accommodate for any potential variation in the "undefined" bytes? (These bytes do typically have a pattern, and in fact, we currently rely on that fact.) Also, I can easily foresee a situation in which someone might want to support NAND based solely on the datasheet, not waiting till they get a sample of that chip in their hands. In that case, they cannot specify a full 8 bytes in the table; they can (and should) only specify the few substring found in their datasheet.
Quoted 8 lines
Quoted 2 lines
Really, the only argument I see for dropping
id_lenis to save space. I think this is a bad choice.Let's take a flash which has 5 bytes ID length, suppose it is {1, 2, 3, 4, 5}. The 8-byte table value for this flash would be:
{1, 2, 3, 4, 5, 0, 0, 0}. When we read the ID sequence, we need to start with allocating an 8-byte array and initializing it to 0. Then we read the 5-byte ID and end up with: {1, 2, 3, 4, 5, 0, 0, 0}. And we
When we "read the 5-byte ID", are you referring to reading the ID from the NAND flash? Unfortunately, things are *never* this nice. Those last 3 bytes can be anything. Often they wrap around; see my nand_id_len() function. But they rarely are 0.
So, we have no way to identify (100% guaranteed) a 5-byte or 6-byte ID that comes from the flash. But we *can* compare a substring of it against 5 or 6 byte ID in our table, if they are marked with lengths.
Quoted 7 lines
successfully match the table entry.
That was my thinking.
There is a potential problem: there may be a flash with 6 bytes ID with value {1, 2, 3, 4, 5, 0}, in which case the algorithm would not work.
Quoted 6 lines
However, I consider this to be very unlikely. And even if this unlikely situation happens, it will probably be noticed and we could fix this with adding the ID length field.
My rationale is avoiding over-designing and trying to cover low probability theoretical cases.
I agree about avoiding over-designing. I only would add that my scenario's are not so theoretical. It just happens that I (and others) have successfully managed to devise heuristics for most of the 5-byte and 6-byte IDs I've seen.
Quoted 9 lines
But yes, I did not really strongly opposed the field, it was more that I asked questions from Huang about why is this needed, and expected to hear some justification. Huang preferred to answer that he does not really need this, and I just thought that if this is all he can say, then he should not add it.
This is often, generally, the role of maintainer who cannot get into all the details - ask questions and validate the answers. Generally, good answers have correlation with quality code.
That is entirely reasonable.
Quoted 3 lines
You did provide good arguments thanks! If my rationally is not convincing enough and you think this is not over-engineering, let's have the ID length field.
I do not think that it is over-engineering, but with the immediate needs (Huang's patch set), it is not necessary. I am OK with either result. It's not too difficult to add the field as needed.
Quoted 4 lines
BTW, Huang, I think we should introduce a Macro instead of the '8' constant. And if ATM we do not have 8-byte ID's in our table, we should make the macro to contain a smaller number. This number can be increased when needed.
Sounds like a good idea. (But I don't expect that this will need increased.)
Brian