462 lines · c
1/*2 * Management Module Support for MPT (Message Passing Technology) based3 * controllers4 *5 * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.h6 * Copyright (C) 2012-2014 LSI Corporation7 * Copyright (C) 2013-2014 Avago Technologies8 * (mailto: MPT-FusionLinux.pdl@avagotech.com)9 *10 * This program is free software; you can redistribute it and/or11 * modify it under the terms of the GNU General Public License12 * as published by the Free Software Foundation; either version 213 * of the License, or (at your option) any later version.14 *15 * This program is distributed in the hope that it will be useful,16 * but WITHOUT ANY WARRANTY; without even the implied warranty of17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the18 * GNU General Public License for more details.19 *20 * NO WARRANTY21 * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR22 * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT23 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,24 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is25 * solely responsible for determining the appropriateness of using and26 * distributing the Program and assumes all risks associated with its27 * exercise of rights under this Agreement, including but not limited to28 * the risks and costs of program errors, damage to or loss of data,29 * programs or equipment, and unavailability or interruption of operations.30 31 * DISCLAIMER OF LIABILITY32 * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY33 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL34 * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND35 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR36 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE37 * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED38 * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES39 40 * You should have received a copy of the GNU General Public License41 * along with this program; if not, write to the Free Software42 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,43 * USA.44 */45 46#ifndef MPT3SAS_CTL_H_INCLUDED47#define MPT3SAS_CTL_H_INCLUDED48 49#ifdef __KERNEL__50#include <linux/miscdevice.h>51#endif52 53#include "mpt3sas_base.h"54 55#ifndef MPT2SAS_MINOR56#define MPT2SAS_MINOR (MPT_MINOR + 1)57#endif58#ifndef MPT3SAS_MINOR59#define MPT3SAS_MINOR (MPT_MINOR + 2)60#endif61#define MPT2SAS_DEV_NAME "mpt2ctl"62#define MPT3SAS_DEV_NAME "mpt3ctl"63#define MPT3_MAGIC_NUMBER 'L'64#define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */65 66/**67 * IOCTL opcodes68 */69#define MPT3IOCINFO _IOWR(MPT3_MAGIC_NUMBER, 17, \70 struct mpt3_ioctl_iocinfo)71#define MPT3COMMAND _IOWR(MPT3_MAGIC_NUMBER, 20, \72 struct mpt3_ioctl_command)73#ifdef CONFIG_COMPAT74#define MPT3COMMAND32 _IOWR(MPT3_MAGIC_NUMBER, 20, \75 struct mpt3_ioctl_command32)76#endif77#define MPT3EVENTQUERY _IOWR(MPT3_MAGIC_NUMBER, 21, \78 struct mpt3_ioctl_eventquery)79#define MPT3EVENTENABLE _IOWR(MPT3_MAGIC_NUMBER, 22, \80 struct mpt3_ioctl_eventenable)81#define MPT3EVENTREPORT _IOWR(MPT3_MAGIC_NUMBER, 23, \82 struct mpt3_ioctl_eventreport)83#define MPT3HARDRESET _IOWR(MPT3_MAGIC_NUMBER, 24, \84 struct mpt3_ioctl_diag_reset)85#define MPT3BTDHMAPPING _IOWR(MPT3_MAGIC_NUMBER, 31, \86 struct mpt3_ioctl_btdh_mapping)87 88/* diag buffer support */89#define MPT3DIAGREGISTER _IOWR(MPT3_MAGIC_NUMBER, 26, \90 struct mpt3_diag_register)91#define MPT3DIAGRELEASE _IOWR(MPT3_MAGIC_NUMBER, 27, \92 struct mpt3_diag_release)93#define MPT3DIAGUNREGISTER _IOWR(MPT3_MAGIC_NUMBER, 28, \94 struct mpt3_diag_unregister)95#define MPT3DIAGQUERY _IOWR(MPT3_MAGIC_NUMBER, 29, \96 struct mpt3_diag_query)97#define MPT3DIAGREADBUFFER _IOWR(MPT3_MAGIC_NUMBER, 30, \98 struct mpt3_diag_read_buffer)99#define MPT3ADDNLDIAGQUERY _IOWR(MPT3_MAGIC_NUMBER, 32, \100 struct mpt3_addnl_diag_query)101#define MPT3ENABLEDIAGSBRRELOAD _IOWR(MPT3_MAGIC_NUMBER, 33, \102 struct mpt3_enable_diag_sbr_reload)103 104/* Trace Buffer default UniqueId */105#define MPT2DIAGBUFFUNIQUEID (0x07075900)106#define MPT3DIAGBUFFUNIQUEID (0x4252434D)107 108/* UID not found */109#define MPT3_DIAG_UID_NOT_FOUND (0xFF)110 111 112/**113 * struct mpt3_ioctl_header - main header structure114 * @ioc_number - IOC unit number115 * @port_number - IOC port number116 * @max_data_size - maximum number bytes to transfer on read117 */118struct mpt3_ioctl_header {119 uint32_t ioc_number;120 uint32_t port_number;121 uint32_t max_data_size;122};123 124/**125 * struct mpt3_ioctl_diag_reset - diagnostic reset126 * @hdr - generic header127 */128struct mpt3_ioctl_diag_reset {129 struct mpt3_ioctl_header hdr;130};131 132 133/**134 * struct mpt3_ioctl_pci_info - pci device info135 * @device - pci device id136 * @function - pci function id137 * @bus - pci bus id138 * @segment_id - pci segment id139 */140struct mpt3_ioctl_pci_info {141 union {142 struct {143 uint32_t device:5;144 uint32_t function:3;145 uint32_t bus:24;146 } bits;147 uint32_t word;148 } u;149 uint32_t segment_id;150};151 152 153#define MPT2_IOCTL_INTERFACE_SCSI (0x00)154#define MPT2_IOCTL_INTERFACE_FC (0x01)155#define MPT2_IOCTL_INTERFACE_FC_IP (0x02)156#define MPT2_IOCTL_INTERFACE_SAS (0x03)157#define MPT2_IOCTL_INTERFACE_SAS2 (0x04)158#define MPT2_IOCTL_INTERFACE_SAS2_SSS6200 (0x05)159#define MPT3_IOCTL_INTERFACE_SAS3 (0x06)160#define MPT3_IOCTL_INTERFACE_SAS35 (0x07)161#define MPT2_IOCTL_VERSION_LENGTH (32)162 163/**164 * struct mpt3_ioctl_iocinfo - generic controller info165 * @hdr - generic header166 * @adapter_type - type of adapter (spi, fc, sas)167 * @port_number - port number168 * @pci_id - PCI Id169 * @hw_rev - hardware revision170 * @sub_system_device - PCI subsystem Device ID171 * @sub_system_vendor - PCI subsystem Vendor ID172 * @rsvd0 - reserved173 * @firmware_version - firmware version174 * @bios_version - BIOS version175 * @driver_version - driver version - 32 ASCII characters176 * @rsvd1 - reserved177 * @scsi_id - scsi id of adapter 0178 * @rsvd2 - reserved179 * @pci_information - pci info (2nd revision)180 */181struct mpt3_ioctl_iocinfo {182 struct mpt3_ioctl_header hdr;183 uint32_t adapter_type;184 uint32_t port_number;185 uint32_t pci_id;186 uint32_t hw_rev;187 uint32_t subsystem_device;188 uint32_t subsystem_vendor;189 uint32_t rsvd0;190 uint32_t firmware_version;191 uint32_t bios_version;192 uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH];193 uint8_t rsvd1;194 uint8_t scsi_id;195 uint16_t rsvd2;196 struct mpt3_ioctl_pci_info pci_information;197};198 199 200/* number of event log entries */201#define MPT3SAS_CTL_EVENT_LOG_SIZE (200)202 203/**204 * struct mpt3_ioctl_eventquery - query event count and type205 * @hdr - generic header206 * @event_entries - number of events returned by get_event_report207 * @rsvd - reserved208 * @event_types - type of events currently being captured209 */210struct mpt3_ioctl_eventquery {211 struct mpt3_ioctl_header hdr;212 uint16_t event_entries;213 uint16_t rsvd;214 uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];215};216 217/**218 * struct mpt3_ioctl_eventenable - enable/disable event capturing219 * @hdr - generic header220 * @event_types - toggle off/on type of events to be captured221 */222struct mpt3_ioctl_eventenable {223 struct mpt3_ioctl_header hdr;224 uint32_t event_types[4];225};226 227#define MPT3_EVENT_DATA_SIZE (192)228/**229 * struct MPT3_IOCTL_EVENTS -230 * @event - the event that was reported231 * @context - unique value for each event assigned by driver232 * @data - event data returned in fw reply message233 */234struct MPT3_IOCTL_EVENTS {235 uint32_t event;236 uint32_t context;237 uint8_t data[MPT3_EVENT_DATA_SIZE];238};239 240/**241 * struct mpt3_ioctl_eventreport - returing event log242 * @hdr - generic header243 * @event_data - (see struct MPT3_IOCTL_EVENTS)244 */245struct mpt3_ioctl_eventreport {246 struct mpt3_ioctl_header hdr;247 struct MPT3_IOCTL_EVENTS event_data[1];248};249 250/**251 * struct mpt3_ioctl_command - generic mpt firmware passthru ioctl252 * @hdr - generic header253 * @timeout - command timeout in seconds. (if zero then use driver default254 * value).255 * @reply_frame_buf_ptr - reply location256 * @data_in_buf_ptr - destination for read257 * @data_out_buf_ptr - data source for write258 * @sense_data_ptr - sense data location259 * @max_reply_bytes - maximum number of reply bytes to be sent to app.260 * @data_in_size - number bytes for data transfer in (read)261 * @data_out_size - number bytes for data transfer out (write)262 * @max_sense_bytes - maximum number of bytes for auto sense buffers263 * @data_sge_offset - offset in words from the start of the request message to264 * the first SGL265 * @mf[1];266 */267struct mpt3_ioctl_command {268 struct mpt3_ioctl_header hdr;269 uint32_t timeout;270 void __user *reply_frame_buf_ptr;271 void __user *data_in_buf_ptr;272 void __user *data_out_buf_ptr;273 void __user *sense_data_ptr;274 uint32_t max_reply_bytes;275 uint32_t data_in_size;276 uint32_t data_out_size;277 uint32_t max_sense_bytes;278 uint32_t data_sge_offset;279 uint8_t mf[1];280};281 282#ifdef CONFIG_COMPAT283struct mpt3_ioctl_command32 {284 struct mpt3_ioctl_header hdr;285 uint32_t timeout;286 uint32_t reply_frame_buf_ptr;287 uint32_t data_in_buf_ptr;288 uint32_t data_out_buf_ptr;289 uint32_t sense_data_ptr;290 uint32_t max_reply_bytes;291 uint32_t data_in_size;292 uint32_t data_out_size;293 uint32_t max_sense_bytes;294 uint32_t data_sge_offset;295 uint8_t mf[1];296};297#endif298 299/**300 * struct mpt3_ioctl_btdh_mapping - mapping info301 * @hdr - generic header302 * @id - target device identification number303 * @bus - SCSI bus number that the target device exists on304 * @handle - device handle for the target device305 * @rsvd - reserved306 *307 * To obtain a bus/id the application sets308 * handle to valid handle, and bus/id to 0xFFFF.309 *310 * To obtain the device handle the application sets311 * bus/id valid value, and the handle to 0xFFFF.312 */313struct mpt3_ioctl_btdh_mapping {314 struct mpt3_ioctl_header hdr;315 uint32_t id;316 uint32_t bus;317 uint16_t handle;318 uint16_t rsvd;319};320 321 322 323/* application flags for mpt3_diag_register, mpt3_diag_query */324#define MPT3_APP_FLAGS_APP_OWNED (0x0001)325#define MPT3_APP_FLAGS_BUFFER_VALID (0x0002)326#define MPT3_APP_FLAGS_FW_BUFFER_ACCESS (0x0004)327#define MPT3_APP_FLAGS_DYNAMIC_BUFFER_ALLOC (0x0008)328 329/* flags for mpt3_diag_read_buffer */330#define MPT3_FLAGS_REREGISTER (0x0001)331 332#define MPT3_PRODUCT_SPECIFIC_DWORDS 23333 334/**335 * struct mpt3_diag_register - application register with driver336 * @hdr - generic header337 * @reserved -338 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED339 * @application_flags - misc flags340 * @diagnostic_flags - specifies flags affecting command processing341 * @product_specific - product specific information342 * @requested_buffer_size - buffers size in bytes343 * @unique_id - tag specified by application that is used to signal ownership344 * of the buffer.345 *346 * This will allow the driver to setup any required buffers that will be347 * needed by firmware to communicate with the driver.348 */349struct mpt3_diag_register {350 struct mpt3_ioctl_header hdr;351 uint8_t reserved;352 uint8_t buffer_type;353 uint16_t application_flags;354 uint32_t diagnostic_flags;355 uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];356 uint32_t requested_buffer_size;357 uint32_t unique_id;358};359 360/**361 * struct mpt3_diag_unregister - application unregister with driver362 * @hdr - generic header363 * @unique_id - tag uniquely identifies the buffer to be unregistered364 *365 * This will allow the driver to cleanup any memory allocated for diag366 * messages and to free up any resources.367 */368struct mpt3_diag_unregister {369 struct mpt3_ioctl_header hdr;370 uint32_t unique_id;371};372 373/**374 * struct mpt3_diag_query - query relevant info associated with diag buffers375 * @hdr - generic header376 * @reserved -377 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED378 * @application_flags - misc flags379 * @diagnostic_flags - specifies flags affecting command processing380 * @product_specific - product specific information381 * @total_buffer_size - diag buffer size in bytes382 * @driver_added_buffer_size - size of extra space appended to end of buffer383 * @unique_id - unique id associated with this buffer.384 *385 * The application will send only buffer_type and unique_id. Driver will386 * inspect unique_id first, if valid, fill in all the info. If unique_id is387 * 0x00, the driver will return info specified by Buffer Type.388 */389struct mpt3_diag_query {390 struct mpt3_ioctl_header hdr;391 uint8_t reserved;392 uint8_t buffer_type;393 uint16_t application_flags;394 uint32_t diagnostic_flags;395 uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];396 uint32_t total_buffer_size;397 uint32_t driver_added_buffer_size;398 uint32_t unique_id;399};400 401/**402 * struct mpt3_diag_release - request to send Diag Release Message to firmware403 * @hdr - generic header404 * @unique_id - tag uniquely identifies the buffer to be released405 *406 * This allows ownership of the specified buffer to returned to the driver,407 * allowing an application to read the buffer without fear that firmware is408 * overwriting information in the buffer.409 */410struct mpt3_diag_release {411 struct mpt3_ioctl_header hdr;412 uint32_t unique_id;413};414 415/**416 * struct mpt3_diag_read_buffer - request for copy of the diag buffer417 * @hdr - generic header418 * @status -419 * @reserved -420 * @flags - misc flags421 * @starting_offset - starting offset within drivers buffer where to start422 * reading data at into the specified application buffer423 * @bytes_to_read - number of bytes to copy from the drivers buffer into the424 * application buffer starting at starting_offset.425 * @unique_id - unique id associated with this buffer.426 * @diagnostic_data - data payload427 */428struct mpt3_diag_read_buffer {429 struct mpt3_ioctl_header hdr;430 uint8_t status;431 uint8_t reserved;432 uint16_t flags;433 uint32_t starting_offset;434 uint32_t bytes_to_read;435 uint32_t unique_id;436 uint32_t diagnostic_data[1];437};438 439/**440 * struct mpt3_addnl_diag_query - diagnostic buffer release reason441 * @hdr - generic header442 * @unique_id - unique id associated with this buffer.443 * @rel_query - release query.444 * @reserved2445 */446struct mpt3_addnl_diag_query {447 struct mpt3_ioctl_header hdr;448 uint32_t unique_id;449 struct htb_rel_query rel_query;450 uint32_t reserved2[2];451};452 453/**454 * struct mpt3_enable_diag_sbr_reload - enable sbr reload455 * @hdr - generic header456 */457struct mpt3_enable_diag_sbr_reload {458 struct mpt3_ioctl_header hdr;459};460 461#endif /* MPT3SAS_CTL_H_INCLUDED */462