FreeBSD/sys/dev/mps/mps.c
/*
 * The MPT driver had a verbose interface for config pages.  In this driver,
 * reduce it to much simpler terms, similar to the Linux driver.
 */
The MPT driver had a verbose interface for config pages.  In this driver,
reduce it to much simpler terms, similar to the Linux driver.
The MPT driver had a verbose interface for config pages . In this driver reduce it to much simpler terms similar to the Linux driver .
int
mps_read_config_page(struct mps_softc *sc, struct mps_config_params *params)
{
	MPI2_CONFIG_REQUEST *req;
	struct mps_command *cm;
	int error;
	if (sc->mps_flags & MPS_FLAGS_BUSY) {
		return (EBUSY);
	}
	cm = mps_alloc_command(sc);
	if (cm == NULL) {
		return (EBUSY);
	}
	req = (MPI2_CONFIG_REQUEST *)cm->cm_req;
	req->Function = MPI2_FUNCTION_CONFIG;
	req->Action = params->action;
	req->SGLFlags = 0;
	req->ChainOffset = 0;
	req->PageAddress = params->page_address;
	if (params->hdr.Struct.PageType == MPI2_CONFIG_PAGETYPE_EXTENDED) {
		MPI2_CONFIG_EXTENDED_PAGE_HEADER *hdr;
		hdr = &params->hdr.Ext;
		req->ExtPageType = hdr->ExtPageType;
		req->ExtPageLength = hdr->ExtPageLength;
		req->Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
		req->Header.PageLength = 0; 
		req->Header.PageNumber = hdr->PageNumber;
		req->Header.PageVersion = hdr->PageVersion;
	} else {
		MPI2_CONFIG_PAGE_HEADER *hdr;
		hdr = &params->hdr.Struct;
		req->Header.PageType = hdr->PageType;
		req->Header.PageNumber = hdr->PageNumber;
		req->Header.PageLength = hdr->PageLength;
		req->Header.PageVersion = hdr->PageVersion;
	}
	cm->cm_data = params->buffer;
	cm->cm_length = params->length;
	if (cm->cm_data != NULL) {
		cm->cm_sge = &req->PageBufferSGE;
		cm->cm_sglsize = sizeof(MPI2_SGE_IO_UNION);
		cm->cm_flags = MPS_CM_FLAGS_SGE_SIMPLE | MPS_CM_FLAGS_DATAIN;
	} else
		cm->cm_sge = NULL;
	cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
	cm->cm_complete_data = params;
	if (params->callback != NULL) {
		cm->cm_complete = mps_config_complete;
		return (mps_map_command(sc, cm));
	} else {
		error = mps_wait_command(sc, cm, 0, CAN_SLEEP);
		if (error) {
			mps_dprint(sc, MPS_FAULT,
			    "Error %d reading config page\n", error);
			mps_free_command(sc, cm);
			return (error);
		}
		mps_config_complete(sc, cm);
	}
	return (0);
}
int mps_read_config_page ( struct mps_softc * sc , struct mps_config_params * params ) { MPI2_CONFIG_REQUEST * req ; struct mps_command * cm ; int error ; if ( sc -> mps_flags & MPS_FLAGS_BUSY ) { return ( EBUSY ) ; } cm = mps_alloc_command ( sc ) ; if ( cm == NULL ) { return ( EBUSY ) ; } req = ( MPI2_CONFIG_REQUEST * ) cm -> cm_req ; req -> Function = MPI2_FUNCTION_CONFIG ; req -> Action = params -> action ; req -> SGLFlags = 0 ; req -> ChainOffset = 0 ; req -> PageAddress = params -> page_address ; if ( params -> hdr . Struct . PageType == MPI2_CONFIG_PAGETYPE_EXTENDED ) { MPI2_CONFIG_EXTENDED_PAGE_HEADER * hdr ; hdr = & params -> hdr . Ext ; req -> ExtPageType = hdr -> ExtPageType ; req -> ExtPageLength = hdr -> ExtPageLength ; req -> Header . PageType = MPI2_CONFIG_PAGETYPE_EXTENDED ; req -> Header . PageLength = 0 ; req -> Header . PageNumber = hdr -> PageNumber ; req -> Header . PageVersion = hdr -> PageVersion ; } else { MPI2_CONFIG_PAGE_HEADER * hdr ; hdr = & params -> hdr . Struct ; req -> Header . PageType = hdr -> PageType ; req -> Header . PageNumber = hdr -> PageNumber ; req -> Header . PageLength = hdr -> PageLength ; req -> Header . PageVersion = hdr -> PageVersion ; } cm -> cm_data = params -> buffer ; cm -> cm_length = params -> length ; if ( cm -> cm_data != NULL ) { cm -> cm_sge = & req -> PageBufferSGE ; cm -> cm_sglsize = sizeof ( MPI2_SGE_IO_UNION ) ; cm -> cm_flags = MPS_CM_FLAGS_SGE_SIMPLE | MPS_CM_FLAGS_DATAIN ; } else cm -> cm_sge = NULL ; cm -> cm_desc . Default . RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE ; cm -> cm_complete_data = params ; if ( params -> callback != NULL ) { cm -> cm_complete = mps_config_complete ; return ( mps_map_command ( sc , cm ) ) ; } else { error = mps_wait_command ( sc , cm , 0 , CAN_SLEEP ) ; if ( error ) { mps_dprint ( sc , MPS_FAULT , " \n " , error ) ; mps_free_command ( sc , cm ) ; return ( error ) ; } mps_config_complete ( sc , cm ) ; } return ( 0 ) ; }
The MPT driver had a verbose interface for config pages.
The MPT driver had a verbose interface for config pages .
/* Must be set to zero */