nvmet: Add get_mdts op for controllers
authorMax Gurtovoy <maxg@mellanox.com>
Sun, 8 Mar 2020 10:55:03 +0000 (12:55 +0200)
committerKeith Busch <kbusch@kernel.org>
Wed, 25 Mar 2020 19:51:54 +0000 (04:51 +0900)
Some transports, such as RDMA, would like to set the Maximum Data
Transfer Size (MDTS) according to device/port/ctrl characteristics.
This will enable the transport to set the optimal MDTS according to
controller needs and device capabilities. Add a new nvmet transport
op that is called during ctrl identification. This will not effect
transports that don't implement this option. The return value of the new
op is according to the NVMe spec definition for MDTS.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Signed-off-by: Israel Rukshin <israelr@mellanox.com>
drivers/nvme/target/admin-cmd.c
drivers/nvme/target/nvmet.h

index c0aa9c34c69994e9e6d34c90fcefcfb7b19317e9..b9ec489dc7486c3ab2424c679cd27bd24b019de3 100644 (file)
@@ -369,8 +369,12 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
        /* we support multiple ports, multiples hosts and ANA: */
        id->cmic = (1 << 0) | (1 << 1) | (1 << 3);
 
-       /* no limit on data transfer sizes for now */
-       id->mdts = 0;
+       /* Limit MDTS according to transport capability */
+       if (ctrl->ops->get_mdts)
+               id->mdts = ctrl->ops->get_mdts(ctrl);
+       else
+               id->mdts = 0;
+
        id->cntlid = cpu_to_le16(ctrl->cntlid);
        id->ver = cpu_to_le32(ctrl->subsys->ver);
 
index 42ba2ddd9e963630dfcd223502f090945af5d3d8..421dff3ea1433e35f4636a37732a5ffbc3a5c884 100644 (file)
@@ -289,6 +289,7 @@ struct nvmet_fabrics_ops {
                        struct nvmet_port *port, char *traddr);
        u16 (*install_queue)(struct nvmet_sq *nvme_sq);
        void (*discovery_chg)(struct nvmet_port *port);
+       u8 (*get_mdts)(const struct nvmet_ctrl *ctrl);
 };
 
 #define NVMET_MAX_INLINE_BIOVEC        8