10 #include <linux/kernel.h>
11 #include <linux/string.h>
12 #include <linux/types.h>
13 #include <linux/errno.h>
14 #include <linux/bitops.h>
23 #define PGID_RETRIES 256
24 #define PGID_TIMEOUT (10 * HZ)
39 if (sch->
config.mp != mpath) {
44 CIO_MSG_EVENT(2,
"vrfy: device 0.%x.%04x: rc=%d pgroup=%d mpath=%d "
45 "vpm=%02x\n", id->
ssid, id->
devno, rc, pgroup, mpath,
82 verify_done(cdev, sch->
vpm ? 0 : -
EACCES);
100 static void nop_callback(
struct ccw_device *cdev,
void *data,
int rc)
114 verify_done(cdev, rc);
130 cp->
count =
sizeof(*pgid);
153 if (cdev->
private->flags.mpath)
155 spid_build_cp(cdev, fn);
160 verify_done(cdev, sch->
vpm ? 0 : -
EACCES);
163 static void verify_start(
struct ccw_device *cdev);
168 static void spid_callback(
struct ccw_device *cdev,
void *data,
int rc)
180 if (cdev->
private->flags.mpath) {
182 cdev->
private->flags.mpath = 0;
186 cdev->
private->flags.pgroup = 0;
199 verify_done(cdev, rc);
202 static void spid_start(
struct ccw_device *cdev)
207 memset(req, 0,
sizeof(*req));
216 static int pgid_is_reset(
struct pgid *
p)
220 for (c = (
char *)p + 1; c < (
char *)(p + 1); c++) {
227 static int pgid_cmp(
struct pgid *
p1,
struct pgid *p2)
229 return memcmp((
char *) p1 + 1, (
char *) p2 + 1,
230 sizeof(
struct pgid) - 1);
236 static void pgid_analyze(
struct ccw_device *cdev,
struct pgid **p,
239 struct pgid *pgid = &cdev->
private->pgid[0];
247 for (i = 0, lpm = 0x80; i < 8; i++, pgid++, lpm >>= 1) {
248 if ((cdev->
private->pgid_valid_mask & lpm) == 0)
252 if (pgid_is_reset(pgid)) {
260 if (pgid_cmp(pgid, first) != 0)
277 for (i = 0; i < 8; i++) {
279 if ((cdev->
private->pgid_valid_mask & lpm) == 0)
282 if (sch->
opm & lpm) {
289 if (cdev->
private->flags.mpath) {
302 static void pgid_fill(
struct ccw_device *cdev,
struct pgid *pgid)
306 for (i = 0; i < 8; i++)
313 static void snid_done(
struct ccw_device *cdev,
int rc)
325 pgid_analyze(cdev, &pgid, &mismatch, &reserved, &reset);
331 donepm = pgid_to_donepm(cdev);
332 sch->
vpm = donepm & sch->
opm;
333 cdev->
private->pgid_todo_mask &= ~donepm;
334 cdev->
private->pgid_reset_mask |= reset;
335 pgid_fill(cdev, pgid);
338 CIO_MSG_EVENT(2,
"snid: device 0.%x.%04x: rc=%d pvm=%02x vpm=%02x "
339 "todo=%02x mism=%d rsvd=%d reset=%02x\n", id->
ssid,
341 cdev->
private->pgid_todo_mask, mismatch, reserved, reset);
345 if (cdev->
private->pgid_todo_mask == 0) {
346 verify_done(cdev, sch->
vpm == 0 ? -
EACCES : 0);
354 cdev->
private->flags.pgroup = 0;
355 cdev->
private->flags.mpath = 0;
359 verify_done(cdev, rc);
366 static void snid_build_cp(
struct ccw_device *cdev)
370 int i = 8 -
ffs(req->
lpm);
375 cp->
count =
sizeof(
struct pgid);
397 snid_done(cdev, cdev->
private->pgid_valid_mask ? 0 : -
EACCES);
403 static void snid_callback(
struct ccw_device *cdev,
void *data,
int rc)
422 static void verify_start(
struct ccw_device *cdev)
431 memset(req, 0,
sizeof(*req));
436 if (cdev->
private->flags.pgroup) {
438 CIO_HEX_EVENT(4, devid,
sizeof(*devid));
443 CIO_HEX_EVENT(4, devid,
sizeof(*devid));
465 CIO_HEX_EVENT(4, &cdev->
private->dev_id,
sizeof(cdev->
private->dev_id));
468 cdev->
private->pgid_valid_mask = 0;
476 cdev->
private->flags.doverify = 0;
483 static void disband_callback(
struct ccw_device *cdev,
void *data,
int rc)
491 cdev->
private->flags.mpath = 0;
517 CIO_HEX_EVENT(4, &cdev->
private->dev_id,
sizeof(cdev->
private->dev_id));
519 memset(req, 0,
sizeof(*req));
526 if (cdev->
private->flags.mpath)
528 spid_build_cp(cdev, fn);
532 static void stlck_build_cp(
struct ccw_device *cdev,
void *buf1,
void *buf2)
548 static void stlck_callback(
struct ccw_device *cdev,
void *data,
int rc)
571 CIO_HEX_EVENT(4, &cdev->
private->dev_id,
sizeof(cdev->
private->dev_id));
573 memset(req, 0,
sizeof(*req));
579 stlck_build_cp(cdev, buf1, buf2);