From patchwork Tue Mar 19 13:12:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Ben Yosef X-Patchwork-Id: 2300601 X-Patchwork-Delegate: ira.weiny@intel.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 79EFFDFB79 for ; Tue, 19 Mar 2013 13:13:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755292Ab3CSNNB (ORCPT ); Tue, 19 Mar 2013 09:13:01 -0400 Received: from eu1sys200aog102.obsmtp.com ([207.126.144.113]:48927 "EHLO eu1sys200aog102.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755110Ab3CSNNB (ORCPT ); Tue, 19 Mar 2013 09:13:01 -0400 Received: from mtlsws123.lab.mtl.com ([82.166.227.17]) (using TLSv1) by eu1sys200aob102.postini.com ([207.126.147.11]) with SMTP ID DSNKUUhkWQR/fpOQGLfL3bkUD2QX067eIFX8@postini.com; Tue, 19 Mar 2013 13:13:00 UTC Received: from r-ufm5-17.lab.mtl.com (r-ufm5-17.mtr.labs.mlnx [172.30.5.91]) by mtlsws123.lab.mtl.com (8.13.8/8.13.8) with ESMTP id r2JDCuIg009899; Tue, 19 Mar 2013 15:12:56 +0200 Received: from r-ufm5-17.mtr.labs.mlnx (localhost [127.0.0.1]) by r-ufm5-17.lab.mtl.com (8.14.4/8.14.4) with ESMTP id r2JDCuwL029576; Tue, 19 Mar 2013 15:12:56 +0200 Received: (from danby@localhost) by r-ufm5-17.mtr.labs.mlnx (8.14.4/8.14.4/Submit) id r2JDCtQc029573; Tue, 19 Mar 2013 15:12:55 +0200 Date: Tue, 19 Mar 2013 15:12:55 +0200 From: Dan Ben Yosef To: Ira Weiny Cc: linux-rdma@vger.kernel.org Subject: [PATCH]: infiniband-diags/ibportstate.c: Add ON and OFF options. Message-ID: <20130319131255.GA29404@r-ufm5-17.mtr.labs.mlnx> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Add new Options : 1.ON: Changed the port state to enable only in case the current state is disable. 2.OFF: Change the port state to disable. Signed-off-by: Dan Ben Yosef --- doc/rst/ibportstate.8.in.rst | 6 +++++- src/ibportstate.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletions(-) diff --git a/doc/rst/ibportstate.8.in.rst b/doc/rst/ibportstate.8.in.rst index c082638..750ee42 100644 --- a/doc/rst/ibportstate.8.in.rst +++ b/doc/rst/ibportstate.8.in.rst @@ -30,13 +30,17 @@ OPTIONS **** Supported ops: enable, disable, reset, speed, espeed, fdr10, width, query, - down, arm, active, vls, mtu, lid, smlid, lmc, + on, off, down, arm, active, vls, mtu, lid, smlid, lmc, mkey, mkeylease, mkeyprot (Default is query) **enable, disable, and reset** are only allowed on switch ports (An error is indicated if attempted on CA or router ports) + **off** change the port state to disable. + + **on** change the port state to enable(only when the current state is disable). + **speed and width** are allowed on any port **speed** values are the legal values for PortInfo:LinkSpeedEnabled (An diff --git a/src/ibportstate.c b/src/ibportstate.c index 053b0a2..12ed442 100644 --- a/src/ibportstate.c +++ b/src/ibportstate.c @@ -68,6 +68,8 @@ enum port_ops { MKEY, MKEYLEASE, MKEYPROT, + ON, + OFF }; struct ibmad_port *srcport; @@ -108,6 +110,8 @@ struct { {"mkey", &mkey, 0}, /* MKEY */ {"mkeylease", &mkeylease, 0}, /* MKEY LEASE */ {"mkeyprot", &mkeyprot, 0}, /* MKEY PROTECT BITS */ + {"on", NULL, 0}, /* ON */ + {"off", NULL, 0}, /* OFF */ }; #define NPORT_ARGS (sizeof(port_args) / sizeof(port_args[0])) @@ -534,6 +538,8 @@ int main(int argc, char **argv) * the SMA command will fail due to an invalid LID. * Set it to something unlikely but valid. */ + physstate = mad_get_field(data, 0, IB_PORT_PHYS_STATE_F); + val = mad_get_field(data, 0, IB_PORT_LID_F); if (!port_args[LID].set && (!val || val == 0xFFFF)) mad_set_field(data, 0, IB_PORT_LID_F, 0x1234); @@ -544,11 +550,18 @@ int main(int argc, char **argv) mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 0); /* NOP */ switch (port_op) { + case ON: + /* Enable only if state is Disable */ + if(physstate != 3) { + printf("Port is already in enable state\n"); + goto close_port; + } case ENABLE: case RESET: /* Polling */ mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 2); break; + case OFF: case DISABLE: printf("Disable may be irreversible\n"); mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 3); @@ -732,6 +745,7 @@ int main(int argc, char **argv) } } +close_port: mad_rpc_close_port(srcport); exit(0); }