libsas.h 18.3 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0-only */
J
James Bottomley 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * SAS host prototypes and structures header file
 *
 * Copyright (C) 2005 Adaptec, Inc.  All rights reserved.
 * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
 */

#ifndef _LIBSAS_H_
#define _LIBSAS_H_


#include <linux/timer.h>
#include <linux/pci.h>
#include <scsi/sas.h>
16
#include <linux/libata.h>
J
James Bottomley 已提交
17 18 19 20
#include <linux/list.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_transport_sas.h>
A
Adrian Bunk 已提交
21
#include <linux/scatterlist.h>
22
#include <linux/slab.h>
J
James Bottomley 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

struct block_device;

enum sas_class {
	SAS,
	EXPANDER
};

enum sas_phy_role {
	PHY_ROLE_NONE = 0,
	PHY_ROLE_TARGET = 0x40,
	PHY_ROLE_INITIATOR = 0x80,
};

enum sas_phy_type {
38 39
	PHY_TYPE_PHYSICAL,
	PHY_TYPE_VIRTUAL
J
James Bottomley 已提交
40 41 42 43 44 45 46 47
};

/* The events are mnemonically described in sas_dump.c
 * so when updating/adding events here, please also
 * update the other file too.
 */
enum port_event {
	PORTE_BYTES_DMAED     = 0U,
48 49 50 51 52
	PORTE_BROADCAST_RCVD,
	PORTE_LINK_RESET_ERR,
	PORTE_TIMER_EVENT,
	PORTE_HARD_RESET,
	PORT_NUM_EVENTS,
J
James Bottomley 已提交
53 54 55 56
};

enum phy_event {
	PHYE_LOSS_OF_SIGNAL   = 0U,
57 58 59 60
	PHYE_OOB_DONE,
	PHYE_OOB_ERROR,
	PHYE_SPINUP_HOLD,             /* hot plug SATA, no COMWAKE sent */
	PHYE_RESUME_TIMEOUT,
61
	PHYE_SHUTDOWN,
62
	PHY_NUM_EVENTS,
J
James Bottomley 已提交
63 64 65 66
};

enum discover_event {
	DISCE_DISCOVER_DOMAIN   = 0U,
67 68 69 70
	DISCE_REVALIDATE_DOMAIN,
	DISCE_SUSPEND,
	DISCE_RESUME,
	DISC_NUM_EVENTS,
J
James Bottomley 已提交
71 72 73 74 75 76
};

/* ---------- Expander Devices ---------- */

#define to_dom_device(_obj) container_of(_obj, struct domain_device, dev_obj)
#define to_dev_attr(_attr)  container_of(_attr, struct domain_dev_attribute,\
77
					 attr)
J
James Bottomley 已提交
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

enum routing_attribute {
	DIRECT_ROUTING,
	SUBTRACTIVE_ROUTING,
	TABLE_ROUTING,
};

enum ex_phy_state {
	PHY_EMPTY,
	PHY_VACANT,
	PHY_NOT_PRESENT,
	PHY_DEVICE_DISCOVERED
};

struct ex_phy {
	int    phy_id;

	enum ex_phy_state phy_state;

97
	enum sas_device_type attached_dev_type;
98
	enum sas_linkrate linkrate;
J
James Bottomley 已提交
99 100 101 102 103

	u8   attached_sata_host:1;
	u8   attached_sata_dev:1;
	u8   attached_sata_ps:1;

104 105
	enum sas_protocol attached_tproto;
	enum sas_protocol attached_iproto;
J
James Bottomley 已提交
106 107 108 109

	u8   attached_sas_addr[SAS_ADDR_SIZE];
	u8   attached_phy_id;

110
	int phy_change_count;
J
James Bottomley 已提交
111 112 113 114 115 116 117 118 119 120 121 122
	enum routing_attribute routing_attr;
	u8   virtual:1;

	int  last_da_index;

	struct sas_phy *phy;
	struct sas_port *port;
};

struct expander_device {
	struct list_head children;

123
	int    ex_change_count;
J
James Bottomley 已提交
124 125
	u16    max_route_indexes;
	u8     num_phys;
126 127

	u8     t2t_supp:1;
J
James Bottomley 已提交
128 129
	u8     configuring:1;
	u8     conf_route_table:1;
130

J
James Bottomley 已提交
131 132 133 134
	u8     enclosure_logical_id[8];

	struct ex_phy *ex_phy;
	struct sas_port *parent_port;
135 136

	struct mutex cmd_mutex;
J
James Bottomley 已提交
137 138 139
};

/* ---------- SATA device ---------- */
140 141
#define ATA_RESP_FIS_SIZE 24

J
James Bottomley 已提交
142
struct sata_device {
H
Hannes Reinecke 已提交
143 144
	unsigned int class;
	u8     port_no;        /* port number, if this is a PM (Port) */
145 146

	struct ata_port *ap;
147
	struct ata_host *ata_host;
148
	struct smp_resp rps_resp ____cacheline_aligned; /* report_phy_sata_resp */
149
	u8     fis[ATA_RESP_FIS_SIZE];
J
James Bottomley 已提交
150 151
};

152 153 154 155 156
struct ssp_device {
	struct list_head eh_list_node; /* pending a user requested eh action */
	struct scsi_lun reset_lun;
};

157 158
enum {
	SAS_DEV_GONE,
159
	SAS_DEV_FOUND, /* device notified to lldd */
160
	SAS_DEV_DESTROY,
161
	SAS_DEV_EH_PENDING,
162 163
	SAS_DEV_LU_RESET,
	SAS_DEV_RESET,
164 165
};

J
James Bottomley 已提交
166
struct domain_device {
167
	spinlock_t done_lock;
168
	enum sas_device_type dev_type;
J
James Bottomley 已提交
169

170 171 172
	enum sas_linkrate linkrate;
	enum sas_linkrate min_linkrate;
	enum sas_linkrate max_linkrate;
J
James Bottomley 已提交
173

174
	int  pathways;
J
James Bottomley 已提交
175

176 177 178
	struct domain_device *parent;
	struct list_head siblings; /* devices on the same level */
	struct asd_sas_port *port;        /* shortcut to root of the tree */
179
	struct sas_phy *phy;
J
James Bottomley 已提交
180

181
	struct list_head dev_list_node;
182
	struct list_head disco_list_node; /* awaiting probe or destruct */
J
James Bottomley 已提交
183

184 185
	enum sas_protocol    iproto;
	enum sas_protocol    tproto;
J
James Bottomley 已提交
186

187
	struct sas_rphy *rphy;
J
James Bottomley 已提交
188

189 190
	u8  sas_addr[SAS_ADDR_SIZE];
	u8  hashed_sas_addr[HASHED_SAS_ADDR_SIZE];
J
James Bottomley 已提交
191

192
	u8  frame_rcvd[32];
J
James Bottomley 已提交
193

194 195 196
	union {
		struct expander_device ex_dev;
		struct sata_device     sata_dev; /* STP & directly attached */
197
		struct ssp_device      ssp_dev;
198
	};
J
James Bottomley 已提交
199

200
	void *lldd_dev;
201
	unsigned long state;
202
	struct kref kref;
J
James Bottomley 已提交
203 204
};

205 206
struct sas_work {
	struct list_head drain_node;
D
David Howells 已提交
207
	struct work_struct work;
208 209
};

210
static inline bool dev_is_expander(enum sas_device_type type)
211 212 213 214 215
{
	return type == SAS_EDGE_EXPANDER_DEVICE ||
	       type == SAS_FANOUT_EXPANDER_DEVICE;
}

216 217 218 219 220 221 222 223
static inline void INIT_SAS_WORK(struct sas_work *sw, void (*fn)(struct work_struct *))
{
	INIT_WORK(&sw->work, fn);
	INIT_LIST_HEAD(&sw->drain_node);
}

struct sas_discovery_event {
	struct sas_work work;
D
David Howells 已提交
224 225 226
	struct asd_sas_port *port;
};

