public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH/ibsim] Provide support for SubnSet(GUIDInfo)
@ 2011-09-16 21:06 Jason Gunthorpe
       [not found] ` <20110916210611.GA6926-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Jason Gunthorpe @ 2011-09-16 21:06 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Alex Netes

Hardwire PortInfo.GUIDCap to 1 for both the switch and HCA case,
then simply verify that the incoming SubnSet matches the RO data
in block 0.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 ibsim/sim_mad.c |   25 +++++++++++++++++--------
 ibsim/sim_net.c |    2 +-
 2 files changed, 18 insertions(+), 9 deletions(-)

I've put all our patches for ibsim on my github page:

git://github.com/jgunthorpe/ibsim.git

diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c
index 83d4e3b..60da7d2 100644
--- a/ibsim/sim_mad.c
+++ b/ibsim/sim_mad.c
@@ -385,17 +385,26 @@ static int do_guidinfo(Port * port, unsigned op, uint32_t mod, uint8_t * data)
 	Node *node = port->node;
 	int status = 0;
 	uint64_t portguid = node->nodeguid + port->portnum;
+	if (node->type == SWITCH_NODE)
+		portguid = node->nodeguid;
 
-	if (op != IB_MAD_METHOD_GET)    // only get currently supported (non compliant)
-		status = ERR_METHOD_UNSUPPORTED;
-
-	memset(data, 0, IB_SMP_DATA_SIZE);
-	if (mod == 0) {
-		if (node->type == SWITCH_NODE)
-			mad_encode_field(data, IB_GUID_GUID0_F, &node->nodeguid);
-		else
+	if (op == IB_MAD_METHOD_SET) {
+		/* The PortInfo.GuidCap is hardwired to 1, so the only valid input
+		   to a Set is the port GUID followed by zeros on block 0. */
+		int i = mod == 0?1:0;
+		for (; i != 8; ++i)
+			if (mad_get_field64(data, i*8, IB_GUID_GUID0_F) != 0)
+				status = ERR_BAD_PARAM;
+		if (mod != 0 ||
+		    mad_get_field64(data, 0, IB_GUID_GUID0_F) != portguid)
+			status = ERR_BAD_PARAM;
+	} else if (op == IB_MAD_METHOD_GET) {
+		memset(data, 0, IB_SMP_DATA_SIZE);
+		if (mod == 0)
 			mad_encode_field(data, IB_GUID_GUID0_F, &portguid);
 	}
+	else
+		status = ERR_METHOD_UNSUPPORTED;
 
 	return status;
 }
diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c
index 13c3b8c..59fc28e 100644
--- a/ibsim/sim_net.c
+++ b/ibsim/sim_net.c
@@ -104,7 +104,7 @@ static const uint8_t hcaport[] = {
 	0x00, 0x00, 0x0F, 0xF9, 0x01, 0x03, 0x03, 0x02,
 	0x12, 0x52, 0x00, 0x11, 0x40, 0x40, 0x00, 0x08,
 	0x08, 0x04, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x20, 0x1F, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00, 0x00,
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 };
 
-- 
1.7.1

--
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] 7+ messages in thread

end of thread, other threads:[~2011-09-21 16:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-16 21:06 [PATCH/ibsim] Provide support for SubnSet(GUIDInfo) Jason Gunthorpe
     [not found] ` <20110916210611.GA6926-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2011-09-19 14:07   ` Hal Rosenstock
     [not found]     ` <CAKzyTsy6QsrufSAFrCDyUUZcZvQU+PHuPjEL7y9SrT3FuaD19Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-19 15:59       ` Jason Gunthorpe
     [not found]         ` <20110919155904.GA8113-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2011-09-19 19:55           ` Hal Rosenstock
     [not found]             ` <CAKzyTsw+VpLaz14eSLNED40QGN3GCeQ5xC7FZp59Da8C1xE3ww-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-19 20:06               ` Jason Gunthorpe
     [not found]                 ` <20110919200637.GA28454-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2011-09-21 13:04                   ` Hal Rosenstock
     [not found]                     ` <CAKzyTswY3ebSgWMWhm7aV0n4PHa4O1qxuHu-EqnwER7b7o-=Dg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-21 16:37                       ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox