We have nvme-subsys and nvme devices mapped together. To support multi-controller scheme to this setup, controller identifier(id) has to be managed. Earlier, cntlid(controller id) used to be always 0 because we didn't have any subsystem scheme that controller id matters. This patch introduced 'cntlid' attribute to the nvme controller instance(NvmeCtrl) and make it allocated by the nvme-subsys device mapped to the controller. If nvme-subsys is not given to the controller, then it will always be 0 as it was. Added 'ctrls' array in the nvme-subsys instance to manage attached controllers to the subsystem with a limit(32). This patch didn't take list for the controllers to make it seamless with nvme-ns device. Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Tested-by: Klaus Jensen <k.jensen@samsung.com> Reviewed-by: Klaus Jensen <k.jensen@samsung.com> Reviewed-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
34 lines
748 B
C
34 lines
748 B
C
/*
|
|
* QEMU NVM Express Subsystem: nvme-subsys
|
|
*
|
|
* Copyright (c) 2021 Minwoo Im <minwoo.im.dev@gmail.com>
|
|
*
|
|
* This code is licensed under the GNU GPL v2. Refer COPYING.
|
|
*/
|
|
|
|
#ifndef NVME_SUBSYS_H
|
|
#define NVME_SUBSYS_H
|
|
|
|
#define TYPE_NVME_SUBSYS "nvme-subsys"
|
|
#define NVME_SUBSYS(obj) \
|
|
OBJECT_CHECK(NvmeSubsystem, (obj), TYPE_NVME_SUBSYS)
|
|
|
|
#define NVME_SUBSYS_MAX_CTRLS 32
|
|
|
|
typedef struct NvmeCtrl NvmeCtrl;
|
|
typedef struct NvmeNamespace NvmeNamespace;
|
|
typedef struct NvmeSubsystem {
|
|
DeviceState parent_obj;
|
|
uint8_t subnqn[256];
|
|
|
|
NvmeCtrl *ctrls[NVME_SUBSYS_MAX_CTRLS];
|
|
|
|
struct {
|
|
char *nqn;
|
|
} params;
|
|
} NvmeSubsystem;
|
|
|
|
int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp);
|
|
|
|
#endif /* NVME_SUBSYS_H */
|