Skip to content

Commit 99032e9

Browse files
Hannes Reineckekeithbusch
authored andcommitted
nvmet-fc: implement host_traddr()
Implement callback to display the host transport address by adding a callback 'host_traddr' for nvmet_fc_target_template. Signed-off-by: Hannes Reinecke <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: James Smart <[email protected]> Signed-off-by: Daniel Wagner <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent c7ea20c commit 99032e9

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

drivers/nvme/target/fc.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,6 +2934,38 @@ nvmet_fc_discovery_chg(struct nvmet_port *port)
29342934
tgtport->ops->discovery_event(&tgtport->fc_target_port);
29352935
}
29362936

2937+
static ssize_t
2938+
nvmet_fc_host_traddr(struct nvmet_ctrl *ctrl,
2939+
char *traddr, size_t traddr_size)
2940+
{
2941+
struct nvmet_sq *sq = ctrl->sqs[0];
2942+
struct nvmet_fc_tgt_queue *queue =
2943+
container_of(sq, struct nvmet_fc_tgt_queue, nvme_sq);
2944+
struct nvmet_fc_tgtport *tgtport = queue->assoc ? queue->assoc->tgtport : NULL;
2945+
struct nvmet_fc_hostport *hostport = queue->assoc ? queue->assoc->hostport : NULL;
2946+
u64 wwnn, wwpn;
2947+
ssize_t ret = 0;
2948+
2949+
if (!tgtport || !nvmet_fc_tgtport_get(tgtport))
2950+
return -ENODEV;
2951+
if (!hostport || !nvmet_fc_hostport_get(hostport)) {
2952+
ret = -ENODEV;
2953+
goto out_put;
2954+
}
2955+
2956+
if (tgtport->ops->host_traddr) {
2957+
ret = tgtport->ops->host_traddr(hostport->hosthandle, &wwnn, &wwpn);
2958+
if (ret)
2959+
goto out_put_host;
2960+
ret = snprintf(traddr, traddr_size, "nn-0x%llx:pn-0x%llx", wwnn, wwpn);
2961+
}
2962+
out_put_host:
2963+
nvmet_fc_hostport_put(hostport);
2964+
out_put:
2965+
nvmet_fc_tgtport_put(tgtport);
2966+
return ret;
2967+
}
2968+
29372969
static const struct nvmet_fabrics_ops nvmet_fc_tgt_fcp_ops = {
29382970
.owner = THIS_MODULE,
29392971
.type = NVMF_TRTYPE_FC,
@@ -2943,6 +2975,7 @@ static const struct nvmet_fabrics_ops nvmet_fc_tgt_fcp_ops = {
29432975
.queue_response = nvmet_fc_fcp_nvme_cmd_done,
29442976
.delete_ctrl = nvmet_fc_delete_ctrl,
29452977
.discovery_chg = nvmet_fc_discovery_chg,
2978+
.host_traddr = nvmet_fc_host_traddr,
29462979
};
29472980

29482981
static int __init nvmet_fc_init_module(void)

include/linux/nvme-fc-driver.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,9 @@ struct nvmet_fc_target_port {
920920
* further references to hosthandle.
921921
* Entrypoint is Mandatory if the lldd calls nvmet_fc_invalidate_host().
922922
*
923+
* @host_traddr: called by the transport to retrieve the node name and
924+
* port name of the host port address.
925+
*
923926
* @max_hw_queues: indicates the maximum number of hw queues the LLDD
924927
* supports for cpu affinitization.
925928
* Value is Mandatory. Must be at least 1.
@@ -975,6 +978,7 @@ struct nvmet_fc_target_template {
975978
void (*ls_abort)(struct nvmet_fc_target_port *targetport,
976979
void *hosthandle, struct nvmefc_ls_req *lsreq);
977980
void (*host_release)(void *hosthandle);
981+
int (*host_traddr)(void *hosthandle, u64 *wwnn, u64 *wwpn);
978982

979983
u32 max_hw_queues;
980984
u16 max_sgl_segments;

0 commit comments

Comments
 (0)