]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/nvme/host/nvme.h
nvme: introduce a nvme_ns_ids structure
[mirror_ubuntu-bionic-kernel.git] / drivers / nvme / host / nvme.h
index d3f3c4447515703a26683580071bd6fd160cd102..2f1af915f93a54cdcdf1e2101dedcc9c860bbe59 100644 (file)
 #define _NVME_H
 
 #include <linux/nvme.h>
+#include <linux/cdev.h>
 #include <linux/pci.h>
 #include <linux/kref.h>
 #include <linux/blk-mq.h>
 #include <linux/lightnvm.h>
 #include <linux/sed-opal.h>
 
-extern unsigned char nvme_io_timeout;
+extern unsigned int nvme_io_timeout;
 #define NVME_IO_TIMEOUT        (nvme_io_timeout * HZ)
 
-extern unsigned char admin_timeout;
+extern unsigned int admin_timeout;
 #define ADMIN_TIMEOUT  (admin_timeout * HZ)
 
 #define NVME_DEFAULT_KATO      5
@@ -127,24 +128,24 @@ struct nvme_ctrl {
        struct request_queue *admin_q;
        struct request_queue *connect_q;
        struct device *dev;
-       struct kref kref;
        int instance;
        struct blk_mq_tag_set *tagset;
        struct blk_mq_tag_set *admin_tagset;
        struct list_head namespaces;
        struct mutex namespaces_mutex;
+       struct device ctrl_device;
        struct device *device;  /* char device */
-       struct list_head node;
+       struct cdev cdev;
        struct ida ns_ida;
        struct work_struct reset_work;
+       struct work_struct delete_work;
+
+       struct nvme_subsystem *subsys;
+       struct list_head subsys_entry;
 
        struct opal_dev *opal_dev;
 
        char name[12];
-       char serial[20];
-       char model[40];
-       char firmware_rev[8];
-       char subnqn[NVMF_NQN_SIZE];
        u16 cntlid;
 
        u32 ctrl_config;
@@ -155,23 +156,23 @@ struct nvme_ctrl {
        u32 page_size;
        u32 max_hw_sectors;
        u16 oncs;
-       u16 vid;
        u16 oacs;
        u16 nssa;
        u16 nr_streams;
        atomic_t abort_limit;
-       u8 event_limit;
        u8 vwc;
        u32 vs;
        u32 sgls;
        u16 kas;
        u8 npss;
        u8 apsta;
+       u32 aen_result;
        unsigned int shutdown_timeout;
        unsigned int kato;
        bool subsystem;
        unsigned long quirks;
        struct nvme_id_power_state psd[32];
+       struct nvme_effects_log *effects;
        struct work_struct scan_work;
        struct work_struct async_event_work;
        struct delayed_work ka_work;
@@ -197,6 +198,34 @@ struct nvme_ctrl {
        struct nvmf_ctrl_options *opts;
 };
 
+struct nvme_subsystem {
+       int                     instance;
+       struct device           dev;
+       /*
+        * Because we unregister the device on the last put we need
+        * a separate refcount.
+        */
+       struct kref             ref;
+       struct list_head        entry;
+       struct mutex            lock;
+       struct list_head        ctrls;
+       char                    subnqn[NVMF_NQN_SIZE];
+       char                    serial[20];
+       char                    model[40];
+       char                    firmware_rev[8];
+       u8                      cmic;
+       u16                     vendor_id;
+};
+
+/*
+ * Container structure for uniqueue namespace identifiers.
+ */
+struct nvme_ns_ids {
+       u8      eui64[8];
+       u8      nguid[16];
+       uuid_t  uuid;
+};
+
 struct nvme_ns {
        struct list_head list;
 
@@ -207,11 +236,8 @@ struct nvme_ns {
        struct kref kref;
        int instance;
 
-       u8 eui[8];
-       u8 nguid[16];
-       uuid_t uuid;
-
        unsigned ns_id;
+       struct nvme_ns_ids ids;
        int lba_shift;
        u16 ms;
        u16 sgs;
@@ -234,9 +260,10 @@ struct nvme_ctrl_ops {
        int (*reg_write32)(struct nvme_ctrl *ctrl, u32 off, u32 val);
        int (*reg_read64)(struct nvme_ctrl *ctrl, u32 off, u64 *val);
        void (*free_ctrl)(struct nvme_ctrl *ctrl);
-       void (*submit_async_event)(struct nvme_ctrl *ctrl, int aer_idx);
-       int (*delete_ctrl)(struct nvme_ctrl *ctrl);
+       void (*submit_async_event)(struct nvme_ctrl *ctrl);
+       void (*delete_ctrl)(struct nvme_ctrl *ctrl);
        int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size);
+       int (*reinit_request)(void *data, struct request *rq);
 };
 
 static inline bool nvme_ctrl_ready(struct nvme_ctrl *ctrl)
@@ -278,6 +305,16 @@ static inline void nvme_end_request(struct request *req, __le16 status,
        blk_mq_complete_request(req);
 }
 
+static inline void nvme_get_ctrl(struct nvme_ctrl *ctrl)
+{
+       get_device(ctrl->device);
+}
+
+static inline void nvme_put_ctrl(struct nvme_ctrl *ctrl)
+{
+       put_device(ctrl->device);
+}
+
 void nvme_complete_rq(struct request *req);
 void nvme_cancel_request(struct request *req, void *data, bool reserved);
 bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
@@ -299,10 +336,8 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl);
 int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,
                bool send);
 
-#define NVME_NR_AERS   1
 void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
                union nvme_result *res);
-void nvme_queue_async_events(struct nvme_ctrl *ctrl);
 
 void nvme_stop_queues(struct nvme_ctrl *ctrl);
 void nvme_start_queues(struct nvme_ctrl *ctrl);
@@ -311,21 +346,25 @@ void nvme_unfreeze(struct nvme_ctrl *ctrl);
 void nvme_wait_freeze(struct nvme_ctrl *ctrl);
 void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
 void nvme_start_freeze(struct nvme_ctrl *ctrl);
+int nvme_reinit_tagset(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set);
 
 #define NVME_QID_ANY -1
 struct request *nvme_alloc_request(struct request_queue *q,
-               struct nvme_command *cmd, unsigned int flags, int qid);
+               struct nvme_command *cmd, blk_mq_req_flags_t flags, int qid);
 blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
                struct nvme_command *cmd);
 int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
                void *buf, unsigned bufflen);
 int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
                union nvme_result *result, void *buffer, unsigned bufflen,
-               unsigned timeout, int qid, int at_head, int flags);
+               unsigned timeout, int qid, int at_head,
+               blk_mq_req_flags_t flags);
 int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count);
 void nvme_start_keep_alive(struct nvme_ctrl *ctrl);
 void nvme_stop_keep_alive(struct nvme_ctrl *ctrl);
 int nvme_reset_ctrl(struct nvme_ctrl *ctrl);
+int nvme_delete_ctrl(struct nvme_ctrl *ctrl);
+int nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl);
 
 #ifdef CONFIG_NVM
 int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node);