From: Bart Van Assche <bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
To: Jason Gunthorpe <jgg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Bart Van Assche <bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
Subject: [PATCH 03/28] IB/srp: Refactor srp_send_req()
Date: Wed, 3 Jan 2018 13:39:13 -0800 [thread overview]
Message-ID: <20180103213938.11664-4-bart.vanassche@wdc.com> (raw)
In-Reply-To: <20180103213938.11664-1-bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
This patch does not change any functionality but makes the next
patch in this series easier to read.
Signed-off-by: Bart Van Assche <bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
---
drivers/infiniband/ulp/srp/ib_srp.c | 65 +++++++++++++++++++------------------
1 file changed, 34 insertions(+), 31 deletions(-)
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index fec6e800adf4..9472f5989d27 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -738,35 +738,21 @@ static int srp_send_req(struct srp_rdma_ch *ch, bool multich)
struct ib_cm_req_param param;
struct srp_login_req priv;
} *req = NULL;
+ char *ipi, *tpi;
int status;
- u8 subnet_timeout;
-
- subnet_timeout = srp_get_subnet_timeout(target->srp_host);
req = kzalloc(sizeof *req, GFP_KERNEL);
if (!req)
return -ENOMEM;
- req->param.primary_path = &ch->path;
- req->param.alternate_path = NULL;
- req->param.service_id = target->service_id;
- req->param.qp_num = ch->qp->qp_num;
- req->param.qp_type = ch->qp->qp_type;
- req->param.private_data = &req->priv;
- req->param.private_data_len = sizeof req->priv;
req->param.flow_control = 1;
-
- get_random_bytes(&req->param.starting_psn, 4);
- req->param.starting_psn &= 0xffffff;
+ req->param.retry_count = target->tl_retry_count;
/*
* Pick some arbitrary defaults here; we could make these
* module parameters if anyone cared about setting them.
*/
req->param.responder_resources = 4;
- req->param.remote_cm_response_timeout = subnet_timeout + 2;
- req->param.local_cm_response_timeout = subnet_timeout + 2;
- req->param.retry_count = target->tl_retry_count;
req->param.rnr_retry_count = 7;
req->param.max_cm_retries = 15;
@@ -777,6 +763,28 @@ static int srp_send_req(struct srp_rdma_ch *ch, bool multich)
SRP_BUF_FORMAT_INDIRECT);
req->priv.req_flags = (multich ? SRP_MULTICHAN_MULTI :
SRP_MULTICHAN_SINGLE);
+
+ {
+ u8 subnet_timeout;
+
+ subnet_timeout = srp_get_subnet_timeout(target->srp_host);
+
+ req->param.primary_path = &ch->path;
+ req->param.alternate_path = NULL;
+ req->param.service_id = target->service_id;
+ get_random_bytes(&req->param.starting_psn, 4);
+ req->param.starting_psn &= 0xffffff;
+ req->param.qp_num = ch->qp->qp_num;
+ req->param.qp_type = ch->qp->qp_type;
+ req->param.local_cm_response_timeout = subnet_timeout + 2;
+ req->param.remote_cm_response_timeout = subnet_timeout + 2;
+ req->param.private_data = &req->priv;
+ req->param.private_data_len = sizeof(req->priv);
+
+ ipi = req->priv.initiator_port_id;
+ tpi = req->priv.target_port_id;
+ }
+
/*
* In the published SRP specification (draft rev. 16a), the
* port identifier format is 8 bytes of ID extension followed
@@ -787,19 +795,15 @@ static int srp_send_req(struct srp_rdma_ch *ch, bool multich)
* recognized by the I/O Class they report.
*/
if (target->io_class == SRP_REV10_IB_IO_CLASS) {
- memcpy(req->priv.initiator_port_id,
- &target->sgid.global.interface_id, 8);
- memcpy(req->priv.initiator_port_id + 8,
- &target->initiator_ext, 8);
- memcpy(req->priv.target_port_id, &target->ioc_guid, 8);
- memcpy(req->priv.target_port_id + 8, &target->id_ext, 8);
+ memcpy(ipi, &target->sgid.global.interface_id, 8);
+ memcpy(ipi + 8, &target->initiator_ext, 8);
+ memcpy(tpi, &target->ioc_guid, 8);
+ memcpy(tpi + 8, &target->id_ext, 8);
} else {
- memcpy(req->priv.initiator_port_id,
- &target->initiator_ext, 8);
- memcpy(req->priv.initiator_port_id + 8,
- &target->sgid.global.interface_id, 8);
- memcpy(req->priv.target_port_id, &target->id_ext, 8);
- memcpy(req->priv.target_port_id + 8, &target->ioc_guid, 8);
+ memcpy(ipi, &target->initiator_ext, 8);
+ memcpy(ipi + 8, &target->sgid.global.interface_id, 8);
+ memcpy(tpi, &target->id_ext, 8);
+ memcpy(tpi + 8, &target->ioc_guid, 8);
}
/*
@@ -812,9 +816,8 @@ static int srp_send_req(struct srp_rdma_ch *ch, bool multich)
PFX "Topspin/Cisco initiator port ID workaround "
"activated for target GUID %016llx\n",
be64_to_cpu(target->ioc_guid));
- memset(req->priv.initiator_port_id, 0, 8);
- memcpy(req->priv.initiator_port_id + 8,
- &target->srp_host->srp_dev->dev->node_guid, 8);
+ memset(ipi, 0, 8);
+ memcpy(ipi + 8, &target->srp_host->srp_dev->dev->node_guid, 8);
}
status = ib_send_cm_req(ch->cm_id, &req->param);
--
2.15.1
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-01-03 21:39 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-03 21:39 [PATCH 00/28] IB/srp and IB/srpt patches Bart Van Assche
2018-01-03 21:39 ` [PATCH 05/28] IB/srpt: Disable RDMA access by the initiator Bart Van Assche
[not found] ` <20180103213938.11664-6-bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
2018-01-04 3:12 ` Jason Gunthorpe
2018-01-03 21:39 ` [PATCH 06/28] IB/srpt: Fix ACL lookup during login Bart Van Assche
[not found] ` <20180103213938.11664-7-bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
2018-01-04 3:12 ` Jason Gunthorpe
[not found] ` <20180103213938.11664-1-bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
2018-01-03 21:39 ` [PATCH 01/28] IB/srp: Use kstrtoull() instead of simple_strtoull() Bart Van Assche
2018-01-03 21:39 ` [PATCH 02/28] IB/srp: Make the path record query error message more informative Bart Van Assche
2018-01-03 21:39 ` Bart Van Assche [this message]
2018-01-03 21:39 ` [PATCH 04/28] IB/srp: Add RDMA/CM support Bart Van Assche
2018-01-03 21:39 ` [PATCH 07/28] IB/srpt: Remove an unused structure member Bart Van Assche
2018-01-03 21:39 ` [PATCH 08/28] IB/srpt: Fix kernel-doc warnings in ib_srpt.c Bart Van Assche
2018-01-03 21:39 ` [PATCH 09/28] IB/srpt: Make it safe to use RCU for srpt_device.rch_list Bart Van Assche
2018-01-03 21:39 ` [PATCH 10/28] IB/srpt: Rework srpt_disconnect_ch_sync() Bart Van Assche
2018-01-03 21:39 ` [PATCH 11/28] IB/srpt: Document all structure members in ib_srpt.h Bart Van Assche
2018-01-03 21:39 ` [PATCH 12/28] IB/srpt: Rename a local variable, a member variable and a constant Bart Van Assche
2018-01-03 21:39 ` [PATCH 13/28] IB/srpt: Reduce the severity level of a log message Bart Van Assche
2018-01-03 21:39 ` [PATCH 14/28] IB/srpt: Verify port numbers in srpt_event_handler() Bart Van Assche
2018-01-03 21:39 ` [PATCH 15/28] IB/srpt: Use the IPv6 format for GIDs in log messages Bart Van Assche
2018-01-03 21:39 ` [PATCH 16/28] IB/srpt: Reduce frequency of receive failure messages Bart Van Assche
2018-01-03 21:39 ` [PATCH 17/28] IB/srpt: Introduce srpt_format_guid() Bart Van Assche
2018-01-03 21:39 ` [PATCH 18/28] IB/srpt: Inline srpt_get_cmd_state() Bart Van Assche
2018-01-03 21:39 ` [PATCH 19/28] IB/srpt: Micro-optimize I/O context state manipulation Bart Van Assche
2018-01-03 21:39 ` [PATCH 20/28] IB/srpt: Add P_Key support Bart Van Assche
2018-01-03 21:39 ` [PATCH 21/28] IB/srpt: One target per port Bart Van Assche
2018-01-03 21:39 ` [PATCH 22/28] IB/srpt: Rework multi-channel support Bart Van Assche
2018-01-03 21:39 ` [PATCH 23/28] IB/srpt: Fix login-related race conditions Bart Van Assche
2018-01-03 21:39 ` [PATCH 24/28] IB/srpt: Prepare RDMA/CM support Bart Van Assche
2018-01-03 21:39 ` [PATCH 25/28] IB/srpt: Move the code for parsing struct ib_cm_req_event_param Bart Van Assche
2018-01-03 21:39 ` [PATCH 26/28] IB/srpt: Fix a race condition related to wait list processing Bart Van Assche
2018-01-03 21:39 ` [PATCH 27/28] IB/srpt: Avoid that wait list processing triggers command reordering Bart Van Assche
2018-01-03 21:39 ` [PATCH 28/28] IB/srpt: Add RDMA/CM support Bart Van Assche
2018-01-03 21:51 ` [PATCH 00/28] IB/srp and IB/srpt patches Jason Gunthorpe
[not found] ` <20180103215130.GN11348-uk2M96/98Pc@public.gmane.org>
2018-01-03 22:06 ` Bart Van Assche
[not found] ` <1515017215.2582.50.camel-Sjgp3cTcYWE@public.gmane.org>
2018-01-04 3:15 ` Jason Gunthorpe
[not found] ` <20180104031505.GP11348-uk2M96/98Pc@public.gmane.org>
2018-01-04 4:29 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180103213938.11664-4-bart.vanassche@wdc.com \
--to=bart.vanassche-sjgp3ctcywe@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=jgg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox