From patchwork Mon Mar 3 18:44:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 3756251 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 51BBFBF13A for ; Mon, 3 Mar 2014 18:44:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5470B203E6 for ; Mon, 3 Mar 2014 18:44:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D66B6203A9 for ; Mon, 3 Mar 2014 18:44:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753536AbaCCSoS (ORCPT ); Mon, 3 Mar 2014 13:44:18 -0500 Received: from mail-we0-f171.google.com ([74.125.82.171]:35811 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753402AbaCCSoR (ORCPT ); Mon, 3 Mar 2014 13:44:17 -0500 Received: by mail-we0-f171.google.com with SMTP id t61so1219683wes.30 for ; Mon, 03 Mar 2014 10:44:16 -0800 (PST) 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=rBYxmQAqNTciJhQ8iGN+n1DLQVKDVDFJ50LPJZ8oo9k=; b=PxLH3Lmn3V3qiE1RJRcSD9Rs14Dl/nYwiDd1OAqmz2ia9Kd7li5pps7ZdGFRibOn0g yp0c1aHV9/4g8uSzEF4ic1HGIwfyTqEQqpdiJwosBNzMzF0Dclkq4e0VGdZiTjSt5BBm Bv5lROrsA6G9G5WbKiSa39zoT/gXpsdp6cU86Z7BsS8n3V5ICR4sfLgsovkHHzRN953x CVpQRr8uauVO0XSa0WMev+UOLW+o2JkrbrHTnvvv9D5K7f6JVGjhM3zfioO4XbCSx8mJ 2Mh6F9y3vYXiE7MnbQeFy5LlfSVl3EY95N0i/yrCFSS4aiGU43e/YV/wBuKfmje6/oAL jkYg== X-Gm-Message-State: ALoCoQlSVTtLzxP8ZEBRp8b5Qr1LU+Oy9Q5oCFxeCKvQQf2eMVQ9lWXvpGVwW2F9ebphhXoS7vEu X-Received: by 10.195.12.5 with SMTP id em5mr8561056wjd.77.1393872256082; Mon, 03 Mar 2014 10:44:16 -0800 (PST) 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 dd3sm39326602wjb.9.2014.03.03.10.44.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Mar 2014 10:44:15 -0800 (PST) Message-ID: <5314CD7D.3060304@dev.mellanox.co.il> Date: Mon, 03 Mar 2014 13:44:13 -0500 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 1/2] examples/riostream.c: Add AF_IB support 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, 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 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/examples/riostream.c b/examples/riostream.c index a1d3671..4c0d21f 100644 --- a/examples/riostream.c +++ b/examples/riostream.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2011-2012 Intel Corporation. All rights reserved. + * Copyright (c) 2014 Mellanox Technologies LTD. All rights reserved. * * This software is available to you under the OpenIB.org BSD license * below: @@ -75,6 +76,7 @@ static struct test_size_param test_size[] = { static int rs, lrs; static int use_async; +static int use_rgai; static int verify; static int flags = MSG_DONTWAIT; static int poll_timeout = 0; @@ -92,6 +94,8 @@ static char *src_addr; static struct timeval start, end; static void *buf; static volatile uint8_t *poll_byte; +static struct rdma_addrinfo rai_hints; +static struct addrinfo ai_hints; static void show_perf(void) { @@ -355,18 +359,24 @@ static void set_options(int rs) static int server_listen(void) { - struct addrinfo hints, *res; + struct rdma_addrinfo *rai = NULL; + struct addrinfo *ai; int val, ret; - memset(&hints, 0, sizeof hints); - hints.ai_flags = AI_PASSIVE; - ret = getaddrinfo(src_addr, port, &hints, &res); + if (use_rgai) { + rai_hints.ai_flags |= RAI_PASSIVE; + ret = rdma_getaddrinfo(src_addr, port, &rai_hints, &rai); + } else { + ai_hints.ai_flags |= AI_PASSIVE; + ret = getaddrinfo(src_addr, port, &ai_hints, &ai); + } if (ret) { perror("getaddrinfo"); return ret; } - lrs = rsocket(res->ai_family, res->ai_socktype, res->ai_protocol); + lrs = rai ? rsocket(rai->ai_family, SOCK_STREAM, 0) : + rsocket(ai->ai_family, SOCK_STREAM, 0); if (lrs < 0) { perror("rsocket"); ret = lrs; @@ -380,7 +390,8 @@ static int server_listen(void) goto close; } - ret = rbind(lrs, res->ai_addr, res->ai_addrlen); + ret = rai ? rbind(lrs, rai->ai_src_addr, rai->ai_src_len) : + rbind(lrs, ai->ai_addr, ai->ai_addrlen); if (ret) { perror("rbind"); goto close; @@ -394,7 +405,10 @@ close: if (ret) rclose(lrs); free: - freeaddrinfo(res); + if (rai) + rdma_freeaddrinfo(rai); + else + freeaddrinfo(ai); return ret; } @@ -429,18 +443,21 @@ static int server_connect(void) static int client_connect(void) { - struct addrinfo *res; + struct rdma_addrinfo *rai = NULL; + struct addrinfo *ai; struct pollfd fds; int ret, err; socklen_t len; - ret = getaddrinfo(dst_addr, port, NULL, &res); + ret = use_rgai ? rdma_getaddrinfo(dst_addr, port, &rai_hints, &rai) : + getaddrinfo(dst_addr, port, &ai_hints, &ai); if (ret) { perror("getaddrinfo"); return ret; } - rs = rsocket(res->ai_family, res->ai_socktype, res->ai_protocol); + rs = rai ? rsocket(rai->ai_family, SOCK_STREAM, 0) : + rsocket(ai->ai_family, SOCK_STREAM, 0); if (rs < 0) { perror("rsocket"); ret = rs; @@ -450,7 +467,8 @@ static int client_connect(void) set_options(rs); /* TODO: bind client to src_addr */ - ret = rconnect(rs, res->ai_addr, res->ai_addrlen); + ret = rai ? rconnect(rs, rai->ai_dst_addr, rai->ai_dst_len) : + rconnect(rs, ai->ai_addr, ai->ai_addrlen); if (ret && (errno != EINPROGRESS)) { perror("rconnect"); goto close; @@ -478,7 +496,10 @@ close: if (ret) rclose(rs); free: - freeaddrinfo(res); + if (rai) + rdma_freeaddrinfo(rai); + else + freeaddrinfo(ai); return ret; } @@ -579,7 +600,9 @@ int main(int argc, char **argv) { int op, ret; - while ((op = getopt(argc, argv, "s:b:B:I:C:S:p:T:")) != -1) { + ai_hints.ai_socktype = SOCK_STREAM; + rai_hints.ai_port_space = RDMA_PS_TCP; + while ((op = getopt(argc, argv, "s:b:f:B:I:C:S:p:T:")) != -1) { switch (op) { case 's': dst_addr = optarg; @@ -587,6 +610,17 @@ int main(int argc, char **argv) case 'b': src_addr = optarg; break; + case 'f': + if (!strncasecmp("ip", optarg, 2)) { + ai_hints.ai_flags = AI_NUMERICHOST; + } else if (!strncasecmp("gid", optarg, 3)) { + rai_hints.ai_flags = RAI_NUMERICHOST | RAI_FAMILY; + rai_hints.ai_family = AF_IB; + use_rgai = 1; + } else { + fprintf(stderr, "Warning: unknown address format\n"); + } + break; case 'B': buffer_size = atoi(optarg); break; @@ -617,6 +651,8 @@ int main(int argc, char **argv) printf("usage: %s\n", argv[0]); printf("\t[-s server_address]\n"); printf("\t[-b bind_address]\n"); + printf("\t[-f address_format]\n"); + printf("\t name, ip, ipv6, or gid\n"); printf("\t[-B buffer_size]\n"); printf("\t[-I iterations]\n"); printf("\t[-C transfer_count]\n");