sati_lun_reset.c revision 230557
1178825Sdfr/*-
2233294Sstas * This file is provided under a dual BSD/GPLv2 license.  When using or
3233294Sstas * redistributing this file, you may do so under either license.
4233294Sstas *
5178825Sdfr * GPL LICENSE SUMMARY
6233294Sstas *
7233294Sstas * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8233294Sstas *
9178825Sdfr * This program is free software; you can redistribute it and/or modify
10233294Sstas * it under the terms of version 2 of the GNU General Public License as
11233294Sstas * published by the Free Software Foundation.
12178825Sdfr *
13233294Sstas * This program is distributed in the hope that it will be useful, but
14233294Sstas * WITHOUT ANY WARRANTY; without even the implied warranty of
15233294Sstas * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16178825Sdfr * General Public License for more details.
17233294Sstas *
18233294Sstas * You should have received a copy of the GNU General Public License
19233294Sstas * along with this program; if not, write to the Free Software
20178825Sdfr * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21233294Sstas * The full GNU General Public License is included in this distribution
22233294Sstas * in the file called LICENSE.GPL.
23233294Sstas *
24233294Sstas * BSD LICENSE
25233294Sstas *
26233294Sstas * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27233294Sstas * All rights reserved.
28233294Sstas *
29233294Sstas * Redistribution and use in source and binary forms, with or without
30233294Sstas * modification, are permitted provided that the following conditions
31233294Sstas * are met:
32178825Sdfr *
33178825Sdfr *   * Redistributions of source code must retain the above copyright
34178825Sdfr *     notice, this list of conditions and the following disclaimer.
35178825Sdfr *   * Redistributions in binary form must reproduce the above copyright
36178825Sdfr *     notice, this list of conditions and the following disclaimer in
37233294Sstas *     the documentation and/or other materials provided with the
38233294Sstas *     distribution.
39178825Sdfr *
40178825Sdfr * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41178825Sdfr * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42178825Sdfr * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43178825Sdfr * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44178825Sdfr * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45178825Sdfr * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46178825Sdfr * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47178825Sdfr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48178825Sdfr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49233294Sstas * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50178825Sdfr * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51178825Sdfr */
52178825Sdfr
53178825Sdfr#include <sys/cdefs.h>
54178825Sdfr__FBSDID("$FreeBSD$");
55178825Sdfr
56178825Sdfr/**
57233294Sstas * @file
58178825Sdfr *
59178825Sdfr * @brief This file contains the method implementations required to
60178825Sdfr *        translate the SCSI lun reset command.
61178825Sdfr */
62178825Sdfr
63178825Sdfr#if !defined(DISABLE_SATI_TASK_MANAGEMENT)
64178825Sdfr
65233294Sstas#include <dev/isci/scil/sati_lun_reset.h>
66178825Sdfr#include <dev/isci/scil/sati_callbacks.h>
67178825Sdfr#include <dev/isci/scil/sati_util.h>
68178825Sdfr#include <dev/isci/scil/intel_ata.h>
69178825Sdfr#include <dev/isci/scil/intel_scsi.h>
70178825Sdfr#include <dev/isci/scil/intel_sat.h>
71178825Sdfr
72178825Sdfr//******************************************************************************
73178825Sdfr//* P U B L I C   M E T H O D S
74178825Sdfr//******************************************************************************
75178825Sdfr
76178825Sdfr/**
77178825Sdfr * @brief This method will translate the lun reset SCSI task request into an
78178825Sdfr *        ATA SOFT RESET command. For more information on the parameters
79233294Sstas *        passed to this method, please reference sati_translate_command().
80178825Sdfr *
81178825Sdfr * @return Indicate if the command translation succeeded.
82178825Sdfr * @retval SCI_SUCCESS This is returned if the command translation was
83178825Sdfr *         successful.
84178825Sdfr *
85178825Sdfr * @note It is up to the user of the sata translator to set the command bit
86233294Sstas *       and clear the control softreset bit and send the second register fis.
87233294Sstas */
88178825SdfrSATI_STATUS sati_lun_reset_translate_command(
89178825Sdfr   SATI_TRANSLATOR_SEQUENCE_T * sequence,
90178825Sdfr   void                       * scsi_io,
91178825Sdfr   void                       * ata_io
92178825Sdfr)
93178825Sdfr{
94178825Sdfr   U8* register_fis = sati_cb_get_h2d_register_fis_address(ata_io);
95178825Sdfr
96178825Sdfr   sati_set_ata_command(register_fis, ATA_NOP);
97178825Sdfr   sati_set_ata_control(register_fis, ATA_CONTROL_REG_SOFT_RESET_BIT);
98178825Sdfr
99233294Sstas   //set all other fields to zero.
100178825Sdfr   sati_clear_sata_command_flag(register_fis);
101178825Sdfr   sati_set_ata_features(register_fis, 0);
102233294Sstas   sati_set_ata_features_exp(register_fis, 0);
103178825Sdfr   sati_set_ata_sector_count(register_fis, 0);
104178825Sdfr   sati_set_ata_sector_count_exp(register_fis, 0);
105178825Sdfr   sati_set_ata_lba_low(register_fis, 0);
106178825Sdfr   sati_set_ata_lba_mid(register_fis, 0);
107178825Sdfr   sati_set_ata_lba_high(register_fis, 0);
108178825Sdfr   sati_set_ata_lba_low_exp(register_fis, 0);
109233294Sstas   sati_set_ata_lba_mid_exp(register_fis, 0);
110178825Sdfr   sati_set_ata_lba_high_exp(register_fis, 0);
111178825Sdfr   sati_set_ata_device_head(register_fis, 0);
112178825Sdfr
113233294Sstas   sequence->type                = SATI_SEQUENCE_LUN_RESET;
114178825Sdfr   sequence->data_direction      = SATI_DATA_DIRECTION_NONE;
115178825Sdfr   sequence->protocol            = SAT_PROTOCOL_SOFT_RESET;
116178825Sdfr   sequence->ata_transfer_length = 0;
117178825Sdfr
118178825Sdfr   return SATI_SUCCESS;
119233294Sstas}
120178825Sdfr
121178825Sdfr#endif // !defined(DISABLE_SATI_TASK_MANAGEMENT)
122178825Sdfr
123178825Sdfr