From patchwork Thu Jun 19 12:48:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 4383061 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 50D6D9F1D6 for ; Thu, 19 Jun 2014 12:49:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 96009202EB for ; Thu, 19 Jun 2014 12:49:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4295220340 for ; Thu, 19 Jun 2014 12:49:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752601AbaFSMtJ (ORCPT ); Thu, 19 Jun 2014 08:49:09 -0400 Received: from mail-we0-f177.google.com ([74.125.82.177]:62910 "EHLO mail-we0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750961AbaFSMtH (ORCPT ); Thu, 19 Jun 2014 08:49:07 -0400 Received: by mail-we0-f177.google.com with SMTP id u56so2229870wes.8 for ; Thu, 19 Jun 2014 05:49:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=yx/9KDx1MinVFZOiACwWajJE1efKkPeeMTU9HR4ys/o=; b=Xg5xklN7spw2Unh1mLYNE/midxOm+Q+/YQDaUW7jhr/njgoMLjzI4yx5m9vZ1Ig5sG QsGefmryRyMcx8X5dBYakKMUliE8BgBO3fy+BgNebO/OBa3wzkbVrcsktu8w2wQaJwZ0 B5LFXjCiYNpIQFr+eNSfTt4pXEp/ZjzRSoFpNNLrnoyW1xmksa+KVvQdqkIVxdxp8eBf vgttuwTwKv4Uaccv7szo4RUAoeMwd8VGPuEKSePkQM+ZH7VpC4xSMrxTvFvHU0/zhuwM 8XZb9EbypgrlnLBDs1yMmEjLOHZKE26XnIKw2aLoCF8D6JRruO2xVEZ2288VPW326rYF NsKw== X-Gm-Message-State: ALoCoQkR/ggli+cbkzRVDdiEUhpic/WEY9fCAzmRTGxxDGYKvczFt6K1MKcWUw2vUKCO2aZK8sOF X-Received: by 10.194.204.170 with SMTP id kz10mr4904327wjc.38.1403182145726; Thu, 19 Jun 2014 05:49:05 -0700 (PDT) Received: from [192.168.1.102] (c-98-229-118-119.hsd1.ma.comcast.net. [98.229.118.119]) by mx.google.com with ESMTPSA id ge6sm17654340wic.0.2014.06.19.05.49.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Jun 2014 05:49:04 -0700 (PDT) Message-ID: <53A2DC3A.8050204@dev.mellanox.co.il> Date: Thu, 19 Jun 2014 08:48:58 -0400 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "Hefty, Sean" CC: "linux-rdma (linux-rdma@vger.kernel.org)" Subject: [PATCH librdmacm] rsocket: Add support for RDMA_ROUTE option in rgetsockopt Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;