227 228 229 230 231 232 233
static inline struct sas_discovery_event *to_sas_discovery_event(struct work_struct *work)
{
	struct sas_discovery_event *ev = container_of(work, typeof(*ev), work.work);

	return ev;
}

J
James Bottomley 已提交
234
struct sas_discovery {
D
David Howells 已提交
235
	struct sas_discovery_event disc_work[DISC_NUM_EVENTS];
J
James Bottomley 已提交
236
	unsigned long    pending;
237 238 239
	u8     fanout_sas_addr[SAS_ADDR_SIZE];
	u8     eeds_a[SAS_ADDR_SIZE];
	u8     eeds_b[SAS_ADDR_SIZE];
J
James Bottomley 已提交
240 241 242 243 244 245 246 247 248 249
	int    max_level;
};

/* The port struct is Class:RW, driver:RO */
struct asd_sas_port {
/* private: */
	struct sas_discovery disc;
	struct domain_device *port_dev;
	spinlock_t dev_list_lock;
	struct list_head dev_list;
250 251
	struct list_head disco_list;
	struct list_head destroy_list;
252
	struct list_head sas_port_del_list;
253
	enum   sas_linkrate linkrate;
J
James Bottomley 已提交
254

255
	struct sas_work work;
256
	int suspended;
J
James Bottomley 已提交
257 258 259 260 261 262 263

/* public: */
	int id;

	enum sas_class   class;
	u8               sas_addr[SAS_ADDR_SIZE];
	u8               attached_sas_addr[SAS_ADDR_SIZE];
264 265
	enum sas_protocol   iproto;
	enum sas_protocol   tproto;
J
James Bottomley 已提交
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280

	enum sas_oob_mode oob_mode;

	spinlock_t       phy_list_lock;
	struct list_head phy_list;
	int              num_phys;
	u32              phy_mask;

	struct sas_ha_struct *ha;

	struct sas_port	*port;

	void *lldd_port;	  /* not touched by the sas class code */
};

D
David Howells 已提交
281
struct asd_sas_event {
282
	struct sas_work work;
D
David Howells 已提交
283
	struct asd_sas_phy *phy;
284
	int event;
D
David Howells 已提交
285 286
};

287 288 289 290 291 292 293
static inline struct asd_sas_event *to_asd_sas_event(struct work_struct *work)
{
	struct asd_sas_event *ev = container_of(work, typeof(*ev), work.work);

	return ev;
}

294 295 296 297 298 299 300 301 302
static inline void INIT_SAS_EVENT(struct asd_sas_event *ev,
		void (*fn)(struct work_struct *),
		struct asd_sas_phy *phy, int event)
{
	INIT_SAS_WORK(&ev->work, fn);
	ev->phy = phy;
	ev->event = event;
}

303
#define SAS_PHY_SHUTDOWN_THRES   1024
304

J
James Bottomley 已提交
305 306 307 308 309
/* The phy pretty much is controlled by the LLDD.
 * The class only reads those fields.
 */
struct asd_sas_phy {
/* private: */
310 311
	atomic_t event_nr;
	int in_shutdown;
J
James Bottomley 已提交
312
	int error;
313
	int suspended;
J
James Bottomley 已提交
314 315 316 317 318 319 320 321 322

	struct sas_phy *phy;

/* public: */
	/* The following are class:RO, driver:R/W */
	int            enabled;	  /* must be set */

	int            id;	  /* must be set */
	enum sas_class class;
323 324
	enum sas_protocol iproto;
	enum sas_protocol tproto;
J
James Bottomley 已提交
325 326 327 328

	enum sas_phy_type  type;
	enum sas_phy_role  role;
	enum sas_oob_mode  oob_mode;
329
	enum sas_linkrate linkrate;
J
James Bottomley 已提交
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353

	u8   *sas_addr;		  /* must be set */
	u8   attached_sas_addr[SAS_ADDR_SIZE]; /* class:RO, driver: R/W */

	spinlock_t     frame_rcvd_lock;
	u8             *frame_rcvd; /* must be set */
	int            frame_rcvd_size;

