* [PATCH librdmacm] rsocket: Add support for RDMA_ROUTE option in rgetsockopt
@ 2014-06-19 12:48 Hal Rosenstock
[not found] ` <53A2DC3A.8050204-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Hal Rosenstock @ 2014-06-19 12:48 UTC (permalink / raw)
To: Hefty, Sean
Cc: linux-rdma (linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org)
Create as many ibv_path_data structs from the RDMA route
ibv_sa_path_rec struct for the rsocket based on how
many fit into the supplied buffer.
Signed-off-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
diff --git a/src/rsocket.c b/src/rsocket.c
index 0e5635f..d1d0ebf 100644
--- a/src/rsocket.c
+++ b/src/rsocket.c
@@ -3500,11 +3500,38 @@ int rsetsockopt(int socket, int level, int optname,
return ret;
}
+static void rs_convert_sa_path(struct ibv_sa_path_rec *sa_path,
+ struct ibv_path_data *path_data)
+{
+ uint32_t fl_hop;
+
+ memset(path_data, 0, sizeof(*path_data));
+ path_data->path.dgid = sa_path->dgid;
+ path_data->path.sgid = sa_path->sgid;
+ path_data->path.dlid = sa_path->dlid;
+ path_data->path.slid = sa_path->slid;
+ fl_hop = ntohl(sa_path->flow_label) << 8;
+ path_data->path.flowlabel_hoplimit = htonl(fl_hop) | sa_path->hop_limit;
+ path_data->path.tclass = sa_path->traffic_class;
+ path_data->path.reversible_numpath = sa_path->reversible << 7 | 1;
+ path_data->path.pkey = sa_path->pkey;
+ path_data->path.qosclass_sl = sa_path->sl;
+ path_data->path.mtu = sa_path->mtu | 2 << 6; /* exactly */
+ path_data->path.rate = sa_path->rate | 2 << 6;
+ path_data->path.packetlifetime = sa_path->packet_life_time | 2 << 6;
+ path_data->flags= sa_path->preference;
+}
+
int rgetsockopt(int socket, int level, int optname,
void *optval, socklen_t *optlen)
{
struct rsocket *rs;
+ void *opt;
+ struct ibv_sa_path_rec *path_rec;
+ struct ibv_path_data path_data;
+ socklen_t len;
int ret = 0;
+ int num_paths;
rs = idm_lookup(&idm, socket);
if (!rs)
@@ -3597,6 +3624,27 @@ int rgetsockopt(int socket, int level, int optname,
*((int *) optval) = rs->target_iomap_size;
*optlen = sizeof(int);
break;
+ case RDMA_ROUTE:
+ if (*optlen < sizeof(path_data)) {
+ ret = EINVAL;
+ } else {
+ len = 0;
+ opt = optval;
+ path_rec = rs->cm_id->route.path_rec;
+ num_paths = 0;
+ if (len + sizeof(path_data) <= *optlen &&
+ num_paths < rs->cm_id->route.num_paths) {
+ rs_convert_sa_path(path_rec, &path_data);
+ memcpy(opt, &path_data, sizeof(path_data));
+ len += sizeof(path_data);
+ opt += sizeof(path_data);
+ path_rec++;
+ num_paths++;
+ }
+ *optlen = len;
+ ret = 0;
+ }
+ break;
default:
ret = ENOTSUP;
break;
--
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH librdmacm] rsocket: Add support for RDMA_ROUTE option in rgetsockopt
[not found] ` <53A2DC3A.8050204-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
@ 2014-06-19 15:29 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A8237399312AB2-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Hefty, Sean @ 2014-06-19 15:29 UTC (permalink / raw)
To: Hal Rosenstock
Cc: linux-rdma (linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org)
> + case RDMA_ROUTE:
> + if (*optlen < sizeof(path_data)) {
> + ret = EINVAL;
> + } else {
> + len = 0;
> + opt = optval;
> + path_rec = rs->cm_id->route.path_rec;
> + num_paths = 0;
> + if (len + sizeof(path_data) <= *optlen &&
len is 0 here and we've already checked *optlen
> + num_paths < rs->cm_id->route.num_paths) {
and num_paths is 0
> + rs_convert_sa_path(path_rec, &path_data);
> + memcpy(opt, &path_data, sizeof(path_data));
> + len += sizeof(path_data);
> + opt += sizeof(path_data);
> + path_rec++;
> + num_paths++;
were you actually wanting a loop here?
> + }
This also needs to handle the case where rgetsockopt is called immediately after rsetsockopt. Something like:
if (rs->optval) {
memcpy(rs->optval, optval, rs->optlen);
*optlen = rs->optlen;
}
assuming that rs->optlen is verified
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH librdmacm] rsocket: Add support for RDMA_ROUTE option in rgetsockopt
[not found] ` <1828884A29C6694DAF28B7E6B8A8237399312AB2-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2014-06-19 15:52 ` Hal Rosenstock
0 siblings, 0 replies; 3+ messages in thread
From: Hal Rosenstock @ 2014-06-19 15:52 UTC (permalink / raw)
To: Hefty, Sean
Cc: linux-rdma (linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org)
On 6/19/2014 11:29 AM, Hefty, Sean wrote:
>> + case RDMA_ROUTE:
>> + if (*optlen < sizeof(path_data)) {
>> + ret = EINVAL;
>> + } else {
>> + len = 0;
>> + opt = optval;
>> + path_rec = rs->cm_id->route.path_rec;
>> + num_paths = 0;
>> + if (len + sizeof(path_data) <= *optlen &&
>
> len is 0 here and we've already checked *optlen
>
>> + num_paths < rs->cm_id->route.num_paths) {
>
> and num_paths is 0
>
>> + rs_convert_sa_path(path_rec, &path_data);
>> + memcpy(opt, &path_data, sizeof(path_data));
>> + len += sizeof(path_data);
>> + opt += sizeof(path_data);
>> + path_rec++;
>> + num_paths++;
>
> were you actually wanting a loop here?
Yes; if should have been while
>
>> + }
>
> This also needs to handle the case where rgetsockopt is called immediately after rsetsockopt. Something like:
>
> if (rs->optval) {
> memcpy(rs->optval, optval, rs->optlen);
> *optlen = rs->optlen;
> }
>
> assuming that rs->optlen is verified
Sure.
v2 patch shortly...
-- Hal
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-06-19 15:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-19 12:48 [PATCH librdmacm] rsocket: Add support for RDMA_ROUTE option in rgetsockopt Hal Rosenstock
[not found] ` <53A2DC3A.8050204-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-06-19 15:29 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A8237399312AB2-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-06-19 15:52 ` Hal Rosenstock
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.