.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * SAS host prototypes and structures header file |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2005 Adaptec, Inc. All rights reserved. |
---|
5 | 6 | * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com> |
---|
6 | | - * |
---|
7 | | - * This file is licensed under GPLv2. |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or |
---|
10 | | - * modify it under the terms of the GNU General Public License as |
---|
11 | | - * published by the Free Software Foundation; either version 2 of the |
---|
12 | | - * License, or (at your option) any later version. |
---|
13 | | - * |
---|
14 | | - * This program is distributed in the hope that it will be useful, but |
---|
15 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | | - * General Public License for more details. |
---|
18 | | - * |
---|
19 | | - * You should have received a copy of the GNU General Public License |
---|
20 | | - * along with this program; if not, write to the Free Software |
---|
21 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
22 | | - * USA |
---|
23 | | - * |
---|
24 | 7 | */ |
---|
25 | 8 | |
---|
26 | 9 | #ifndef _LIBSAS_H_ |
---|
.. | .. |
---|
52 | 35 | }; |
---|
53 | 36 | |
---|
54 | 37 | enum sas_phy_type { |
---|
55 | | - PHY_TYPE_PHYSICAL, |
---|
56 | | - PHY_TYPE_VIRTUAL |
---|
| 38 | + PHY_TYPE_PHYSICAL, |
---|
| 39 | + PHY_TYPE_VIRTUAL |
---|
57 | 40 | }; |
---|
58 | 41 | |
---|
59 | 42 | /* The events are mnemonically described in sas_dump.c |
---|
.. | .. |
---|
91 | 74 | |
---|
92 | 75 | #define to_dom_device(_obj) container_of(_obj, struct domain_device, dev_obj) |
---|
93 | 76 | #define to_dev_attr(_attr) container_of(_attr, struct domain_dev_attribute,\ |
---|
94 | | - attr) |
---|
| 77 | + attr) |
---|
95 | 78 | |
---|
96 | 79 | enum routing_attribute { |
---|
97 | 80 | DIRECT_ROUTING, |
---|
.. | .. |
---|
184 | 167 | spinlock_t done_lock; |
---|
185 | 168 | enum sas_device_type dev_type; |
---|
186 | 169 | |
---|
187 | | - enum sas_linkrate linkrate; |
---|
188 | | - enum sas_linkrate min_linkrate; |
---|
189 | | - enum sas_linkrate max_linkrate; |
---|
| 170 | + enum sas_linkrate linkrate; |
---|
| 171 | + enum sas_linkrate min_linkrate; |
---|
| 172 | + enum sas_linkrate max_linkrate; |
---|
190 | 173 | |
---|
191 | | - int pathways; |
---|
| 174 | + int pathways; |
---|
192 | 175 | |
---|
193 | | - struct domain_device *parent; |
---|
194 | | - struct list_head siblings; /* devices on the same level */ |
---|
195 | | - struct asd_sas_port *port; /* shortcut to root of the tree */ |
---|
| 176 | + struct domain_device *parent; |
---|
| 177 | + struct list_head siblings; /* devices on the same level */ |
---|
| 178 | + struct asd_sas_port *port; /* shortcut to root of the tree */ |
---|
196 | 179 | struct sas_phy *phy; |
---|
197 | 180 | |
---|
198 | | - struct list_head dev_list_node; |
---|
| 181 | + struct list_head dev_list_node; |
---|
199 | 182 | struct list_head disco_list_node; /* awaiting probe or destruct */ |
---|
200 | 183 | |
---|
201 | | - enum sas_protocol iproto; |
---|
202 | | - enum sas_protocol tproto; |
---|
| 184 | + enum sas_protocol iproto; |
---|
| 185 | + enum sas_protocol tproto; |
---|
203 | 186 | |
---|
204 | | - struct sas_rphy *rphy; |
---|
| 187 | + struct sas_rphy *rphy; |
---|
205 | 188 | |
---|
206 | | - u8 sas_addr[SAS_ADDR_SIZE]; |
---|
207 | | - u8 hashed_sas_addr[HASHED_SAS_ADDR_SIZE]; |
---|
| 189 | + u8 sas_addr[SAS_ADDR_SIZE]; |
---|
| 190 | + u8 hashed_sas_addr[HASHED_SAS_ADDR_SIZE]; |
---|
208 | 191 | |
---|
209 | | - u8 frame_rcvd[32]; |
---|
| 192 | + u8 frame_rcvd[32]; |
---|
210 | 193 | |
---|
211 | | - union { |
---|
212 | | - struct expander_device ex_dev; |
---|
213 | | - struct sata_device sata_dev; /* STP & directly attached */ |
---|
| 194 | + union { |
---|
| 195 | + struct expander_device ex_dev; |
---|
| 196 | + struct sata_device sata_dev; /* STP & directly attached */ |
---|
214 | 197 | struct ssp_device ssp_dev; |
---|
215 | | - }; |
---|
| 198 | + }; |
---|
216 | 199 | |
---|
217 | | - void *lldd_dev; |
---|
| 200 | + void *lldd_dev; |
---|
218 | 201 | unsigned long state; |
---|
219 | 202 | struct kref kref; |
---|
220 | 203 | }; |
---|
.. | .. |
---|
223 | 206 | struct list_head drain_node; |
---|
224 | 207 | struct work_struct work; |
---|
225 | 208 | }; |
---|
| 209 | + |
---|
| 210 | +static inline bool dev_is_expander(enum sas_device_type type) |
---|
| 211 | +{ |
---|
| 212 | + return type == SAS_EDGE_EXPANDER_DEVICE || |
---|
| 213 | + type == SAS_FANOUT_EXPANDER_DEVICE; |
---|
| 214 | +} |
---|
226 | 215 | |
---|
227 | 216 | static inline void INIT_SAS_WORK(struct sas_work *sw, void (*fn)(struct work_struct *)) |
---|
228 | 217 | { |
---|
.. | .. |
---|
245 | 234 | struct sas_discovery { |
---|
246 | 235 | struct sas_discovery_event disc_work[DISC_NUM_EVENTS]; |
---|
247 | 236 | unsigned long pending; |
---|
248 | | - u8 fanout_sas_addr[8]; |
---|
249 | | - u8 eeds_a[8]; |
---|
250 | | - u8 eeds_b[8]; |
---|
| 237 | + u8 fanout_sas_addr[SAS_ADDR_SIZE]; |
---|
| 238 | + u8 eeds_a[SAS_ADDR_SIZE]; |
---|
| 239 | + u8 eeds_b[SAS_ADDR_SIZE]; |
---|
251 | 240 | int max_level; |
---|
252 | 241 | }; |
---|
253 | 242 | |
---|
.. | .. |
---|
402 | 391 | int strict_wide_ports; /* both sas_addr and attached_sas_addr must match |
---|
403 | 392 | * their siblings when forming wide ports */ |
---|
404 | 393 | |
---|
405 | | - /* LLDD calls these to notify the class of an event. */ |
---|
406 | | - int (*notify_port_event)(struct asd_sas_phy *, enum port_event); |
---|
407 | | - int (*notify_phy_event)(struct asd_sas_phy *, enum phy_event); |
---|
408 | | - |
---|
409 | 394 | void *lldd_ha; /* not touched by sas class code */ |
---|
410 | 395 | |
---|
411 | 396 | struct list_head eh_done_q; /* complete via scsi_eh_flush_done_q */ |
---|
.. | .. |
---|
489 | 474 | }; |
---|
490 | 475 | |
---|
491 | 476 | enum exec_status { |
---|
492 | | - /* The SAM_STAT_.. codes fit in the lower 6 bits, alias some of |
---|
493 | | - * them here to silence 'case value not in enumerated type' warnings |
---|
| 477 | + /* |
---|
| 478 | + * Values 0..0x7f are used to return the SAM_STAT_* codes. To avoid |
---|
| 479 | + * 'case value not in enumerated type' compiler warnings every value |
---|
| 480 | + * returned through the exec_status enum needs an alias with the SAS_ |
---|
| 481 | + * prefix here. |
---|
494 | 482 | */ |
---|
495 | | - __SAM_STAT_CHECK_CONDITION = SAM_STAT_CHECK_CONDITION, |
---|
| 483 | + SAS_SAM_STAT_GOOD = SAM_STAT_GOOD, |
---|
| 484 | + SAS_SAM_STAT_BUSY = SAM_STAT_BUSY, |
---|
| 485 | + SAS_SAM_STAT_TASK_ABORTED = SAM_STAT_TASK_ABORTED, |
---|
| 486 | + SAS_SAM_STAT_CHECK_CONDITION = SAM_STAT_CHECK_CONDITION, |
---|
496 | 487 | |
---|
497 | 488 | SAS_DEV_NO_RESPONSE = 0x80, |
---|
498 | 489 | SAS_DATA_UNDERRUN, |
---|
.. | .. |
---|
512 | 503 | |
---|
513 | 504 | /* When a task finishes with a response, the LLDD examines the |
---|
514 | 505 | * response: |
---|
515 | | - * - For an ATA task task_status_struct::stat is set to |
---|
| 506 | + * - For an ATA task task_status_struct::stat is set to |
---|
516 | 507 | * SAS_PROTO_RESPONSE, and the task_status_struct::buf is set to the |
---|
517 | 508 | * contents of struct ata_task_resp. |
---|
518 | | - * - For SSP tasks, if no data is present or status/TMF response |
---|
| 509 | + * - For SSP tasks, if no data is present or status/TMF response |
---|
519 | 510 | * is valid, task_status_struct::stat is set. If data is present |
---|
520 | 511 | * (SENSE data), the LLDD copies up to SAS_STATUS_BUF_SIZE, sets |
---|
521 | 512 | * task_status_struct::buf_valid_size, and task_status_struct::stat is |
---|
.. | .. |
---|
671 | 662 | extern void sas_resume_ha(struct sas_ha_struct *sas_ha); |
---|
672 | 663 | extern void sas_suspend_ha(struct sas_ha_struct *sas_ha); |
---|
673 | 664 | |
---|
674 | | -int sas_set_phy_speed(struct sas_phy *phy, |
---|
675 | | - struct sas_phy_linkrates *rates); |
---|
| 665 | +int sas_set_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates); |
---|
676 | 666 | int sas_phy_reset(struct sas_phy *phy, int hard_reset); |
---|
677 | | -extern int sas_queuecommand(struct Scsi_Host * ,struct scsi_cmnd *); |
---|
| 667 | +extern int sas_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); |
---|
678 | 668 | extern int sas_target_alloc(struct scsi_target *); |
---|
679 | 669 | extern int sas_slave_configure(struct scsi_device *); |
---|
680 | 670 | extern int sas_change_queue_depth(struct scsi_device *, int new_depth); |
---|
681 | | -extern int sas_bios_param(struct scsi_device *, |
---|
682 | | - struct block_device *, |
---|
| 671 | +extern int sas_bios_param(struct scsi_device *, struct block_device *, |
---|
683 | 672 | sector_t capacity, int *hsc); |
---|
684 | 673 | extern struct scsi_transport_template * |
---|
685 | 674 | sas_domain_attach_transport(struct sas_domain_function_template *); |
---|
.. | .. |
---|
709 | 698 | |
---|
710 | 699 | extern void sas_target_destroy(struct scsi_target *); |
---|
711 | 700 | extern int sas_slave_alloc(struct scsi_device *); |
---|
712 | | -extern int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg); |
---|
| 701 | +extern int sas_ioctl(struct scsi_device *sdev, unsigned int cmd, |
---|
| 702 | + void __user *arg); |
---|
713 | 703 | extern int sas_drain_work(struct sas_ha_struct *ha); |
---|
714 | 704 | |
---|
715 | 705 | extern void sas_ssp_task_response(struct device *dev, struct sas_task *task, |
---|
.. | .. |
---|
718 | 708 | |
---|
719 | 709 | int sas_request_addr(struct Scsi_Host *shost, u8 *addr); |
---|
720 | 710 | |
---|
| 711 | +int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event); |
---|
| 712 | +int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event); |
---|
| 713 | +int sas_notify_port_event_gfp(struct asd_sas_phy *phy, enum port_event event, |
---|
| 714 | + gfp_t gfp_flags); |
---|
| 715 | +int sas_notify_phy_event_gfp(struct asd_sas_phy *phy, enum phy_event event, |
---|
| 716 | + gfp_t gfp_flags); |
---|
| 717 | + |
---|
721 | 718 | #endif /* _SASLIB_H_ */ |
---|