FreeBSD/sys/dev/cxgbe/common/t4_hw.c
/**
 *	t4_query_params_rw - query FW or device parameters
 *	@adap: the adapter
 *	@mbox: mailbox to use for the FW command
 *	@pf: the PF
 *	@vf: the VF
 *	@nparams: the number of parameters
 *	@params: the parameter names
 *	@val: the parameter values
 *	@rw: Write and read flag
 *
 *	Reads the value of FW or device parameters.  Up to 7 parameters can be
 *	queried at once.
 */


Reads the value of FW or device parameters.  Up to 7 parameters can be
queried at once.
Reads the value of FW or device parameters . Up to 7 parameters can be queried at once .
int t4_query_params_rw(struct adapter *adap, unsigned int mbox, unsigned int pf,
		       unsigned int vf, unsigned int nparams, const u32 *params,
		       u32 *val, int rw)
{
	int i, ret;
	struct fw_params_cmd c;
	__be32 *p = &c.param[0].mnem;
	if (nparams > 7)
		return -EINVAL;
	memset(&c, 0, sizeof(c));
	c.op_to_vfn = cpu_to_be32(V_FW_CMD_OP(FW_PARAMS_CMD) |
				  F_FW_CMD_REQUEST | F_FW_CMD_READ |
				  V_FW_PARAMS_CMD_PFN(pf) |
				  V_FW_PARAMS_CMD_VFN(vf));
	c.retval_len16 = cpu_to_be32(FW_LEN16(c));
	for (i = 0; i < nparams; i++) {
		*p++ = cpu_to_be32(*params++);
		if (rw)
			*p = cpu_to_be32(*(val + i));
		p++;
	}
	ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
	if (ret == 0)
		for (i = 0, p = &c.param[0].val; i < nparams; i++, p += 2)
			*val++ = be32_to_cpu(*p);
	return ret;
}
int t4_query_params_rw ( struct adapter * adap , unsigned int mbox , unsigned int pf , unsigned int vf , unsigned int nparams , const u32 * params , u32 * val , int rw ) { int i , ret ; struct fw_params_cmd c ; __be32 * p = & c . param [ 0 ] . mnem ; if ( nparams > 7 ) return - EINVAL ; memset ( & c , 0 , sizeof ( c ) ) ; c . op_to_vfn = cpu_to_be32 ( V_FW_CMD_OP ( FW_PARAMS_CMD ) | F_FW_CMD_REQUEST | F_FW_CMD_READ | V_FW_PARAMS_CMD_PFN ( pf ) | V_FW_PARAMS_CMD_VFN ( vf ) ) ; c . retval_len16 = cpu_to_be32 ( FW_LEN16 ( c ) ) ; for ( i = 0 ; i < nparams ; i ++ ) { * p ++ = cpu_to_be32 ( * params ++ ) ; if ( rw ) * p = cpu_to_be32 ( * ( val + i ) ) ; p ++ ; } ret = t4_wr_mbox ( adap , mbox , & c , sizeof ( c ) , & c ) ; if ( ret == 0 ) for ( i = 0 , p = & c . param [ 0 ] . val ; i < nparams ; i ++ , p += 2 ) * val ++ = be32_to_cpu ( * p ) ; return ret ; }
t4_query_params_rw - query FW or device parameters
      @adap: the adapter
      @mbox: mailbox to use for the FW command
      @pf: the PF
      @vf: the VF
      @nparams: the number of parameters
      @params: the parameter names
      @val: the parameter values
      @rw: Write and read flag
t4_query_params_rw - query FW or device parameters @adap : the adapter @mbox : mailbox to use for the FW command @pf : the PF @vf : the VF @nparams : the number of parameters @params : the parameter names @val : the parameter values @rw : Write and read flag