11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Block OSM structures/API 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Copyright (C) 1999-2002 Red Hat Software 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Written by Alan Cox, Building Number Three Ltd 71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This program is free software; you can redistribute it and/or modify it 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * under the terms of the GNU General Public License as published by the 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Free Software Foundation; either version 2 of the License, or (at your 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * option) any later version. 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This program is distributed in the hope that it will be useful, but 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * WITHOUT ANY WARRANTY; without even the implied warranty of 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * General Public License for more details. 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * For the purpose of avoiding doubt the preferred form of the work 191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * for making modifications shall be a standards compliant form such 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * gzipped tar and not one requiring a proprietary or patent encumbered 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * tool to unpack. 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Fixes/additions: 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Steve Ralston: 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Multiple device handling error fixes, 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Added a queue depth. 271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Alan Cox: 281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FC920 has an rmw bug. Dont or in the end marker. 291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Removed queue walk, fixed for 64bitness. 301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Rewrote much of the code over time 311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Added indirect block lists 321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Handle 64K limits on many controllers 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Don't use indirects on the Promise (breaks) 341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Heavily chop down the queue depths 351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Deepak Saxena: 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Independent queues per IOP 371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Support for dynamic device creation/deletion 381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Code cleanup 391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Support for larger I/Os through merge* functions 401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * (taken from DAC960 driver) 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Boji T Kannanthanam: 421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Set the I2O Block devices to be detected in increasing 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * order of TIDs during boot. 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Search and set the I2O block device that we boot off 451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * from as the first device to be claimed (as /dev/i2o/hda) 461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Properly attach/detach I2O gendisk structure from the 471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * system gendisk list. The I2O block devices now appear in 481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * /proc/partitions. 491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Markus Lidel <Markus.Lidel@shadowconnect.com>: 501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Minor bugfixes for 2.6. 511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef I2O_BLOCK_OSM_H 541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define I2O_BLOCK_OSM_H 551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define I2O_BLOCK_RETRY_TIME HZ/4 571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define I2O_BLOCK_MAX_OPEN_REQUESTS 50 581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 59b2aaee33fbb354a2f08121aa1c1be55841102761Markus Lidel/* request queue sizes */ 60b2aaee33fbb354a2f08121aa1c1be55841102761Markus Lidel#define I2O_BLOCK_REQ_MEMPOOL_SIZE 32 61b2aaee33fbb354a2f08121aa1c1be55841102761Markus Lidel 62b2aaee33fbb354a2f08121aa1c1be55841102761Markus Lidel#define KERNEL_SECTOR_SHIFT 9 63b2aaee33fbb354a2f08121aa1c1be55841102761Markus Lidel#define KERNEL_SECTOR_SIZE (1 << KERNEL_SECTOR_SHIFT) 64b2aaee33fbb354a2f08121aa1c1be55841102761Markus Lidel 651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* I2O Block OSM mempool struct */ 661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct i2o_block_mempool { 67e18b890bb0881bbab6f4f1a6cd20d9c60d66b003Christoph Lameter struct kmem_cache *slab; 68f33213ecf49c98da4e85121b592c3bea8057c2e6Markus Lidel mempool_t *pool; 691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* I2O Block device descriptor */ 721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct i2o_block_device { 731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct i2o_device *i2o_dev; /* pointer to I2O device */ 741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct gendisk *gd; 75f33213ecf49c98da4e85121b592c3bea8057c2e6Markus Lidel spinlock_t lock; /* queue lock */ 7625985edcedea6396277003854657b5f3cb31a628Lucas De Marchi struct list_head open_queue; /* list of transferred, but unfinished 771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds requests */ 781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int open_queue_depth; /* number of requests in the queue */ 791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 80f33213ecf49c98da4e85121b592c3bea8057c2e6Markus Lidel int rcache; /* read cache flags */ 81f33213ecf49c98da4e85121b592c3bea8057c2e6Markus Lidel int wcache; /* write cache flags */ 821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int flags; 83f33213ecf49c98da4e85121b592c3bea8057c2e6Markus Lidel u16 power; /* power state */ 84f33213ecf49c98da4e85121b592c3bea8057c2e6Markus Lidel int media_change_flag; /* media changed flag */ 851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* I2O Block device request */ 88f33213ecf49c98da4e85121b592c3bea8057c2e6Markus Lidelstruct i2o_block_request { 891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct list_head queue; 90f33213ecf49c98da4e85121b592c3bea8057c2e6Markus Lidel struct request *req; /* corresponding request */ 911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct i2o_block_device *i2o_blk_dev; /* I2O block device */ 92f33213ecf49c98da4e85121b592c3bea8057c2e6Markus Lidel struct device *dev; /* device used for DMA */ 93f33213ecf49c98da4e85121b592c3bea8057c2e6Markus Lidel int sg_nents; /* number of SG elements */ 94f33213ecf49c98da4e85121b592c3bea8057c2e6Markus Lidel struct scatterlist sg_table[I2O_MAX_PHYS_SEGMENTS]; /* SG table */ 951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* I2O Block device delayed request */ 98f33213ecf49c98da4e85121b592c3bea8057c2e6Markus Lidelstruct i2o_block_delayed_request { 99c4028958b6ecad064b1a6303a6a5906d4fe48d73David Howells struct delayed_work work; 1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct request_queue *queue; 1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 1021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 104