From patchwork Fri Nov 22 21:10:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Coulter, Susan K" X-Patchwork-Id: 3224301 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 73D15C045B for ; Fri, 22 Nov 2013 21:35:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 698E620795 for ; Fri, 22 Nov 2013 21:35:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 345E320791 for ; Fri, 22 Nov 2013 21:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755278Ab3KVVfP (ORCPT ); Fri, 22 Nov 2013 16:35:15 -0500 Received: from proofpoint4.lanl.gov ([204.121.3.52]:56755 "EHLO proofpoint4.lanl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755248Ab3KVVfN convert rfc822-to-8bit (ORCPT ); Fri, 22 Nov 2013 16:35:13 -0500 X-Greylist: delayed 1483 seconds by postgrey-1.27 at vger.kernel.org; Fri, 22 Nov 2013 16:35:13 EST Received: from mailrelay2.lanl.gov (mailrelay2.lanl.gov [128.165.4.103]) by mailgate4.lanl.gov (8.14.5/8.14.5) with ESMTP id rAMLAQel029579; Fri, 22 Nov 2013 14:10:26 -0700 Received: from localhost (localhost.localdomain [127.0.0.1]) by mailrelay2.lanl.gov (Postfix) with ESMTP id 31F76B817D8; Fri, 22 Nov 2013 14:10:26 -0700 (MST) X-NIE-2-Virus-Scanner: amavisd-new at mailrelay2.lanl.gov Received: from ECS-EXG-P-CH01.win.lanl.gov (ecs-exg-p-ch01.win.lanl.gov [128.165.106.11]) by mailrelay2.lanl.gov (Postfix) with ESMTP id 18E44B817C5; Fri, 22 Nov 2013 14:10:26 -0700 (MST) Received: from ECS-EXG-P-MB01.win.lanl.gov ([169.254.1.23]) by ECS-EXG-P-CH01.win.lanl.gov ([128.165.106.11]) with mapi id 14.03.0158.001; Fri, 22 Nov 2013 14:10:26 -0700 From: "Coulter, Susan K" To: "linux-rdma (linux-rdma@vger.kernel.org)" CC: "gilr@mellanox.com" Subject: PKey patch Thread-Topic: PKey patch Thread-Index: AQHO58dCCDIx6iAbTkeVXE7ufQSdeQ== Date: Fri, 22 Nov 2013 21:10:24 +0000 Message-ID: <79F41063-EC59-4515-B13B-C2104C8C490A@lanl.gov> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [128.165.184.250] Content-ID: <684CFC859697C84BAAFA9BDC1E65E845@win.lanl.gov> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.10.8794, 1.0.14, 0.0.0000 definitions=2013-11-22_07:2013-11-22, 2013-11-22, 1970-01-01 signatures=0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 … again … reworked as requested to use only the long option. From e3471983cf96c17e4353ff98a339f3ca2b767b13 Mon Sep 17 00:00:00 2001 From: Susan K. Coulter Date: Fri, 22 Nov 2013 13:38:11 -0700 Subject: [PATCH] Allow specification of PKey index Signed-off-by: Susan K. Coulter --- src/perftest_communication.c | 9 +++------ src/perftest_parameters.c | 41 ++++++++++++++++++++++++++++++++++++++++- src/perftest_parameters.h | 1 + src/perftest_resources.c | 2 +- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/perftest_communication.c b/src/perftest_communication.c index 44c0f32..1f0abcc 100755 --- a/src/perftest_communication.c +++ b/src/perftest_communication.c @@ -207,8 +207,7 @@ static int ethernet_read_keys(struct pingpong_dest *rem_dest, char msg[KEY_MSG_SIZE]; if (read(comm->rdma_params->sockfd, msg, sizeof msg) != sizeof msg) { - perror("pp_read_keys"); - fprintf(stderr, "Couldn't read remote address\n"); + fprintf(stderr, "ethernet_read_keys: Couldn't read remote address\n"); return 1; } @@ -229,8 +228,7 @@ static int ethernet_read_keys(struct pingpong_dest *rem_dest, int i; if (read(comm->rdma_params->sockfd, msg, sizeof msg) != sizeof msg) { - perror("pp_read_keys"); - fprintf(stderr, "Couldn't read remote address\n"); + fprintf(stderr, "ethernet_read_keys: Couldn't read remote address\n"); return 1; } @@ -1130,8 +1128,7 @@ int ethernet_write_data(struct perftest_comm *comm, char* msg) { int ethernet_read_data(struct perftest_comm *comm, char* recv_msg) { if (read(comm->rdma_params->sockfd, recv_msg, sizeof recv_msg) != sizeof recv_msg) { - perror("pp_read_keys"); - fprintf(stderr, "Couldn't read reports\n"); + fprintf(stderr, "ethernet_read_data: Couldn't read reports\n"); return 1; } diff --git a/src/perftest_parameters.c b/src/perftest_parameters.c index 084f16f..5899103 100755 --- a/src/perftest_parameters.c +++ b/src/perftest_parameters.c @@ -267,6 +267,8 @@ static void usage(const char *argv0,VerbType verb,TestType tst) { if (tst == BW) printf(" -q, --qp= Num of qp's(default %d)\n",DEF_NUM_QPS); + printf(" --pkey_index= PKey index to use for QP\n"); + putchar('\n'); } /****************************************************************************** @@ -345,6 +347,7 @@ static void init_perftest_params(struct perftest_parameters *user_param) { user_param->limit_bw = 0; user_param->is_limit_msgrate = OFF; user_param->limit_msgrate = 0; + user_param->pkey_index = 0; if (user_param->tst == LAT) { user_param->r_flag->unsorted = OFF; @@ -841,6 +844,33 @@ static int ctx_set_out_reads(struct ibv_context *context,int num_user_reads) { /****************************************************************************** * ******************************************************************************/ +static int ctx_chk_pkey_index(struct ibv_context *context,int pkey_idx) { + + + int idx = 0; + struct ibv_device_attr attr; + + if (!ibv_query_device(context,&attr)) { + + if (pkey_idx > attr.max_pkeys - 1) { + printf(RESULT_LINE); + fprintf(stderr," Specified PKey Index, %i, greater than allowed max, %i\n",pkey_idx,attr.max_pkeys - 1); + fprintf(stderr," Changing to 0\n"); + idx = 0; + } else + idx = pkey_idx; + } else { + fprintf(stderr," Unable to validate PKey Index, changing to 0\n"); + idx = 0; + } + + return idx; + +} + +/****************************************************************************** + * + ******************************************************************************/ static void ctx_set_max_inline(struct ibv_context *context,struct perftest_parameters *user_param) { @@ -883,6 +913,7 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc) { static int run_inf_flag = 0; static int report_fmt_flag = 0; static int srq_flag = 0; + static int pkey_flag = 0; init_perftest_params(user_param); @@ -941,6 +972,7 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc) { { .name = "run_infinitely", .has_arg = 0, .flag = &run_inf_flag, .val = 1 }, { .name = "report_gbits", .has_arg = 0, .flag = &report_fmt_flag, .val = 1}, { .name = "use-srq", .has_arg = 0, .flag = &srq_flag, .val = 1}, + { .name = "pkey_index", .has_arg = 1, .flag = &pkey_flag, .val = 1}, { 0 } }; c = getopt_long(argc,argv,"w:y:p:d:i:m:s:n:t:u:S:x:c:q:I:o:M:r:Q:A:l:D:f:B:T:E:J:j:K:k:aFegzRvhbNVCHUOZP",long_options,NULL); @@ -1143,7 +1175,11 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc) { case 'P': user_param->machine = CLIENT; break; case 'Z': user_param->machine = SERVER; break; case 'v': user_param->mac_fwd = ON; break; - case 0: break; // required for long options to work. + case 0: // used for long options + if (pkey_flag) { + user_param->pkey_index = strtol(optarg,NULL,0); + } + break; default: fprintf(stderr," Invalid Command or flag.\n"); fprintf(stderr," Please check command line and run again.\n\n"); @@ -1256,6 +1292,9 @@ int check_link_and_mtu(struct ibv_context *context,struct perftest_parameters *u if (!user_param->ib_devname) GET_STRING(user_param->ib_devname,ibv_get_device_name(context->device)) + if (user_param->pkey_index > 0) + user_param->pkey_index = ctx_chk_pkey_index(context, user_param->pkey_index); + return SUCCESS; } diff --git a/src/perftest_parameters.h b/src/perftest_parameters.h index 42f6966..3f0d59f 100755 --- a/src/perftest_parameters.h +++ b/src/perftest_parameters.h @@ -291,6 +291,7 @@ struct perftest_parameters { int work_rdma_cm; char *user_mgid; int buff_size; + int pkey_index; // New test params format pilot. will be used in all flags soon,. enum ctx_test_method test_method; enum ibv_transport_type transport_type; diff --git a/src/perftest_resources.c b/src/perftest_resources.c index 2ddddd1..9d869c1 100755 --- a/src/perftest_resources.c +++ b/src/perftest_resources.c @@ -619,7 +619,7 @@ int ctx_modify_qp_to_init(struct ibv_qp *qp,struct perftest_parameters *user_par memset(&attr, 0, sizeof(struct ibv_qp_attr)); attr.qp_state = IBV_QPS_INIT; - attr.pkey_index = 0; + attr.pkey_index = user_param->pkey_index; if ( user_param->use_xrc && (user_param->duplex || user_param->tst == LAT)) { num_of_qps /= 2;