	spinlock_t     sas_prim_lock;
	u32            sas_prim;

	struct list_head port_phy_el; /* driver:RO */
	struct asd_sas_port      *port; /* Class:RW, driver: RO */

	struct sas_ha_struct *ha; /* may be set; the class sets it anyway */

	void *lldd_phy;		  /* not touched by the sas_class_code */
};

struct scsi_core {
	struct Scsi_Host *shost;

};

354 355
enum sas_ha_state {
	SAS_HA_REGISTERED,
356
	SAS_HA_DRAINING,
357
	SAS_HA_ATA_EH_ACTIVE,
358
	SAS_HA_FROZEN,
359
	SAS_HA_RESUMING,
360 361
};

J
James Bottomley 已提交
362 363
struct sas_ha_struct {
/* private: */
364 365
	struct list_head  defer_q; /* work queued while draining */
	struct mutex	  drain_mutex;
366
	unsigned long	  state;
367 368
	spinlock_t	  lock;
	int		  eh_active;
369 370
	wait_queue_head_t eh_wait_q;
	struct list_head  eh_dev_q;
371

372 373
	struct mutex disco_mutex;

J
James Bottomley 已提交
374 375 376 377
	struct scsi_core core;

/* public: */
	char *sas_ha_name;
378
	struct device *dev;	  /* should be set */
J
James Bottomley 已提交
379 380
	struct module *lldd_module; /* should be set */

381 382 383
	struct workqueue_struct *event_q;
	struct workqueue_struct *disco_q;

J
James Bottomley 已提交
384 385 386 387 388 389 390 391
	u8 *sas_addr;		  /* must be set */
	u8 hashed_sas_addr[HASHED_SAS_ADDR_SIZE];

	spinlock_t      phy_port_lock;
	struct asd_sas_phy  **sas_phy; /* array of valid pointers, must be set */
	struct asd_sas_port **sas_port; /* array of valid pointers, must be set */
	int             num_phys; /* must be set, gt 0, static */

392 393
	int strict_wide_ports; /* both sas_addr and attached_sas_addr must match
				* their siblings when forming wide ports */
J
James Bottomley 已提交
394 395

	void *lldd_ha;		  /* not touched by sas class code */
396

397 398
	struct list_head eh_done_q;  /* complete via scsi_eh_flush_done_q */
	struct list_head eh_ata_q; /* scmds to promote from sas to ata eh */
399 400

	int event_thres;
J
James Bottomley 已提交
401 402 403 404 405 406 407 408 409 410 411 412 413 414
};

#define SHOST_TO_SAS_HA(_shost) (*(struct sas_ha_struct **)(_shost)->hostdata)

static inline struct domain_device *
starget_to_domain_dev(struct scsi_target *starget) {
	return starget->hostdata;
}

static inline struct domain_device *
sdev_to_domain_dev(struct scsi_device *sdev) {
	return starget_to_domain_dev(sdev->sdev_target);
}

D
Dan Williams 已提交
415 416 417 418 419
static inline struct ata_device *sas_to_ata_dev(struct domain_device *dev)
{
	return &dev->sata_dev.ap->link.device[0];
}

J
James Bottomley 已提交
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435
static inline struct domain_device *
cmd_to_domain_dev(struct scsi_cmnd *cmd)
{
	return sdev_to_domain_dev(cmd->device);
}

void sas_hash_addr(u8 *hashed, const u8 *sas_addr);

/* Before calling a notify event, LLDD should use this function
 * when the link is severed (possibly from its tasklet).
 * The idea is that the Class only reads those, while the LLDD,
 * can R/W these (thus avoiding a race).
 */
static inline void sas_phy_disconnected(struct asd_sas_phy *phy)
{
	phy->oob_mode = OOB_NOT_CONNECTED;
436
	phy->linkrate = SAS_LINK_RATE_UNKNOWN;
J
James Bottomley 已提交
437 438
}

439 440 441 442 443
static inline unsigned int to_sas_gpio_od(int device, int bit)
{
	return 3 * device + bit;
}

