2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 #include <sys/cdefs.h>
54 __FBSDID("$FreeBSD$");
59 * @brief This file contains all of method implementations specific to
60 * the high priority request queue (HPRQ). See the
61 * scif_sas_high_priority_request_queue.h file for additional
65 #include <dev/isci/scil/scif_sas_high_priority_request_queue.h>
67 #include <dev/isci/scil/scif_sas_logger.h>
68 #include <dev/isci/scil/scif_sas_io_request.h>
69 #include <dev/isci/scil/scif_sas_controller.h>
72 * @brief This method initializes the fields of the HPRQ. It should be
73 * called during the construction of the object containing or
74 * utilizing it (i.e. SCIF_SAS_CONTROLLER).
76 * @param[in] fw_hprq This parameter specific the high priority request
77 * queue object being constructed.
81 void scif_sas_high_priority_request_queue_construct(
82 SCIF_SAS_HIGH_PRIORITY_REQUEST_QUEUE_T * fw_hprq,
83 SCI_BASE_LOGGER_T * logger
88 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_DOMAIN_DISCOVERY,
89 "scif_sas_high_priority_request_queue_construct(0x%x,0x%x) enter\n",
93 sci_base_object_construct((SCI_BASE_OBJECT_T*) &fw_hprq->lock, logger);
94 fw_hprq->lock.level = SCI_LOCK_LEVEL_NONE;
96 sci_pool_initialize(fw_hprq->pool);
100 * @brief This method will ensure all internal requests destined for
101 * devices contained in the supplied domain are properly removed
102 * from the high priority request queue.
104 * @param[in] fw_hprq This parameter specifies the high priority request
105 * queue object for which to attempt to remove elements.
106 * @param[in] fw_domain This parameter specifies the domain for which to
107 * remove all high priority requests.
111 void scif_sas_high_priority_request_queue_purge_domain(
112 SCIF_SAS_HIGH_PRIORITY_REQUEST_QUEUE_T * fw_hprq,
113 SCIF_SAS_DOMAIN_T * fw_domain
116 SCIF_SAS_IO_REQUEST_T * fw_io;
117 POINTER_UINT io_address;
122 sci_base_object_get_logger(&fw_hprq->lock),
123 SCIF_LOG_OBJECT_CONTROLLER | SCIF_LOG_OBJECT_DOMAIN_DISCOVERY,
124 "scif_sas_high_priority_request_queue_purge_domain(0x%x,0x%x) enter\n",
128 element_count = sci_pool_count(fw_hprq->pool);
130 scif_cb_lock_acquire(fw_domain->controller, &fw_hprq->lock);
132 for (index = 0; index < element_count; index++)
134 sci_pool_get(fw_hprq->pool, io_address);
136 fw_io = (SCIF_SAS_IO_REQUEST_T*) io_address;
138 // If the high priority request is not intended for this domain,
139 // then it can be left in the pool.
140 if (fw_io->parent.device->domain != fw_domain)
142 sci_pool_put(fw_hprq->pool, io_address);
146 if (fw_io->parent.is_internal)
148 SCIF_SAS_INTERNAL_IO_REQUEST_T * fw_internal_io =
149 (SCIF_SAS_INTERNAL_IO_REQUEST_T *)fw_io;
151 // The request was intended for a device in the domain. Put it
152 // back in the pool of freely available internal request memory
153 // objects. The internal IO's timer is to be destoyed.
154 scif_sas_internal_io_request_destruct(fw_domain->controller, fw_internal_io);
159 scif_cb_lock_release(fw_domain->controller, &fw_hprq->lock);