[ofa-general] Re: [PATCH] ibsim/sim_mad.c: Add trap/trap repress handling in simulated SMA

Sasha Khapyorsky sashak at voltaire.com
Fri Mar 6 05:51:42 PST 2009


On 07:23 Thu 05 Mar     , Hal Rosenstock wrote:
> 
> Add notice attribute support
> Also, changes to decode_sim_MAD and reply_MAD for trap/trap repress methods
> 
> Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
> 
> ---
> diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c
> index 32a667e..1a929c5 100644
> --- a/ibsim/sim_mad.c
> +++ b/ibsim/sim_mad.c
> @@ -57,7 +57,7 @@
>  typedef int (Smpfn) (Port * port, unsigned op, uint32_t mod, uint8_t * data);
>  typedef int (EncodeTrapfn) (Port * port, char *data);
>  
> -static Smpfn do_nodeinfo, do_nodedesc, do_switchinfo, do_portinfo,
> +static Smpfn do_notice, do_nodeinfo, do_nodedesc, do_switchinfo, do_portinfo,
>      do_linearforwtbl, do_multicastforwtbl, do_portcounters, do_extcounters,
>      do_pkeytbl, do_sl2vl, do_vlarb, do_guidinfo, do_cpi;
>  
> @@ -65,7 +65,8 @@ static EncodeTrapfn encode_trap128;
>  static EncodeTrapfn encode_trap144;
>  
>  static Smpfn *attrs[IB_PERFORMANCE_CLASS + 1][0xff] = {
> -	[IB_SMI_CLASS] {[IB_ATTR_NODE_DESC] do_nodedesc,
> +	[IB_SMI_CLASS] {[NOTICE] do_notice,

Now Trap MAD is routed to SM, Right?

By having do_notice() processor ibsim will reply by itself and will
prevent SM from receiving traps. No?

> +			[IB_ATTR_NODE_DESC] do_nodedesc,
>  			[IB_ATTR_NODE_INFO] do_nodeinfo,
>  			[IB_ATTR_SWITCH_INFO] do_switchinfo,
>  			[IB_ATTR_PORT_INFO] do_portinfo,
> @@ -118,15 +119,22 @@ static int decode_sim_MAD(Client * cl, struct sim_request * r, ib_rpc_t * rpc,
>  {
>  	void *buf = r->mad;
>  	int response;
> +	uint8_t method;
>  
> -	// first word
> -	response = mad_get_field(buf, 0, IB_MAD_RESPONSE_F);
> +	method = mad_get_field(buf, 0, IB_MAD_METHOD_F);
> +	if (method == IB_MAD_METHOD_TRAP_REPRESS)
> +		response = 1;
> +	else if (method == IB_MAD_METHOD_TRAP)
> +		response = 0;
> +	else
> +		// first word
> +		response = mad_get_field(buf, 0, IB_MAD_RESPONSE_F);

TrapRepress MAD is dropped by ibsim (in process_packet() function right
after decode_sim_MAD() call). How will "response" return value matter
there? (With trap method the original code should work fine - bit 7 of
method field is '0').

Sasha

>  	if (mad_get_field(buf, 0, IB_MAD_CLASSVER_F) > 2 ||	// sma ver is 1, sa is 2
>  	    mad_get_field(buf, 0, IB_MAD_BASEVER_F) != 1) {
>  		IBWARN("bad smp headers (1st word)");
>  		return -1;
>  	}
> -	rpc->method = mad_get_field(buf, 0, IB_MAD_METHOD_F);
> +	rpc->method = method;
>  	rpc->mgtclass = mad_get_field(buf, 0, IB_MAD_MGMTCLASS_F);
>  
>  	// second word:
> @@ -189,11 +197,17 @@ static int forward_MAD(void *buf, ib_rpc_t * rpc, ib_dr_path_t * path)
>  static int reply_MAD(void *buf, ib_rpc_t * rpc, ib_dr_path_t * path,
>  		     int status, void *data)
>  {
> -	// first word
> -	mad_set_field(buf, 0, IB_MAD_RESPONSE_F, 1);
> -	mad_set_field(buf, 0, IB_MAD_METHOD_F, 0x81);	// SUBN_GETRESP
> -
> -	// second word:
> +	uint8_t method;
> +
> +	method = mad_get_field(buf, 0, IB_MAD_METHOD_F);
> +	if (method == IB_MAD_METHOD_TRAP)
> +		mad_set_field(buf, 0, IB_MAD_METHOD_F, IB_MAD_METHOD_TRAP_REPRESS);
> +	else if (method != IB_MAD_METHOD_TRAP_REPRESS) {
> +		// first word
> +		mad_set_field(buf, 0, IB_MAD_RESPONSE_F, 1);
> +		mad_set_field(buf, 0, IB_MAD_METHOD_F, 0x81);	// SUBN_GETRESP
> +	}
> +	// second word
>  	if (rpc->mgtclass == 0x81) {	// direct route
>  		mad_set_field(buf, 0, IB_DRSMP_STATUS_F, status);
>  		mad_set_field(buf, 0, IB_DRSMP_DIRECTION_F, 1);
> @@ -218,6 +232,16 @@ static int reply_MAD(void *buf, ib_rpc_t * rpc, ib_dr_path_t * path,
>  	return 0;
>  }
>  
> +static int do_notice(Port * port, unsigned op, uint32_t mod, uint8_t * data)
> +{
> +	int status = 0;
> +
> +	if (op != IB_MAD_METHOD_TRAP && op != IB_MAD_METHOD_TRAP_REPRESS)
> +		status = ERR_METHOD_UNSUPPORTED;
> +
> +	return status;
> +}
> +
>  static int do_cpi(Port * port, unsigned op, uint32_t mod, uint8_t * data)
>  {
>  	int status = 0;



More information about the general mailing list