444 445 446 447 448
static inline void sas_put_local_phy(struct sas_phy *phy)
{
	put_device(&phy->dev);
}

449
#ifdef CONFIG_SCSI_SAS_HOST_SMP
450
int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count);
451 452 453 454 455 456
#else
static inline int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count)
{
	return -1;
}
#endif
457

J
James Bottomley 已提交
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477
/* ---------- Tasks ---------- */
/*
      service_response |  SAS_TASK_COMPLETE  |  SAS_TASK_UNDELIVERED |
  exec_status          |                     |                       |
  ---------------------+---------------------+-----------------------+
       SAM_...         |         X           |                       |
       DEV_NO_RESPONSE |         X           |           X           |
       INTERRUPTED     |         X           |                       |
       QUEUE_FULL      |                     |           X           |
       DEVICE_UNKNOWN  |                     |           X           |
       SG_ERR          |                     |           X           |
  ---------------------+---------------------+-----------------------+
 */

enum service_response {
	SAS_TASK_COMPLETE,
	SAS_TASK_UNDELIVERED = -1,
};

enum exec_status {
478 479 480 481 482
	/*
	 * Values 0..0x7f are used to return the SAM_STAT_* codes.  To avoid
	 * 'case value not in enumerated type' compiler warnings every value
	 * returned through the exec_status enum needs an alias with the SAS_
	 * prefix here.
483
	 */
484 485 486 487
	SAS_SAM_STAT_GOOD = SAM_STAT_GOOD,
	SAS_SAM_STAT_BUSY = SAM_STAT_BUSY,
	SAS_SAM_STAT_TASK_ABORTED = SAM_STAT_TASK_ABORTED,
	SAS_SAM_STAT_CHECK_CONDITION = SAM_STAT_CHECK_CONDITION,
J
James Bottomley 已提交
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505

	SAS_DEV_NO_RESPONSE = 0x80,
	SAS_DATA_UNDERRUN,
	SAS_DATA_OVERRUN,
	SAS_INTERRUPTED,
	SAS_QUEUE_FULL,
	SAS_DEVICE_UNKNOWN,
	SAS_OPEN_REJECT,
	SAS_OPEN_TO,
	SAS_PROTO_RESPONSE,
	SAS_PHY_DOWN,
	SAS_NAK_R_ERR,
	SAS_PENDING,
	SAS_ABORTED_TASK,
};

/* When a task finishes with a response, the LLDD examines the
 * response:
506
 *	- For an ATA task task_status_struct::stat is set to
J
James Bottomley 已提交
507 508
 * SAS_PROTO_RESPONSE, and the task_status_struct::buf is set to the
 * contents of struct ata_task_resp.
509
 *	- For SSP tasks, if no data is present or status/TMF response
J
James Bottomley 已提交
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524
 * is valid, task_status_struct::stat is set.  If data is present
 * (SENSE data), the LLDD copies up to SAS_STATUS_BUF_SIZE, sets
 * task_status_struct::buf_valid_size, and task_status_struct::stat is
 * set to SAM_CHECK_COND.
 *
 * "buf" has format SCSI Sense for SSP task, or struct ata_task_resp
 * for ATA task.
 *
 * "frame_len" is the total frame length, which could be more or less
 * than actually copied.
 *
 * Tasks ending with response, always set the residual field.
 */
struct ata_task_resp {
	u16  frame_len;
525
	u8   ending_fis[ATA_RESP_FIS_SIZE];	  /* dev to host or data-in */
J
James Bottomley 已提交
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575
};

#define SAS_STATUS_BUF_SIZE 96

struct task_status_struct {
	enum service_response resp;
	enum exec_status      stat;
	int  buf_valid_size;

	u8   buf[SAS_STATUS_BUF_SIZE];

	u32  residual;
	enum sas_open_rej_reason open_rej_reason;
};

/* ATA and ATAPI task queuable to a SAS LLDD.
 */
struct sas_ata_task {
	struct host_to_dev_fis fis;
	u8     atapi_packet[16];  /* 0 if not ATAPI task */

