From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Daniel Walter <dwalter@sigma-star.at>
Cc: linux-mtd@lists.infradead.org,
Richard Weinberger <richard@nod.at>,
computersforpeace@gmail.com, dwmw2@infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 19/46] mtd: nandsim: UAPI v1
Date: Sun, 20 Nov 2016 11:13:35 +0100 [thread overview]
Message-ID: <20161120111335.125f4a4b@bbrezillon> (raw)
In-Reply-To: <d7d9e926ff122be5801b6788b96adb8d24289ceb.1474450296.git.dwalter@sigma-star.at>
Daniel, Richard,
On Wed, 21 Sep 2016 11:50:45 +0200
Daniel Walter <dwalter@sigma-star.at> wrote:
> From: Richard Weinberger <richard@nod.at>
>
> Expose nandsim creation and delete functions
> to user-space
Did you consider using configfs for nandsim dev creation/removal. The
main benefit I see in using configfs is that you can extend the
parameters without breaking the ABI.
Here is an example of what I have in mind:
mtdsim subsystem:
<configfs-mountpoint>/mtdsim
nand backend:
<configfs-mountpoint>/mtdsim/nand
create and configure a new nandsim device:
mkdir <configfs-mountpoint>/mtdsim/nand/<dev-name>
echo xxx > <configfs-mountpoint>/mtdsim/nand/<dev-name>/pagesize
echo xxx > <configfs-mountpoint>/mtdsim/nand/<dev-name>/oobsize
...
create and configure a partitition:
mkdir <configfs-mountpoint>/mtdsim/nand/<dev-name>/<part-name>
echo xxx > <configfs-mountpoint>/mtdsim/nand/<dev-name>/<part-name>/offset
echo xxx > <configfs-mountpoint>/mtdsim/nand/<dev-name>/<part-name>/size
Once your done with the configuration of your nandsim device, you
can register it by doing:
echo 1 > <configfs-mountpoint>/mtdsim/nand/<dev-name>/enable
and unregister it with:
echo 0 > <configfs-mountpoint>/mtdsim/nand/<dev-name>/enable
This way, each time you need to add a new feature (bitflips emulation,
paired pages emulation, ...) or a new property, you can just add an
extra attribute to the configfs interface without breaking the previous
ABI.
I'd really prefer this solution over the nandsim_ctrl dev exposed in
/dev/.
What do you think.
>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> include/uapi/mtd/nandsim-user.h | 102 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 102 insertions(+)
> create mode 100644 include/uapi/mtd/nandsim-user.h
>
> diff --git a/include/uapi/mtd/nandsim-user.h b/include/uapi/mtd/nandsim-user.h
> new file mode 100644
> index 0000000..b52d620
> --- /dev/null
> +++ b/include/uapi/mtd/nandsim-user.h
> @@ -0,0 +1,102 @@
> +#ifndef __NANDSIM_USER_H__
> +#define __NANDSIM_USER_H__
> +
> +#include <linux/types.h>
> +
> +#define NANDSIM_IOC_MAGIC 'n'
> +
> +#define NANDSIM_IOC_NEW_INSTANCE _IOW(NANDSIM_IOC_MAGIC, 0, struct ns_new_instance_req)
> +#define NANDSIM_IOC_DESTROY_INSTANCE _IOW(NANDSIM_IOC_MAGIC, 1, struct ns_destroy_instance_req)
> +
> +#define NANDSIM_MAX_DEVICES 32
> +#define NANDSIM_MAX_PARTS 32
> +
> +enum ns_backend_type {
> + NANDSIM_BACKEND_RAM = 0,
> + NANDSIM_BACKEND_CACHEFILE = 1,
> + NANDSIM_BACKEND_FILE = 2,
> + NANDSIM_BACKEND_MAX,
> +};
> +
> +/**
> + * struct ns_new_instance_req - Create a new nandsim instance.
> + *
> + * @id_bytes: NAND ID of the simulated NAND chip
> + * @bus_width: bus width to emulate, either 8 or 16
> + * @bbt_mode: bad block table mode, 0 OOB, 1 BBT with marker in OOB,
> + * 2 BBT with marker in data area
> + * @no_oob: backing file contains no OOB data
> + * @bch_strength: instead of hamming ECC use BCH with given strength
> + * @parts_num: number of MTD partitions to create
> + * @parts: partition sizes in physical erase blocks, used then @parts_num > 0
> + * @backend: backend type, see @ns_backend_type
> + * @file_fd: file describtor of backend, only for @NANDSIM_BACKEND_CACHEFILE
> + * and @NANDSIM_BACKEND_FILE.
> + * @bitflips: maximum number of random bit flips per page
> + * @overridesize: specifies the NAND size overriding the ID bytes
> + * @access_delay: initial page access delay (microseconds)
> + * @program_delay: page program delay (microseconds)
> + * @erase_delay: sector erase delay (milliseconds)
> + * @output_cycle: word output, from flash, time (nanoseconds)
> + * @input_cycle: word input, to flash, time (nanoseconds)
> + * @simelem_num: number of simulation elements appened to this
> + * data structure. see @ns_simelement_prop
> + *
> + * This struct is used with the @NANDSIM_IOC_NEW_INSTANCE ioctl command.
> + * It creates a new nandsim instance from the given parameter.
> + * The ioctl command returns in case of success the nandsim id of the new
> + * instance, in case of error a negative value.
> + *
> + * Not all fields in the struct have to be filled, if nandsim should
> + * use a default ignore the value, fill with 0.
> + * The only mandatory fields are @id_bytes and @bus_width.
> + * When @no_oob is non-zero @bch_strength cannot be used since
> + * @no_oob implies that no ECC is used.
> + */
> +struct ns_new_instance_req {
> + __s8 id_bytes[8];
> +
> + __s8 bus_width;
> + __s8 bbt_mode;
> + __s8 no_oob;
> + __s32 bch_strength;
> +
> + __s8 parts_num;
> + __s32 parts[NANDSIM_MAX_PARTS];
> +
> + __s8 backend;
> + __s32 file_fd;
> +
> + __s32 bitflips;
> + __s32 overridesize;
> + __s32 access_delay;
> + __s32 program_delay;
> + __s32 erase_delay;
> + __s32 output_cycle;
> + __s32 input_cycle;
> +
> + __s32 padding[4];
> +
> + __s32 simelem_num;
> +} __packed;
> +
> +enum {
> + NANDSIM_SIMELEM_BADBLOCK = 0,
> + NANDSIM_SIMELEM_WEAKBLOCK,
> + NANDSIM_SIMELEM_WEAKPAGE,
> + NANDSIM_SIMELEM_GRAVEPAGE,
> +};
> +
> +struct ns_simelement_prop {
> + __s8 elem_type;
> + __s32 elem_id;
> + __s32 elem_attr;
> + __s8 padding[7];
> +} __packed;
> +
> +struct ns_destroy_instance_req {
> + __s8 id;
> + __s8 padding[7];
> +} __packed;
> +
> +#endif /* __NANDSIM_USER_H__ */
next prev parent reply other threads:[~2016-11-20 10:14 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-21 9:43 [PATCH v2 00/46] Nandsim facelift (part I of II) Daniel Walter
2016-09-21 9:43 ` [PATCH v2 01/46] mtdpart: Propagate _get/put_device() Daniel Walter
2016-09-21 10:15 ` Boris Brezillon
2016-09-28 20:16 ` Brian Norris
2016-12-14 19:24 ` Karl Beldan
2016-12-14 21:09 ` Brian Norris
2016-12-14 21:12 ` Richard Weinberger
2016-12-14 23:40 ` Brian Norris
2016-12-15 7:09 ` Karl Beldan
2016-12-15 7:51 ` Richard Weinberger
2016-12-28 18:53 ` Karl Beldan
2016-09-21 9:44 ` [PATCH v2 02/46] mtd: nand: Provide nand_cleanup() function to free NAND related resources Daniel Walter
2016-09-21 9:58 ` Boris Brezillon
2016-09-21 12:43 ` kbuild test robot
2016-09-21 14:25 ` Boris Brezillon
2016-09-21 14:38 ` Daniel Walter
2016-09-21 14:42 ` Boris Brezillon
2016-09-21 9:45 ` [PATCH v2 03/46] mtd: Don't unconditionally unregister reboot notifier Daniel Walter
2016-09-21 14:31 ` Boris Brezillon
2016-09-21 14:33 ` Daniel Walter
2016-10-09 5:20 ` Brian Norris
2016-09-21 9:45 ` [PATCH v2 04/46] mtd: Don't unconditionally execute remove notifiers Daniel Walter
2016-09-21 9:46 ` [PATCH v2 05/46] mtd: Don't print a scary message when trying to remove a busy MTD Daniel Walter
2016-09-21 9:46 ` [PATCH v2 06/46] mtd: nandsim: Add basic control file support Daniel Walter
2016-09-21 9:47 ` [PATCH v2 07/46] mtd: nandsim: Begin with removal of global state Daniel Walter
2016-09-21 9:47 ` [PATCH v2 08/46] mtd: nandsim: Kill global nsmtd Daniel Walter
2016-09-21 9:47 ` [PATCH v2 09/46] mtd: nandsim: Don't directly use module parameters Daniel Walter
2016-09-21 9:48 ` [PATCH v2 10/46] mtd: nandsim: Add helper functions for pointer magic Daniel Walter
2016-09-21 9:48 ` [PATCH v2 11/46] mtd: nandsim: Factor out nandsim parameters Daniel Walter
2016-09-21 9:48 ` [PATCH v2 12/46] mtd: nandsim: Make debugfs logic multi instance capable Daniel Walter
2016-09-21 9:49 ` [PATCH v2 13/46] mtd: nandsim: Add final logic for multiple instances Daniel Walter
2016-09-21 9:49 ` [PATCH v2 14/46] mtd: nandsim: Add simulator id to MTD parition name Daniel Walter
2016-09-21 9:49 ` [PATCH v2 15/46] mtd: nandsim: Introduce backend operations Daniel Walter
2016-09-21 9:49 ` [PATCH v2 16/46] mtd: nandsim: Print error when backend init failed Daniel Walter
2016-09-21 9:50 ` [PATCH v2 17/46] mtd: nandsim: Allow external backends Daniel Walter
2016-09-21 9:50 ` [PATCH v2 18/46] mtd: nandsim: Add basic support for a file backend Daniel Walter
2016-09-21 9:50 ` [PATCH v2 19/46] mtd: nandsim: UAPI v1 Daniel Walter
2016-11-20 10:13 ` Boris Brezillon [this message]
2016-09-21 9:51 ` [PATCH v2 20/46] mtd: nandsim: Implement preliminary constructor function Daniel Walter
2016-09-21 9:51 ` [PATCH v2 21/46] mtd: nandsim: Implement preliminary destructor function Daniel Walter
2016-09-21 12:56 ` kbuild test robot
2016-09-21 9:51 ` [PATCH v2 22/46] mtd: nandsim: Cleanup destroy handlers Daniel Walter
2016-09-21 9:51 ` [PATCH v2 23/46] mtd: nandsim: Unify file backend init logic Daniel Walter
2016-09-21 9:51 ` [PATCH v2 24/46] mtd: nandsim: Wire up NANDSIM_MODE_CACHEFILE ioctl mode Daniel Walter
2016-09-21 9:52 ` [PATCH v2 25/46] mtd: nandsim: Print backend name Daniel Walter
2016-09-21 9:52 ` [PATCH v2 26/46] mtd: nandsim: use the existing output macros Daniel Walter
2016-09-21 9:52 ` [PATCH v2 27/46] mtd: nandsim: Add no_oob mode Daniel Walter
2016-09-21 9:52 ` [PATCH v2 28/46] mtd: nandsim: Refine exports Daniel Walter
2016-09-21 9:54 ` [PATCH v2 29/46] um: Add nandsim backend driver Daniel Walter
2016-09-21 9:54 ` [PATCH v2 30/46] mtd: nandsim: Use pr_ style logging Daniel Walter
2016-09-21 9:54 ` [PATCH v2 31/46] mtd: nandsim: Remove NS_RAW_OFFSET_OOB Daniel Walter
2016-09-21 9:54 ` [PATCH v2 32/46] mtd: nandsim: Remove NS_IS_INITIALIZED Daniel Walter
2016-09-21 9:55 ` [PATCH v2 33/46] mtd: nandsim: Relax page size restrictions Daniel Walter
2016-09-21 9:55 ` [PATCH v2 34/46] mtd: nandsim: Support bitflip and read error emulation in file backend Daniel Walter
2016-09-21 9:55 ` [PATCH v2 35/46] mtd: nandsim: Make NANDSIM_MAX_DEVICES part of uapi Daniel Walter
2016-09-21 9:55 ` [PATCH v2 36/46] mtd: nandsim: Cleanup constants Daniel Walter
2016-09-21 9:55 ` [PATCH v2 37/46] mtd: nandsim: Turn parts[] into a integer Daniel Walter
2016-09-21 9:56 ` [PATCH v2 38/46] mtd: nandsim: Expose partition creation logic to user space Daniel Walter
2016-09-21 9:56 ` [PATCH v2 39/46] mtd: nandsim: Rework init error paths Daniel Walter
2016-09-21 9:56 ` [PATCH v2 40/46] mtd: nandsim: Expose BBT, delays, etc.. to userspace Daniel Walter
2016-09-21 9:56 ` [PATCH v2 41/46] mtd: nandsim: Expose support for weakpages/blocks " Daniel Walter
2016-09-21 9:57 ` [PATCH v2 42/46] mtd: nandsim: Don't printk on ENOMEM Daniel Walter
2016-09-21 9:57 ` [PATCH v2 43/46] mtd: nandsim: Wire up NANDSIM_IOC_NEW_INSTANCE Daniel Walter
2016-09-21 9:57 ` [PATCH v2 44/46] mtd: nandsim: Wire up NANDSIM_IOC_DESTROY_INSTANCE Daniel Walter
2016-09-21 9:57 ` [PATCH v2 45/46] mtd: nandsim: Always answer all 8 bytes from NAND_CMD_READID Daniel Walter
2016-09-21 9:57 ` [PATCH v2 46/46] mtd/nandsim: Add ioctl for info Daniel Walter
2016-10-16 16:24 ` [PATCH v2 00/46] Nandsim facelift (part I of II) Boris Brezillon
2016-11-14 16:24 ` Richard Weinberger
2016-11-20 10:26 ` Boris Brezillon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161120111335.125f4a4b@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=dwalter@sigma-star.at \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.