Skip to content

Commit

Permalink
nvme-fc: add support for ->map_queues
Browse files Browse the repository at this point in the history
NVMe FC don't have support for map queues, unlike the PCI, RDMA and TCP
transports.  Add a ->map_queues callout for the LLDDs to provide such
functionality.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Saurav Kashyap authored and Christoph Hellwig committed Oct 20, 2021
1 parent f6f09c1 commit 01d8381
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
24 changes: 24 additions & 0 deletions drivers/nvme/host/fc.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/nvme-fc.h>
#include "fc.h"
#include <scsi/scsi_transport_fc.h>
#include <linux/blk-mq-pci.h>

/* *************************** Data Structures/Defines ****************** */

Expand Down Expand Up @@ -2841,6 +2842,28 @@ nvme_fc_complete_rq(struct request *rq)
nvme_fc_ctrl_put(ctrl);
}

static int nvme_fc_map_queues(struct blk_mq_tag_set *set)
{
struct nvme_fc_ctrl *ctrl = set->driver_data;
int i;

for (i = 0; i < set->nr_maps; i++) {
struct blk_mq_queue_map *map = &set->map[i];

if (!map->nr_queues) {
WARN_ON(i == HCTX_TYPE_DEFAULT);
continue;
}

/* Call LLDD map queue functionality if defined */
if (ctrl->lport->ops->map_queues)
ctrl->lport->ops->map_queues(&ctrl->lport->localport,
map);
else
blk_mq_map_queues(map);
}
return 0;
}

static const struct blk_mq_ops nvme_fc_mq_ops = {
.queue_rq = nvme_fc_queue_rq,
Expand All @@ -2849,6 +2872,7 @@ static const struct blk_mq_ops nvme_fc_mq_ops = {
.exit_request = nvme_fc_exit_request,
.init_hctx = nvme_fc_init_hctx,
.timeout = nvme_fc_timeout,
.map_queues = nvme_fc_map_queues,
};

static int
Expand Down
7 changes: 7 additions & 0 deletions include/linux/nvme-fc-driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define _NVME_FC_DRIVER_H 1

#include <linux/scatterlist.h>
#include <linux/blk-mq.h>


/*
Expand Down Expand Up @@ -497,6 +498,8 @@ struct nvme_fc_port_template {
int (*xmt_ls_rsp)(struct nvme_fc_local_port *localport,
struct nvme_fc_remote_port *rport,
struct nvmefc_ls_rsp *ls_rsp);
void (*map_queues)(struct nvme_fc_local_port *localport,
struct blk_mq_queue_map *map);

u32 max_hw_queues;
u16 max_sgl_segments;
Expand Down Expand Up @@ -779,6 +782,10 @@ struct nvmet_fc_target_port {
* LS received.
* Entrypoint is Mandatory.
*
* @map_queues: This functions lets the driver expose the queue mapping
* to the block layer.
* Entrypoint is Optional.
*
* @fcp_op: Called to perform a data transfer or transmit a response.
* The nvmefc_tgt_fcp_req structure is the same LLDD-supplied
* exchange structure specified in the nvmet_fc_rcv_fcp_req() call
Expand Down

0 comments on commit 01d8381

Please sign in to comment.