	u8     retry_count;	  /* hardware retry, should be > 0 */

	u8     dma_xfer:1;	  /* PIO:0 or DMA:1 */
	u8     use_ncq:1;
	u8     set_affil_pol:1;
	u8     stp_affil_pol:1;

	u8     device_control_reg_update:1;
};

struct sas_smp_task {
	struct scatterlist smp_req;
	struct scatterlist smp_resp;
};

enum task_attribute {
	TASK_ATTR_SIMPLE = 0,
	TASK_ATTR_HOQ    = 1,
	TASK_ATTR_ORDERED= 2,
	TASK_ATTR_ACA    = 4,
};

struct sas_ssp_task {
	u8     retry_count;	  /* hardware retry, should be > 0 */

	u8     LUN[8];
	u8     enable_first_burst:1;
	enum   task_attribute task_attr;
	u8     task_prio;
576
	struct scsi_cmnd *cmd;
J
James Bottomley 已提交
577 578
};

579 580 581 582 583 584 585 586 587
struct sas_tmf_task {
	u8 tmf;
	u16 tag_of_task_to_be_managed;

	/* Temp */
	int force_phy;
	int phy_id;
};

J
James Bottomley 已提交
588 589 590 591 592 593
struct sas_task {
	struct domain_device *dev;

	spinlock_t   task_state_lock;
	unsigned     task_state_flags;

594
	enum   sas_protocol      task_proto;
J
James Bottomley 已提交
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611

	union {
		struct sas_ata_task ata_task;
		struct sas_smp_task smp_task;
		struct sas_ssp_task ssp_task;
	};

	struct scatterlist *scatter;
	int    num_scatter;
	u32    total_xfer_len;
	u8     data_dir:2;	  /* Use PCI_DMA_... */

	struct task_status_struct task_status;
	void   (*task_done)(struct sas_task *);

	void   *lldd_task;	  /* for use by LLDDs */
	void   *uldd_task;
612
	struct sas_task_slow *slow_task;
J
John Garry 已提交
613
	struct sas_tmf_task *tmf;
614
};
615

616 617 618 619 620 621
struct sas_task_slow {
	/* standard/extra infrastructure for slow path commands (SMP and
	 * internal lldd commands
	 */
	struct timer_list     timer;
	struct completion     completion;
622
	struct sas_task       *task;
J
James Bottomley 已提交
623 624
};

625 626 627
#define SAS_TASK_STATE_PENDING      1
#define SAS_TASK_STATE_DONE         2
#define SAS_TASK_STATE_ABORTED      4
628
#define SAS_TASK_NEED_DEV_RESET     8
J
James Bottomley 已提交
629

630
extern struct sas_task *sas_alloc_task(gfp_t flags);
631
extern struct sas_task *sas_alloc_slow_task(gfp_t flags);
632
extern void sas_free_task(struct sas_task *task);
J
James Bottomley 已提交
633 634 635 636 637 638 639 640 641 642

struct sas_domain_function_template {
	/* The class calls these to notify the LLDD of an event. */
	void (*lldd_port_formed)(struct asd_sas_phy *);
	void (*lldd_port_deformed)(struct asd_sas_phy *);

	/* The class calls these when a device is found or gone. */
	int  (*lldd_dev_found)(struct domain_device *);
	void (*lldd_dev_gone)(struct domain_device *);

643
	int (*lldd_execute_task)(struct sas_task *, gfp_t gfp_flags);
J
James Bottomley 已提交
644 645 646 647 648 649

	/* Task Management Functions. Must be called from process context. */
	int (*lldd_abort_task)(struct sas_task *);
	int (*lldd_abort_task_set)(struct domain_device *, u8 *lun);
	int (*lldd_clear_task_set)(struct domain_device *, u8 *lun);
	int (*lldd_I_T_nexus_reset)(struct domain_device *);
650
	int (*lldd_ata_check_ready)(struct domain_device *);
651
	void (*lldd_ata_set_dmamode)(struct domain_device *);
J
James Bottomley 已提交
652 653 654
	int (*lldd_lu_reset)(struct domain_device *, u8 *lun);
	int (*lldd_query_task)(struct sas_task *);

655 656 657
	/* Special TMF callbacks */
	void (*lldd_tmf_exec_complete)(struct domain_device *dev);

J
James Bottomley 已提交
658 659 660 661 662
	/* Port and Adapter management */
	int (*lldd_clear_nexus_port)(struct asd_sas_port *);
	int (*lldd_clear_nexus_ha)(struct sas_ha_struct *);

	/* Phy management */
663
	int (*lldd_control_phy)(struct asd_sas_phy *, enum phy_func, void *);
664 665 666 667

	/* GPIO support */
	int (*lldd_write_gpio)(struct sas_ha_struct *, u8 reg_type,
			       u8 reg_index, u8 reg_count, u8 *write_data);
J
James Bottomley 已提交
668 669 670 671
};

extern int sas_register_ha(struct sas_ha_struct *);
extern int sas_unregister_ha(struct sas_ha_struct *);
672 673
extern void sas_prep_resume_ha(struct sas_ha_struct *sas_ha);
extern void sas_resume_ha(struct sas_ha_struct *sas_ha);
674
extern void sas_resume_ha_no_sync(struct sas_ha_struct *sas_ha);
675
extern void sas_suspend_ha(struct sas_ha_struct *sas_ha);
J
James Bottomley 已提交
676

677
int sas_set_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates);
678
int sas_phy_reset(struct sas_phy *phy, int hard_reset);
679
int sas_phy_enable(struct sas_phy *phy, int enable);
680
extern int sas_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
J
James Bottomley 已提交
681 682
extern int sas_target_alloc(struct scsi_target *);
extern int sas_slave_configure(struct scsi_device *);
683
extern int sas_change_queue_depth(struct scsi_device *, int new_depth);
684
extern int sas_bios_param(struct scsi_device *, struct block_device *,
J
James Bottomley 已提交
685 686 687
			  sector_t capacity, int *hsc);
extern struct scsi_transport_template *
sas_domain_attach_transport(struct sas_domain_function_template *);
688
extern struct device_attribute dev_attr_phy_event_threshold;
J
James Bottomley 已提交
689 690 691 692 693 694 695

int  sas_discover_root_expander(struct domain_device *);

void sas_init_ex_attr(void);

int  sas_ex_revalidate_domain(struct domain_device *);

696
void sas_unregister_domain_devices(struct asd_sas_port *port, int gone);
J
James Bottomley 已提交
697
void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *);
698
void sas_discover_event(struct asd_sas_port *, enum discover_event ev);
J
James Bottomley 已提交
699 700 701 702

int  sas_discover_sata(struct domain_device *);
int  sas_discover_end_dev(struct domain_device *);

703
void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *);
J
James Bottomley 已提交
704 705 706

void sas_init_dev(struct domain_device *);

707
void sas_task_abort(struct sas_task *);
708
int sas_eh_abort_handler(struct scsi_cmnd *cmd);
709
int sas_eh_device_reset_handler(struct scsi_cmnd *cmd);
710
int sas_eh_target_reset_handler(struct scsi_cmnd *cmd);
711

712 713
extern void sas_target_destroy(struct scsi_target *);
extern int sas_slave_alloc(struct scsi_device *);
714 715
extern int sas_ioctl(struct scsi_device *sdev, unsigned int cmd,
		     void __user *arg);
716
extern int sas_drain_work(struct sas_ha_struct *ha);
717

718 719
extern void sas_ssp_task_response(struct device *dev, struct sas_task *task,
				  struct ssp_response_iu *iu);
720
struct sas_phy *sas_get_local_phy(struct domain_device *dev);
721

722 723
int sas_request_addr(struct Scsi_Host *shost, u8 *addr);

724 725 726 727
int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event,
			  gfp_t gfp_flags);
int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event,
			 gfp_t gfp_flags);
728

J
James Bottomley 已提交
729
#endif /* _SASLIB_H_ */