[PATCH 2/4] sim_ctl_get_pkeys

Doron Shoham
2010-03-21T15:21:11Z

similar to sim_ctl_get_portinfo, return the correct
port's pkey tables according to the port number.

Signed-off-by: Doron Shoham <dorons-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
ibsim/ibsim.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/ibsim/ibsim.c b/ibsim/ibsim.c
index 9326d37..3cb97e4 100644
--- a/ibsim/ibsim.c
+++ b/ibsim/ibsim.c
@@ -354,11 +354,18 @@ static int sim_ctl_set_issm(Client * cl, struct sim_ctl * ctl)

static int sim_ctl_get_pkeys(Client * cl, struct sim_ctl * ctl)
{
- Port *port = cl->port;
- unsigned size = (port->node->sw && port->portnum) ?
- mad_get_field(port->node->sw->switchinfo, 0,
- IB_SW_PARTITION_ENFORCE_CAP_F) :
- mad_get_field(port->node->nodeinfo, 0, IB_NODE_PARTITION_CAP_F);
+ Port *port;
+ uint8_t port_num = ctl->data[0];
+ unsigned size;
+
+ if (port_num == 0 || port_num > cl->port->node->numports)
+ port = cl->port;
+ else
+ port = node_get_port(cl->port->node, port_num);
+ size = (port->node->sw && port->portnum) ?
+ mad_get_field(port->node->sw->switchinfo, 0,
+ IB_SW_PARTITION_ENFORCE_CAP_F) :
+ mad_get_field(port->node->nodeinfo, 0, IB_NODE_PARTITION_CAP_F);

size *= sizeof(port->pkey_tbl[0]);
if (size > sizeof(ctl->data))