hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
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 */
....@@ -512,10 +497,10 @@
512497
513498 /* When a task finishes with a response, the LLDD examines the
514499 * response:
515
- * - For an ATA task task_status_struct::stat is set to
500
+ * - For an ATA task task_status_struct::stat is set to
516501 * SAS_PROTO_RESPONSE, and the task_status_struct::buf is set to the
517502 * contents of struct ata_task_resp.
518
- * - For SSP tasks, if no data is present or status/TMF response
503
+ * - For SSP tasks, if no data is present or status/TMF response
519504 * is valid, task_status_struct::stat is set. If data is present
520505 * (SENSE data), the LLDD copies up to SAS_STATUS_BUF_SIZE, sets
521506 * task_status_struct::buf_valid_size, and task_status_struct::stat is
....@@ -671,15 +656,13 @@
671656 extern void sas_resume_ha(struct sas_ha_struct *sas_ha);
672657 extern void sas_suspend_ha(struct sas_ha_struct *sas_ha);
673658
674
-int sas_set_phy_speed(struct sas_phy *phy,
675
- struct sas_phy_linkrates *rates);
659
+int sas_set_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates);
676660 int sas_phy_reset(struct sas_phy *phy, int hard_reset);
677
-extern int sas_queuecommand(struct Scsi_Host * ,struct scsi_cmnd *);
661
+extern int sas_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
678662 extern int sas_target_alloc(struct scsi_target *);
679663 extern int sas_slave_configure(struct scsi_device *);
680664 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 *,
665
+extern int sas_bios_param(struct scsi_device *, struct block_device *,
683666 sector_t capacity, int *hsc);
684667 extern struct scsi_transport_template *
685668 sas_domain_attach_transport(struct sas_domain_function_template *);
....@@ -709,7 +692,8 @@
709692
710693 extern void sas_target_destroy(struct scsi_target *);
711694 extern int sas_slave_alloc(struct scsi_device *);
712
-extern int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg);
695
+extern int sas_ioctl(struct scsi_device *sdev, unsigned int cmd,
696
+ void __user *arg);
713697 extern int sas_drain_work(struct sas_ha_struct *ha);
714698
715699 extern void sas_ssp_task_response(struct device *dev, struct sas_task *task,
....@@ -718,4 +702,11 @@
718702
719703 int sas_request_addr(struct Scsi_Host *shost, u8 *addr);
720704
705
+int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event);
706
+int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event);
707
+int sas_notify_port_event_gfp(struct asd_sas_phy *phy, enum port_event event,
708
+ gfp_t gfp_flags);
709
+int sas_notify_phy_event_gfp(struct asd_sas_phy *phy, enum phy_event event,
710
+ gfp_t gfp_flags);
711
+
721712 #endif /* _SASLIB_H_ */