[ofa-general] Re: [PATCH] libibmad: Add support for SA PathRecord SL field

Sasha Khapyorsky sashak at voltaire.com
Fri May 1 13:50:28 PDT 2009


Hi Hal,

On 07:06 Mon 27 Apr     , Hal Rosenstock wrote:
> 
> Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>

There are different things mixed in this patch (like self NodeInfo
resolution and redirection status printouts)? Is it just typo?

Sasha

> ---
> diff --git a/libibmad/include/infiniband/mad.h b/libibmad/include/infiniband/mad.h
> index 0e47ccf..c74cb1d 100644
> --- a/libibmad/include/infiniband/mad.h
> +++ b/libibmad/include/infiniband/mad.h
> @@ -500,6 +500,7 @@ enum MAD_FIELDS {
>  	IB_SA_PR_DLID_F,
>  	IB_SA_PR_SLID_F,
>  	IB_SA_PR_NPATH_F,
> +	IB_SA_PR_SL_F,
>  
>  	/*
>  	 * MC Member rec
> diff --git a/libibmad/src/fields.c b/libibmad/src/fields.c
> index c24bc12..81693a2 100644
> --- a/libibmad/src/fields.c
> +++ b/libibmad/src/fields.c
> @@ -305,6 +305,7 @@ static const ib_field_t ib_mad_f[] = {
>  	{BITSOFFS(320, 16), "PathRecDLid", mad_dump_uint},
>  	{BITSOFFS(336, 16), "PathRecSLid", mad_dump_uint},
>  	{BITSOFFS(393, 7), "PathRecNumPath", mad_dump_uint},
> +	{BITSOFFS(428, 4), "PathRecSL", mad_dump_uint},
>  
>  	/*
>  	 * MC Member rec
> diff --git a/libibmad/src/resolve.c b/libibmad/src/resolve.c
> index 691bdc3..f17da11 100644
> --- a/libibmad/src/resolve.c
> +++ b/libibmad/src/resolve.c
> @@ -59,6 +59,7 @@ int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout,
>  		return -1;
>  
>  	mad_decode_field(portinfo, IB_PORT_SMLID_F, &lid);
> +	mad_decode_field(portinfo, IB_PORT_SMSL_F, &sm_id->sl);
>  
>  	return ib_portid_set(sm_id, lid, 0, 0);
>  }
> @@ -74,12 +75,23 @@ int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
>  {
>  	ib_portid_t sm_portid;
>  	char buf[IB_SA_DATA_SIZE] = { 0 };
> +	ib_portid_t self = { 0 };
> +	uint64_t selfguid;
> +	ibmad_gid_t selfgid;
> +	uint8_t nodeinfo[64];
>  
>  	if (!sm_id) {
>  		sm_id = &sm_portid;
>  		if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0)
>  			return -1;
>  	}
> +
> +	if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport))
> +		return -1;
> +	mad_decode_field(nodeinfo, IB_NODE_PORT_GUID_F, &selfguid);
> +	mad_set_field64(selfgid, 0, IB_GID_PREFIX_F, IB_DEFAULT_SUBN_PREFIX);
> +	mad_set_field64(selfgid, 0, IB_GID_GUID_F, selfguid);
> +
>  	if (*(uint64_t *) & portid->gid == 0)
>  		mad_set_field64(portid->gid, 0, IB_GID_PREFIX_F,
>  				IB_DEFAULT_SUBN_PREFIX);
> @@ -87,10 +99,11 @@ int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
>  		mad_set_field64(portid->gid, 0, IB_GID_GUID_F, *guid);
>  
>  	if ((portid->lid =
> -	     ib_path_query_via(srcport, portid->gid, portid->gid, sm_id,
> +	     ib_path_query_via(srcport, selfgid, portid->gid, sm_id,
>  			       buf)) < 0)
>  		return -1;
>  
> +	mad_decode_field(buf, IB_SA_PR_SL_F, &portid->sl);
>  	return 0;
>  }
>  
> @@ -167,6 +180,7 @@ int ib_resolve_self_via(ib_portid_t * portid, int *portnum, ibmad_gid_t * gid,
>  		return -1;
>  
>  	mad_decode_field(portinfo, IB_PORT_LID_F, &portid->lid);
> +	mad_decode_field(portinfo, IB_PORT_SMSL_F, &portid->sl);
>  	mad_decode_field(portinfo, IB_PORT_GID_PREFIX_F, &prefix);
>  	mad_decode_field(nodeinfo, IB_NODE_PORT_GUID_F, &guid);
>  
> diff --git a/libibmad/src/rpc.c b/libibmad/src/rpc.c
> index 07b623d..21fcc9a 100644
> --- a/libibmad/src/rpc.c
> +++ b/libibmad/src/rpc.c
> @@ -187,7 +187,7 @@ void *mad_rpc(const struct ibmad_port *port, ib_rpc_t * rpc,
>  	      ib_portid_t * dport, void *payload, void *rcvdata)
>  {
>  	int status, len;
> -	uint8_t sndbuf[1024], rcvbuf[1024], *mad;
> +	uint8_t sndbuf[1024], rcvbuf[1024], *mad, mgmtclass;
>  	int timeout, retries;
>  
>  	len = 0;
> @@ -209,7 +209,18 @@ void *mad_rpc(const struct ibmad_port *port, ib_rpc_t * rpc,
>  
>  	mad = umad_get_mad(rcvbuf);
>  
> -	if ((status = mad_get_field(mad, 0, IB_DRSMP_STATUS_F)) != 0) {
> +	status = mad_get_field(mad, 0, IB_MAD_STATUS_F);
> +	mgmtclass = mad_get_field(mad, 0, IB_MAD_MGMTCLASS_F);
> +	if (mgmtclass == IB_SMI_DIRECT_CLASS)
> +		status &= 0x7fff;
> +	else if (mgmtclass != IB_SMI_CLASS) {
> +		if (status & 2) {
> +			ERRS("MAD redirection not supported; dport (%s)",
> +			     portid2str(dport));
> +			return 0;
> +		}
> +	}
> +	if (status) {
>  		ERRS("MAD completed with error status 0x%x; dport (%s)",
>  		     status, portid2str(dport));
>  		return 0;
> @@ -254,8 +265,12 @@ void *mad_rpc_rmpp(const struct ibmad_port *port, ib_rpc_t * rpc,
>  	mad = umad_get_mad(rcvbuf);
>  
>  	if ((status = mad_get_field(mad, 0, IB_MAD_STATUS_F)) != 0) {
> -		ERRS("MAD completed with error status 0x%x; dport (%s)",
> -		     status, portid2str(dport));
> +		if (status & 2)
> +			ERRS("MAD redirection not supported; dport (%s)",
> +			     portid2str(dport));
> +		else
> +			ERRS("MAD completed with error status 0x%x; dport (%s)",
> +			     status, portid2str(dport));
>  		return 0;
>  	}
>  
> 



More information about the general mailing list