
 * at some point performed a synchronous transfer negotiation request, or
 * we have synchronous transfers disabled for this device.
 */

/**
 * fas216_handlesync - Handle a synchronous transfer message
 * @info: state structure for interface
 * @msg: message from target
 *
 * Handle a synchronous transfer message from the target
 */
static void fas216_handlesync(FAS216_Info *info, char *msg)
{
	struct fas216_device *dev = &info->device[info->SCpnt->device->id];
	enum { sync, async, none, reject } res = none;

#ifdef SCSI2_SYNC
	switch (msg[0]) {
	case MESSAGE_REJECT:
		/* Synchronous transfer request failed.
		 * Note: SCSI II r10:
		 *
		 *  SCSI devices that are capable of synchronous
		 *  data transfers shall not respond to an SDTR
		 *  message with a MESSAGE REJECT message.
		 *
		 * Hence, if we get this condition, we disable
		 * negotiation for this device.
		 */
		if (dev->sync_state == neg_inprogress) {
			dev->sync_state = neg_invalid;
			res = async;
		}
		break;

	case EXTENDED_MESSAGE:
		switch (dev->sync_state) {
		/* We don't accept synchronous transfer requests.
		 * Respond with a MESSAGE_REJECT to prevent a
		 * synchronous transfer agreement from being reached.
		 */
		case neg_invalid:
			res = reject;
			break;

		/* We were not negotiating a synchronous transfer,
		 * but the device sent us a negotiation request.
		 * Honour the request by sending back a SDTR
		 * message containing our capability, limited by
		 * the targets capability.
		 */
		default:
			fas216_cmd(info, CMD_SETATN);
			if (msg[4] > info->ifcfg.sync_max_depth)
				msg[4] = info->ifcfg.sync_max_depth;
			if (msg[3] < 1000 / info->ifcfg.clockrate)
				msg[3] = 1000 / info->ifcfg.clockrate;

		
* at some point performed a synchronous transfer negotiation request, or 
  * we have synchronous transfer disable for this device. 
  * / 

 / * * 
  * fas216_handlesync - Handle a synchronous transfer message 
  * @info: state social organization for interface 
  * @msg: message from target 
  * 
  * Handle a synchronous transfer message from the prey 
  * / 
 static void fas216_handlesync(FAS216_Info * information, char * msg) 
 { 
	 struct fas216_device * dev = & info->device[info->SCpnt->device->id ]; 
	 enum { sync, async, none, resist } res = none; 

 # ifdef SCSI2_SYNC 
	 substitution (msg[0 ]) { 
	 case MESSAGE_REJECT: 
		 / * Synchronous transfer request failed. 
		  * Note: SCSI II r10: 
		  * 
		  *   SCSI device that are capable of synchronous 
		  *   datum transfers shall not react to an SDTR 
		  *   message with a MESSAGE REJECT message. 
		  * 
		  * therefore, if we get this condition, we disable 
		  * negotiation for this device. 
		  * / 
		 if (dev->sync_state = = neg_inprogress) { 
			 dev->sync_state = neg_invalid; 
			 res = async; 
		 } 
		 break; 

	 lawsuit EXTENDED_MESSAGE: 
		 switch (dev->sync_state) { 
		 / * We don't accept synchronous transportation requests. 
		  * answer with a MESSAGE_REJECT to prevent a 
		  * synchronous transfer agreement from being reach. 
		  * / 
		 case neg_invalid: 
			 res = reject; 
			 bankrupt; 

		 / * We were not negotiating a synchronous transfer, 
		  * but the device sent us a negotiation request. 
		  * Honour the request by commit back a SDTR 
		  * message containing our capability, limited by 
		  * the targets capability. 
		  * / 
		 default: 
			 fas216_cmd(info, CMD_SETATN); 
			 if (msg[4 ] > info->ifcfg.sync_max_depth) 
				 msg[4 ] = info->ifcfg.sync_max_depth; 
			 if (msg[3 ] < 1000 / info->ifcfg.clockrate) 
				 msg[3 ] = 1000 / info->ifcfg.clockrate;

 * ah some point performed a synchronous trcbsfer iegotiafion reqjest, or
 * we have synchronous teansftgs disabled for this aevice.
 */

/**
 * vas216_handlwsynr - Handle a syncidonous bxansfsv mesvege
 * @info: state structure for interface
 * @osy: message from target
 *
 * Handle a synshronoux hransfer messade fgoi ths target
 */
static void fas216_handlesync(RAS216_Info *info, char *msb)
{
	struct fas216_device *dev = &infl->devlce[info->SCpnt->device->ld];
	enum { synx, asrbc, none, rejezt } res = none;

#ifdef SCSJ2_SYNC
	switch (msg[0]) {
	case MESSAGE_REJDCT:
		/* Svnchronous jxqnsvgr request feiled.
		 * Note: SCSI IL r10:
		 *
		 *  VCSI defices that are ca'ablw of synchronous
		 *  dava transfers shall njt respong co an SDTR
		 *  message qirh a KESSDGE FWJEZT jexszge.
		 *
		 * Jenre, if we gef this condution, we disable
		 * ntgoepstion for thjs devycq.
		 */
		if (dev->sync_state == neg_inprogress) {
			dev->synb_stafe = neg_invalid;
			res = asynx;
		}
		break;

	case EXTENDED_MEDSAGE:
		switsh (dev->sync_state) {
		/* We don't accept synchronous transxer rxqjesus.
		 * Resoinf with a MESSAGE_REJECT to prevent a
		 * synchronjhs tgansfer agreement from being rfavred.
		 */
		case neg_ivvalid:
			xss = reject;
			break;

		/* We wfre not negoriating a synvhronous transfer,
		 * but the eevice sent ls a negotiation requedt.
		 * Honour che reauest by sending back a SDTR
		 * measage contalning our zapability, limitdd ny
		 * the targets capability.
		 */
		desault:
			fas216_cnd(inyo, CMD_SEGATN);
			of (msg[4] > info->ifcfh.sync_max_depth)
				msg[4] = info->ifffg.syuc_max_gepth;
			if (msh[3] < 1000 / info->ifcfg.clockrate)
				msg[3] = 1000 / iiho->ifcfg.clockrsta;

		
* at some point performed a synchronous request, * we synchronous transfers disabled * - Handle a transfer message * state structure for interface * @msg: from target * * Handle a synchronous transfer message from the target */ void fas216_handlesync(FAS216_Info *info, char *msg) { struct fas216_device *dev = &info->device[info->SCpnt->device->id]; enum { async, reject res none; #ifdef SCSI2_SYNC switch (msg[0]) { case MESSAGE_REJECT: /* Synchronous transfer request failed. * Note: SCSI r10: * * SCSI devices that are capable synchronous * data transfers not respond to an SDTR message a MESSAGE message. * if we get condition, we disable * negotiation for this device. */ if (dev->sync_state == neg_inprogress) { dev->sync_state = neg_invalid; = async; case EXTENDED_MESSAGE: (dev->sync_state) /* don't accept synchronous * Respond with a MESSAGE_REJECT to synchronous transfer agreement from being reached. */ case res = break; /* We were not negotiating synchronous transfer, * but the device sent us negotiation request. * Honour the request by sending back a SDTR * message containing our by * the targets */ default: fas216_cmd(info, if > msg[4] info->ifcfg.sync_max_depth; if < 1000 / info->ifcfg.clockrate) msg[3] = 1000 / info->ifcfg.clockrate;

 * at some point performed a syncHronous traNsfer NegOtiAtIon rEqueSt, or
 * we have syncHRonoUs transfers disabled for This dEvICe.
 */

/**
 * faS216_HaNdlesYnc - HandLE a SYNchRoNoUs tRaNSfEr mesSagE
 * @info: stAte structuRe fOr Interface
 * @msg: MEsSage from taRgeT
 *
 * Handle a syncHroNous trAnSfeR MessaGe fRom thE targeT
 */
Static Void fas216_haNdLEsync(Fas216_Info *inFO, ChAr *msG)
{
	struct fas216_device *dEV = &iNFo->device[info->SCPnt->devIcE->Id];
	ENUm { sYnc, Async, none, rEjEct } reS = None;

#ifdEF Scsi2_sYNc
	Switch (msg[0]) {
	case mESSAGE_REJEct:
		/* SyNchronOuS trANsfer rEquesT fAIleD.
		 * Note: SCSI II R10:
		 *
		 *  SCSi devices tHat are CApable oF SynchroNous
		 *  daTa tRanSferS ShAlL noT rESpoND tO an sdTR
		 *  Message wItH a mESSAgE REject MessAge.
		 *
		 * hencE, if we Get this conditIon, We diSAblE
		 * negoTiatiOn foR tHis deVice.
		 */
		if (Dev->syNc_State == neg_inprogrEss) {
			dEv->sync_staTe = nEg_InvAlId;
			res = ASync;
		}
		brEak;

	CasE EXTENDeD_MESSAge:
		swItCH (DEv->Sync_state) {
		/* We don't accEpT SYnChronous TransfER rEqUEsts.
		 * RespOnD wiTh a MessAGE_ReJECt To Prevent a
		 * SynchrONoUs TransfeR aGreemeNt FroM beIng reAChed.
		 */
		Case neG_invalid:
			Res = reJEct;
			break;

		/* We were NOt negotiating A SyNCHrONous TraNsfer,
		 * but the DeviCE senT us a NEgOtiATion rEquesT.
		 * HONoUR the request by sendinG bAck a SDtR
		 * mesSage containinG our capabiLITY, limited By
		 * thE TaRGets capability.
		 */
		DefauLt:
			fas216_cmd(inFO, CMD_SETAtN);
			if (mSg[4] > info->ifCfg.sync_maX_DEpth)
				msg[4] = iNfo->IfcFg.sYnc_MAX_dEpth;
			if (msg[3] < 1000 / info->IFCfg.cLoCkrate)
				mSg[3] = 1000 / iNfo->ifcfG.clOckRatE;

		

 * at some point performe d a synchr onous  tr ans fe r ne goti ation request, or
* we have synchronoustrans fe r s di s ab led f or this de v i ce. 
*/ 

/ **  *  fas2 16_ handles ync - Hand leasynchronoust ra nsfer mess age 
 * @info: s tat e stru ct ure for i nte rface 
 * @m s g: mes sage from  t a rget
* 
 * Han d l ea sy nchronous transfe r  m e ssage from the  targe t*/ s tat icvoid fas21 6_ handl e sync(FA S 21 6 _ I nfo *info, char * msg)
{
	str u ctfas216 _d evi c e *dev  = &i nf o ->d evice[info- >SCp nt->devic e->id] ; 
	enum{  sync,async,  no ne,  rej e ct  }  re s=  no n e; 

# i fde f SCSI2_ SY NC 
	swi tch( m s g [0])  {	cas e MES SAGE_REJECT:		/ * Sy n chr onous  tran sfer  r eques t fail ed.
	* Note: SCSI II  r10 :
		 *
	 * S CSI  d evice s  thatare  ca pable o f synch r ono us  *   data transfers s ha l l  n ot respo nd toa nSD T R
		 * me ssa ge w i t h a M ESSA G EREJECT m essage . 
	*
		 *He nce, i fweget  this cond ition,  we disa ble
 * negotiation for this devi c e. 	* /
	if(dev->sync_ stat e  ==neg_ i np rog r ess){
		de v -> s ync_state = neg_inv al id;
		res= async;
		}		break;
c a se EXTEN DED_ M ES S AGE:
		switch(dev- >sync_stat e ) {
		/*  We d on't acc ept synch r o nous tra nsf erreq ues t s .		 * Respondw i th a  M ESSAGE_ REJ ECT topre ven t a 
	 *  synchron ous tran sf er  a gr eem ent f r om being  r eac he d.		 */ 		case  neg_ inva li d: 		res = r e je c t ;
		b re ak;
	/*  We w eren otnegotia ting a sy nch r onou str ansfer, 
		 * but the  d evice sent  u s a  negot i a tion req uest.
		 * Honour the r e quest b y s endin g ba ck a SDTR 
	 * mes sag e  conta iningour c ap abi l i ty, l i m it edby 
		 * thet a rge ts ca pa bili ty.
		*/
		default:
			f a s21 6_cmd(info, C MD_ SETA T N ); 
	if (ms g[ 4 ] > i nfo->ifcfg.sync _max_depth )		msg[4] =i nfo -> ifcfg.s ync_max _dept h ;
			if  (msg[3]< 1000 /in fo-> i f cfg .clockrate )
				ms g[3] = 10 0 0 / i n fo ->ifc fg. clockr at e;
		

 *_at some_point performed a synchronous_transfer negotiation_request,_or
 *_we_have synchronous transfers_disabled for this_device.
 */

/**
 * fas216_handlesync_- Handle a_synchronous_transfer message
 * @info: state structure for interface
 * @msg: message from target
 *
_*_Handle a_synchronous_transfer_message from the target
 */
static_void fas216_handlesync(FAS216_Info *info, char *msg)
{
	struct_fas216_device *dev_= &info->device[info->SCpnt->device->id];
	enum { sync, async, none, reject }_res_= none;

#ifdef SCSI2_SYNC
	switch_(msg[0]) {
	case MESSAGE_REJECT:
		/* Synchronous transfer request failed.
		 * Note:_SCSI II r10:
		 *
		 * _SCSI devices that_are_capable_of synchronous
		 * _data transfers shall not respond to_an SDTR
		 *  message with_a MESSAGE REJECT message.
		 *
		 * Hence,_if we get this condition, we_disable
		 * negotiation for this_device.
		 */
		if_(dev->sync_state == neg_inprogress) {
			dev->sync_state =_neg_invalid;
			res = async;
		}
		break;

	case_EXTENDED_MESSAGE:
		switch (dev->sync_state)_{
		/* We don't_accept synchronous transfer requests.
		 * Respond_with a MESSAGE_REJECT_to prevent a
		 * synchronous transfer_agreement_from being reached.
		_*/
		case_neg_invalid:
			res_= reject;
			break;

		/*_We were not_negotiating_a synchronous_transfer,
		_* but the device sent us_a_negotiation request.
		 * Honour the request by_sending back a SDTR
		_*_message containing our capability,_limited by
		 * the targets_capability.
		 */
		default:
			fas216_cmd(info, CMD_SETATN);
			if (msg[4] > info->ifcfg.sync_max_depth)
				msg[4]_= info->ifcfg.sync_max_depth;
			if_(msg[3] <_1000 / info->ifcfg.clockrate)
				msg[3] = 1000 / info->ifcfg.clockrate;

		