FreeBSD/sys/cam/ctl/ctl.c
/*
 * Note that this function currently doesn't actually do anything inside
 * CTL to enforce things if the DQue bit is turned on.
 *
 * Also note that this function can't be used in the default case, because
 * the DQue bit isn't set in the changeable mask for the control mode page
 * anyway.  This is just here as an example for how to implement a page
 * handler, and a placeholder in case we want to allow the user to turn
 * tagged queueing on and off.
 *
 * The D_SENSE bit handling is functional, however, and will turn
 * descriptor sense on and off for a given LUN.
 */
Note that this function currently doesn't actually do anything inside
CTL to enforce things if the DQue bit is turned on.

Also note that this function can't be used in the default case, because
the DQue bit isn't set in the changeable mask for the control mode page
anyway.  This is just here as an example for how to implement a page
handler, and a placeholder in case we want to allow the user to turn
tagged queueing on and off.

The D_SENSE bit handling is functional, however, and will turn
descriptor sense on and off for a given LUN.
Note that this function currently doesn ' t actually do anything inside CTL to enforce things if the DQue bit is turned on . Also note that this function can ' t be used in the default case because the DQue bit isn ' t set in the changeable mask for the control mode page anyway . This is just here as an example for how to implement a page handler and a placeholder in case we want to allow the user to turn tagged queueing on and off . The D_SENSE bit handling is functional however and will turn descriptor sense on and off for a given LUN .
int
ctl_control_page_handler(struct ctl_scsiio *ctsio,
			 struct ctl_page_index *page_index, uint8_t *page_ptr)
{
	struct scsi_control_page *current_cp, *saved_cp, *user_cp;
	struct ctl_lun *lun;
	int set_ua;
	uint32_t initidx;
	lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
	initidx = ctl_get_initindex(&ctsio->io_hdr.nexus);
	set_ua = 0;
	user_cp = (struct scsi_control_page *)page_ptr;
	current_cp = (struct scsi_control_page *)
		(page_index->page_data + (page_index->page_len *
		CTL_PAGE_CURRENT));
	saved_cp = (struct scsi_control_page *)
		(page_index->page_data + (page_index->page_len *
		CTL_PAGE_SAVED));
	mtx_lock(&lun->lun_lock);
	if (((current_cp->rlec & SCP_DSENSE) == 0)
	 && ((user_cp->rlec & SCP_DSENSE) != 0)) {
		current_cp->rlec |= SCP_DSENSE;
		saved_cp->rlec |= SCP_DSENSE;
		lun->flags |= CTL_LUN_SENSE_DESC;
		set_ua = 1;
	} else if (((current_cp->rlec & SCP_DSENSE) != 0)
		&& ((user_cp->rlec & SCP_DSENSE) == 0)) {
		current_cp->rlec &= ~SCP_DSENSE;
		saved_cp->rlec &= ~SCP_DSENSE;
		lun->flags &= ~CTL_LUN_SENSE_DESC;
		set_ua = 1;
	}
	if ((current_cp->queue_flags & SCP_QUEUE_ALG_MASK) !=
	    (user_cp->queue_flags & SCP_QUEUE_ALG_MASK)) {
		current_cp->queue_flags &= ~SCP_QUEUE_ALG_MASK;
		current_cp->queue_flags |= user_cp->queue_flags & SCP_QUEUE_ALG_MASK;
		saved_cp->queue_flags &= ~SCP_QUEUE_ALG_MASK;
		saved_cp->queue_flags |= user_cp->queue_flags & SCP_QUEUE_ALG_MASK;
		set_ua = 1;
	}
	if ((current_cp->eca_and_aen & SCP_SWP) !=
	    (user_cp->eca_and_aen & SCP_SWP)) {
		current_cp->eca_and_aen &= ~SCP_SWP;
		current_cp->eca_and_aen |= user_cp->eca_and_aen & SCP_SWP;
		saved_cp->eca_and_aen &= ~SCP_SWP;
		saved_cp->eca_and_aen |= user_cp->eca_and_aen & SCP_SWP;
		set_ua = 1;
	}
	if (set_ua != 0)
		ctl_est_ua_all(lun, initidx, CTL_UA_MODE_CHANGE);
	mtx_unlock(&lun->lun_lock);
	if (set_ua) {
		ctl_isc_announce_mode(lun,
		    ctl_get_initindex(&ctsio->io_hdr.nexus),
		    page_index->page_code, page_index->subpage);
	}
	return (0);
}
int ctl_control_page_handler ( struct ctl_scsiio * ctsio , struct ctl_page_index * page_index , uint8_t * page_ptr ) { struct scsi_control_page * current_cp , * saved_cp , * user_cp ; struct ctl_lun * lun ; int set_ua ; uint32_t initidx ; lun = ( struct ctl_lun * ) ctsio -> io_hdr . ctl_private [ CTL_PRIV_LUN ] . ptr ; initidx = ctl_get_initindex ( & ctsio -> io_hdr . nexus ) ; set_ua = 0 ; user_cp = ( struct scsi_control_page * ) page_ptr ; current_cp = ( struct scsi_control_page * ) ( page_index -> page_data + ( page_index -> page_len * CTL_PAGE_CURRENT ) ) ; saved_cp = ( struct scsi_control_page * ) ( page_index -> page_data + ( page_index -> page_len * CTL_PAGE_SAVED ) ) ; mtx_lock ( & lun -> lun_lock ) ; if ( ( ( current_cp -> rlec & SCP_DSENSE ) == 0 ) && ( ( user_cp -> rlec & SCP_DSENSE ) != 0 ) ) { current_cp -> rlec |= SCP_DSENSE ; saved_cp -> rlec |= SCP_DSENSE ; lun -> flags |= CTL_LUN_SENSE_DESC ; set_ua = 1 ; } else if ( ( ( current_cp -> rlec & SCP_DSENSE ) != 0 ) && ( ( user_cp -> rlec & SCP_DSENSE ) == 0 ) ) { current_cp -> rlec &= ~ SCP_DSENSE ; saved_cp -> rlec &= ~ SCP_DSENSE ; lun -> flags &= ~ CTL_LUN_SENSE_DESC ; set_ua = 1 ; } if ( ( current_cp -> queue_flags & SCP_QUEUE_ALG_MASK ) != ( user_cp -> queue_flags & SCP_QUEUE_ALG_MASK ) ) { current_cp -> queue_flags &= ~ SCP_QUEUE_ALG_MASK ; current_cp -> queue_flags |= user_cp -> queue_flags & SCP_QUEUE_ALG_MASK ; saved_cp -> queue_flags &= ~ SCP_QUEUE_ALG_MASK ; saved_cp -> queue_flags |= user_cp -> queue_flags & SCP_QUEUE_ALG_MASK ; set_ua = 1 ; } if ( ( current_cp -> eca_and_aen & SCP_SWP ) != ( user_cp -> eca_and_aen & SCP_SWP ) ) { current_cp -> eca_and_aen &= ~ SCP_SWP ; current_cp -> eca_and_aen |= user_cp -> eca_and_aen & SCP_SWP ; saved_cp -> eca_and_aen &= ~ SCP_SWP ; saved_cp -> eca_and_aen |= user_cp -> eca_and_aen & SCP_SWP ; set_ua = 1 ; } if ( set_ua != 0 ) ctl_est_ua_all ( lun , initidx , CTL_UA_MODE_CHANGE ) ; mtx_unlock ( & lun -> lun_lock ) ; if ( set_ua ) { ctl_isc_announce_mode ( lun , ctl_get_initindex ( & ctsio -> io_hdr . nexus ) , page_index -> page_code , page_index -> subpage ) ; } return ( 0 ) ; }
Note that this function currently doesn't actually do anything inside
 CTL to enforce things if the DQue bit is turned on.
Note that this function currently doesn ' t actually do anything inside CTL to enforce things if the DQue bit is turned on .
/*
		 * Descriptor sense is currently turned off and the user
		 * wants to turn it on.
		 */ /*
		 * Descriptor sense is currently turned on, and the user
		 * wants to turn it off.
		 */