Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is provided under a dual BSD/GPLv2 license.  When using or
0003  * redistributing this file, you may do so under either license.
0004  *
0005  * GPL LICENSE SUMMARY
0006  *
0007  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
0008  *
0009  * This program is free software; you can redistribute it and/or modify
0010  * it under the terms of version 2 of the GNU General Public License as
0011  * published by the Free Software Foundation.
0012  *
0013  * This program is distributed in the hope that it will be useful, but
0014  * WITHOUT ANY WARRANTY; without even the implied warranty of
0015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016  * General Public License for more details.
0017  *
0018  * You should have received a copy of the GNU General Public License
0019  * along with this program; if not, write to the Free Software
0020  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
0021  * The full GNU General Public License is included in this distribution
0022  * in the file called LICENSE.GPL.
0023  *
0024  * BSD LICENSE
0025  *
0026  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
0027  * All rights reserved.
0028  *
0029  * Redistribution and use in source and binary forms, with or without
0030  * modification, are permitted provided that the following conditions
0031  * are met:
0032  *
0033  *   * Redistributions of source code must retain the above copyright
0034  *     notice, this list of conditions and the following disclaimer.
0035  *   * Redistributions in binary form must reproduce the above copyright
0036  *     notice, this list of conditions and the following disclaimer in
0037  *     the documentation and/or other materials provided with the
0038  *     distribution.
0039  *   * Neither the name of Intel Corporation nor the names of its
0040  *     contributors may be used to endorse or promote products derived
0041  *     from this software without specific prior written permission.
0042  *
0043  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0044  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0045  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0046  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0047  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0048  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0049  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0050  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0051  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0052  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0053  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0054  */
0055 
0056 #ifndef _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
0057 #define _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_
0058 
0059 #include "isci.h"
0060 
0061 #define SCU_UNSOLICITED_FRAME_HEADER_DATA_DWORDS 15
0062 
0063 /**
0064  * struct scu_unsolicited_frame_header -
0065  *
0066  * This structure delineates the format of an unsolicited frame header. The
0067  * first DWORD are UF attributes defined by the silicon architecture. The data
0068  * depicts actual header information received on the link.
0069  */
0070 struct scu_unsolicited_frame_header {
0071     /**
0072      * This field indicates if there is an Initiator Index Table entry with
0073      * which this header is associated.
0074      */
0075     u32 iit_exists:1;
0076 
0077     /**
0078      * This field simply indicates the protocol type (i.e. SSP, STP, SMP).
0079      */
0080     u32 protocol_type:3;
0081 
0082     /**
0083      * This field indicates if the frame is an address frame (IAF or OAF)
0084      * or if it is a information unit frame.
0085      */
0086     u32 is_address_frame:1;
0087 
0088     /**
0089      * This field simply indicates the connection rate at which the frame
0090      * was received.
0091      */
0092     u32 connection_rate:4;
0093 
0094     u32 reserved:23;
0095 
0096     /**
0097      * This field represents the actual header data received on the link.
0098      */
0099     u32 data[SCU_UNSOLICITED_FRAME_HEADER_DATA_DWORDS];
0100 
0101 };
0102 
0103 
0104 
0105 /**
0106  * enum unsolicited_frame_state -
0107  *
0108  * This enumeration represents the current unsolicited frame state.  The
0109  * controller object can not updtate the hardware unsolicited frame put pointer
0110  * unless it has already processed the priror unsolicited frames.
0111  */
0112 enum unsolicited_frame_state {
0113     /**
0114      * This state is when the frame is empty and not in use.  It is
0115      * different from the released state in that the hardware could DMA
0116      * data to this frame buffer.
0117      */
0118     UNSOLICITED_FRAME_EMPTY,
0119 
0120     /**
0121      * This state is set when the frame buffer is in use by by some
0122      * object in the system.
0123      */
0124     UNSOLICITED_FRAME_IN_USE,
0125 
0126     /**
0127      * This state is set when the frame is returned to the free pool
0128      * but one or more frames prior to this one are still in use.
0129      * Once all of the frame before this one are freed it will go to
0130      * the empty state.
0131      */
0132     UNSOLICITED_FRAME_RELEASED,
0133 
0134     UNSOLICITED_FRAME_MAX_STATES
0135 };
0136 
0137 /**
0138  * struct sci_unsolicited_frame -
0139  *
0140  * This is the unsolicited frame data structure it acts as the container for
0141  * the current frame state, frame header and frame buffer.
0142  */
0143 struct sci_unsolicited_frame {
0144     /**
0145      * This field contains the current frame state
0146      */
0147     enum unsolicited_frame_state state;
0148 
0149     /**
0150      * This field points to the frame header data.
0151      */
0152     struct scu_unsolicited_frame_header *header;
0153 
0154     /**
0155      * This field points to the frame buffer data.
0156      */
0157     void *buffer;
0158 
0159 };
0160 
0161 /**
0162  * struct sci_uf_header_array -
0163  *
0164  * This structure contains all of the unsolicited frame header information.
0165  */
0166 struct sci_uf_header_array {
0167     /**
0168      * This field is represents a virtual pointer to the start
0169      * address of the UF address table.  The table contains
0170      * 64-bit pointers as required by the hardware.
0171      */
0172     struct scu_unsolicited_frame_header *array;
0173 
0174     /**
0175      * This field specifies the physical address location for the UF
0176      * buffer array.
0177      */
0178     dma_addr_t physical_address;
0179 
0180 };
0181 
0182 /**
0183  * struct sci_uf_buffer_array -
0184  *
0185  * This structure contains all of the unsolicited frame buffer (actual payload)
0186  * information.
0187  */
0188 struct sci_uf_buffer_array {
0189     /**
0190      * This field is the unsolicited frame data its used to manage
0191      * the data for the unsolicited frame requests.  It also represents
0192      * the virtual address location that corresponds to the
0193      * physical_address field.
0194      */
0195     struct sci_unsolicited_frame array[SCU_MAX_UNSOLICITED_FRAMES];
0196 
0197     /**
0198      * This field specifies the physical address location for the UF
0199      * buffer array.
0200      */
0201     dma_addr_t physical_address;
0202 };
0203 
0204 /**
0205  * struct sci_uf_address_table_array -
0206  *
0207  * This object maintains all of the unsolicited frame address table specific
0208  * data.  The address table is a collection of 64-bit pointers that point to
0209  * 1KB buffers into which the silicon will DMA unsolicited frames.
0210  */
0211 struct sci_uf_address_table_array {
0212     /**
0213      * This field represents a virtual pointer that refers to the
0214      * starting address of the UF address table.
0215      * 64-bit pointers are required by the hardware.
0216      */
0217     u64 *array;
0218 
0219     /**
0220      * This field specifies the physical address location for the UF
0221      * address table.
0222      */
0223     dma_addr_t physical_address;
0224 
0225 };
0226 
0227 /**
0228  * struct sci_unsolicited_frame_control -
0229  *
0230  * This object contains all of the data necessary to handle unsolicited frames.
0231  */
0232 struct sci_unsolicited_frame_control {
0233     /**
0234      * This field is the software copy of the unsolicited frame queue
0235      * get pointer.  The controller object writes this value to the
0236      * hardware to let the hardware put more unsolicited frame entries.
0237      */
0238     u32 get;
0239 
0240     /**
0241      * This field contains all of the unsolicited frame header
0242      * specific fields.
0243      */
0244     struct sci_uf_header_array headers;
0245 
0246     /**
0247      * This field contains all of the unsolicited frame buffer
0248      * specific fields.
0249      */
0250     struct sci_uf_buffer_array buffers;
0251 
0252     /**
0253      * This field contains all of the unsolicited frame address table
0254      * specific fields.
0255      */
0256     struct sci_uf_address_table_array address_table;
0257 
0258 };
0259 
0260 #define SCI_UFI_BUF_SIZE (SCU_MAX_UNSOLICITED_FRAMES * SCU_UNSOLICITED_FRAME_BUFFER_SIZE)
0261 #define SCI_UFI_HDR_SIZE (SCU_MAX_UNSOLICITED_FRAMES * sizeof(struct scu_unsolicited_frame_header))
0262 #define SCI_UFI_TOTAL_SIZE (SCI_UFI_BUF_SIZE + SCI_UFI_HDR_SIZE + SCU_MAX_UNSOLICITED_FRAMES * sizeof(u64))
0263 
0264 struct isci_host;
0265 
0266 void sci_unsolicited_frame_control_construct(struct isci_host *ihost);
0267 
0268 enum sci_status sci_unsolicited_frame_control_get_header(
0269     struct sci_unsolicited_frame_control *uf_control,
0270     u32 frame_index,
0271     void **frame_header);
0272 
0273 enum sci_status sci_unsolicited_frame_control_get_buffer(
0274     struct sci_unsolicited_frame_control *uf_control,
0275     u32 frame_index,
0276     void **frame_buffer);
0277 
0278 bool sci_unsolicited_frame_control_release_frame(
0279     struct sci_unsolicited_frame_control *uf_control,
0280     u32 frame_index);
0281 
0282 #endif /* _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ */