hc
2024-02-20 e636c8d336489bf3eed5878299e6cc045bbad077
kernel/include/scsi/libsas.h
....@@ -1,26 +1,9 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * SAS host prototypes and structures header file
34 *
45 * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
56 * 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
- *
247 */
258
269 #ifndef _LIBSAS_H_
....@@ -52,8 +35,8 @@
5235 };
5336
5437 enum sas_phy_type {
55
- PHY_TYPE_PHYSICAL,
56
- PHY_TYPE_VIRTUAL
38
+ PHY_TYPE_PHYSICAL,
39
+ PHY_TYPE_VIRTUAL
5740 };
5841
5942 /* The events are mnemonically described in sas_dump.c
....@@ -91,7 +74,7 @@
9174
9275 #define to_dom_device(_obj) container_of(_obj, struct domain_device, dev_obj)
9376 #define to_dev_attr(_attr) container_of(_attr, struct domain_dev_attribute,\
94
- attr)
77
+ attr)
9578
9679 enum routing_attribute {
9780 DIRECT_ROUTING,
....@@ -184,37 +167,37 @@
184167 spinlock_t done_lock;
185168 enum sas_device_type dev_type;
186169
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;
190173
191
- int pathways;
174
+ int pathways;
192175
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 */
196179 struct sas_phy *phy;
197180
198
- struct list_head dev_list_node;
181
+ struct list_head dev_list_node;
199182 struct list_head disco_list_node; /* awaiting probe or destruct */
200183
201
- enum sas_protocol iproto;
202
- enum sas_protocol tproto;
184
+ enum sas_protocol iproto;
185
+ enum sas_protocol tproto;
203186
204
- struct sas_rphy *rphy;
187
+ struct sas_rphy *rphy;
205188
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];
208191
209
- u8 frame_rcvd[32];
192
+ u8 frame_rcvd[32];
210193
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 */
214197 struct ssp_device ssp_dev;
215
- };
198
+ };
216199
217
- void *lldd_dev;
200
+ void *lldd_dev;
218201 unsigned long state;
219202 struct kref kref;
220203 };
....@@ -223,6 +206,12 @@
223206 struct list_head drain_node;
224207 struct work_struct work;
225208 };
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
+}
226215
227216 static inline void INIT_SAS_WORK(struct sas_work *sw, void (*fn)(struct work_struct *))
228217 {
....@@ -245,9 +234,9 @@
245234 struct sas_discovery {
246235 struct sas_discovery_event disc_work[DISC_NUM_EVENTS];
247236 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];
251240 int max_level;
252241 };
253242
....@@ -402,10 +391,6 @@
402391 int strict_wide_ports; /* both sas_addr and attached_sas_addr must match
403392 * their siblings when forming wide ports */
404393
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
-
409394 void *lldd_ha; /* not touched by sas class code */
410395
411396 struct list_head eh_done_q; /* complete via scsi_eh_flush_done_q */
....@@ -489,10 +474,16 @@
489474 };
490475
491476 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.
494482 */
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,
496487
497488 SAS_DEV_NO_RESPONSE = 0x80,
498489 SAS_DATA_UNDERRUN,
....@@ -512,10 +503,10 @@
512503
513504 /* When a task finishes with a response, the LLDD examines the
514505 * 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
516507 * SAS_PROTO_RESPONSE, and the task_status_struct::buf is set to the
517508 * 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
519510 * is valid, task_status_struct::stat is set. If data is present
520511 * (SENSE data), the LLDD copies up to SAS_STATUS_BUF_SIZE, sets
521512 * task_status_struct::buf_valid_size, and task_status_struct::stat is
....@@ -671,15 +662,13 @@
671662 extern void sas_resume_ha(struct sas_ha_struct *sas_ha);
672663 extern void sas_suspend_ha(struct sas_ha_struct *sas_ha);
673664
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);
676666 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 *);
678668 extern int sas_target_alloc(struct scsi_target *);
679669 extern int sas_slave_configure(struct scsi_device *);
680670 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 *,
683672 sector_t capacity, int *hsc);
684673 extern struct scsi_transport_template *
685674 sas_domain_attach_transport(struct sas_domain_function_template *);
....@@ -709,7 +698,8 @@
709698
710699 extern void sas_target_destroy(struct scsi_target *);
711700 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);
713703 extern int sas_drain_work(struct sas_ha_struct *ha);
714704
715705 extern void sas_ssp_task_response(struct device *dev, struct sas_task *task,
....@@ -718,4 +708,11 @@
718708
719709 int sas_request_addr(struct Scsi_Host *shost, u8 *addr);
720710
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
+
721718 #endif /* _SASLIB_H_ */