STRUCT NAND_ECC_CTRL(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… NAME πŸ’…

okay so bestie, welcome to struct nand_ecc_ctrl(9) from the Kernel API Manual β€” this is literally the Control structure for ECC. it’s the struct where all the ECC control vibes live, and we’re gonna go through every single member together, no skipping, no cap πŸ’–


✨ SYNOPSIS ✨

here’s the whole struct, bestie β€” every field and function pointer exactly as it appears πŸ‘‘

struct nand_ecc_ctrl {
    enum nand_ecc_engine_type engine_type;
    enum nand_ecc_placement placement;
    enum nand_ecc_algo algo;
    int steps;
    int size;
    int bytes;
    int total;
    int strength;
    int prepad;
    int postpad;
    unsigned int options;
    u8 *calc_buf;
    u8 *code_buf;
    void (*hwctl)(struct nand_chip *chip, int mode);
    int (*calculate)(struct nand_chip *chip, const uint8_t *dat, uint8_t *ecc_code);
    int (*correct)(struct nand_chip *chip, uint8_t *dat, uint8_t *read_ecc, uint8_t *calc_ecc);
    int (*read_page_raw)(struct nand_chip *chip, uint8_t *buf, int oob_required, int page);
    int (*write_page_raw)(struct nand_chip *chip, const uint8_t *buf, int oob_required, int page);
    int (*read_page)(struct nand_chip *chip, uint8_t *buf, int oob_required, int page);
    int (*read_subpage)(struct nand_chip *chip, uint32_t offs, uint32_t len, uint8_t *buf, int page);
    int (*write_subpage)(struct nand_chip *chip, uint32_t offset, uint32_t data_len, const uint8_t *data_buf, int oob_required, int page);
    int (*write_page)(struct nand_chip *chip, const uint8_t *buf, int oob_required, int page);
    int (*write_oob_raw)(struct nand_chip *chip, int page);
    int (*read_oob_raw)(struct nand_chip *chip, int page);
    int (*read_oob)(struct nand_chip *chip, int page);
    int (*write_oob)(struct nand_chip *chip, int page);
};

πŸŽ€ Members πŸŽ€

  • engine_type β€” ECC engine type. the whole β€œwhat kind of ECC engine is this” situation πŸ’«
  • placement β€” OOB bytes placement. where the out-of-band bytes are doing their thing ✨
  • algo β€” ECC algorithm. the algorithm in question, periodt 🌸
  • steps β€” number of ECC steps per page. count ’em πŸ‘‘
  • size β€” data bytes per ECC step. the data chunk size per step πŸ’–
  • bytes β€” ECC bytes per step. how many ECC bytes each step gets πŸŽ€
  • total β€” total number of ECC bytes per page. the whole page’s ECC byte count, fr fr πŸ¦‹
  • strength β€” max number of correctible bits per ECC step. yes, β€œcorrectible,” we’re keeping it exactly like that πŸ’…
  • prepad β€” padding information for syndrome based ECC generators. prepad stays prepad 😌
  • postpad β€” padding information for syndrome based ECC generators. postpad, same energy, different side ✨
  • options β€” ECC specific options (see NAND_ECC_XXX flags defined above). flags defined above, iykyk πŸ”₯
  • calc_buf β€” buffer for calculated ECC, size is oobsize. calculated ECC goes here πŸ’–
  • code_buf β€” buffer for ECC read from flash, size is oobsize. ECC read from flash goes here 🌈
  • hwctl β€” function to control hardware ECC generator. Must only be provided if an hardware ECC is available. so do not just casually wire it up, bestie 😭
  • calculate β€” function for ECC calculation or readback from ECC hardware. calculation or readback, both iconic 🫢
  • correct β€” function for ECC correction, matching to ECC generator (sw/hw). Should return a positive number representing the number of corrected bitflips, -EBADMSG if the number of bitflips exceed ECC strength, or any other error code if the error is not directly related to correction. If -EBADMSG is returned the input buffers should be left untouched. okay this one is important β€” read it twice, bestie πŸ’€
  • read_page_raw β€” function to read a raw page without ECC. This function should hide the specific layout used by the ECC controller and always return contiguous in-band and out-of-band data even if they’re not stored contiguously on the NAND chip (e.g. NAND_ECC_PLACEMENT_INTERLEAVED interleaves in-band and out-of-band data). layout hiding, contiguous return, no surprises ✨
  • write_page_raw β€” function to write a raw page without ECC. This function should hide the specific layout used by the ECC controller and consider the passed data as contiguous in-band and out-of-band data. ECC controller is responsible for doing the appropriate transformations to adapt to its specific layout (e.g. NAND_ECC_PLACEMENT_INTERLEAVED interleaves in-band and out-of-band data). so the controller handles the transformation glow-up πŸ’…
  • read_page β€” function to read a page according to the ECC generator requirements; returns maximum number of bitflips corrected in any single ECC step, -EIO hw error. read page, return the max corrected bitflips in any single step, or -EIO on hw error πŸ‘‘
  • read_subpage β€” function to read parts of the page covered by ECC; returns same as read_page. subpage read, same return vibe as read_page πŸ¦‹
  • write_subpage β€” function to write parts of the page covered by ECC. subpage write, ECC-covered parts only 🌸
  • write_page β€” function to write a page according to the ECC generator requirements. write page, ECC generator requirements, periodt πŸ’–
  • write_oob_raw β€” function to write chip OOB data without ECC. raw OOB write, no ECC πŸŽ€
  • read_oob_raw β€” function to read chip OOB data without ECC. raw OOB read, no ECC ✨
  • read_oob β€” function to read chip OOB data. chip OOB data read, that’s the whole thing πŸ’«
  • write_oob β€” function to write chip OOB data. chip OOB data write, slay πŸ’…

🌈 SEE ALSO 🌈

Kernel file ./include/linux/mtd/rawnand.h β€” and the whole friend group is here: struct nand_parameters(9), struct nand_id(9), struct nand_ecc_step_info(9), struct nand_ecc_caps(9), struct nand_sdr_timings(9), struct nand_nvddr_timings(9), enum nand_interface_type(9), struct nand_interface_config(9), nand_interface_is_sdr(9), nand_interface_is_nvddr(9), nand_get_sdr_timings(9), nand_get_nvddr_timings(9), struct nand_op_cmd_instr(9), struct nand_op_addr_instr(9), struct nand_op_data_instr(9), struct nand_op_waitrdy_instr(9), enum nand_op_instr_type(9), struct nand_op_instr(9), struct nand_subop(9), struct nand_op_parser_addr_constraints(9), struct nand_op_parser_data_constraints(9), struct nand_op_parser_pattern_elem(9), struct nand_op_parser_pattern(9), struct nand_op_parser(9), struct nand_operation(9), struct nand_controller_ops(9), struct nand_controller(9), struct nand_legacy(9), struct nand_chip_ops(9), struct nand_manufacturer(9), struct nand_secure_region(9), struct nand_chip(9), nand_get_interface_config(9), struct nand_flash_dev(9), nand_opcode_8bits(9), nand_get_data_buf(9). go click through the whole squad, bestie 🫢


okay that’s the whole page, and yes it ate πŸ’– this one lives under ./include/linux/mtd, dated October 2026, and it’s all about struct nand_ecc_ctrl(9) β€” byeee πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from