1 .. SPDX-License-Identifier: GPL-2.0 1 .. SPDX-License-Identifier: GPL-2.0 2 2 3 ========= 3 ========= 4 SAS Layer 4 SAS Layer 5 ========= 5 ========= 6 6 7 The SAS Layer is a management infrastructure w 7 The SAS Layer is a management infrastructure which manages 8 SAS LLDDs. It sits between SCSI Core and SAS 8 SAS LLDDs. It sits between SCSI Core and SAS LLDDs. The 9 layout is as follows: while SCSI Core is conce 9 layout is as follows: while SCSI Core is concerned with 10 SAM/SPC issues, and a SAS LLDD+sequencer is co 10 SAM/SPC issues, and a SAS LLDD+sequencer is concerned with 11 phy/OOB/link management, the SAS layer is conc 11 phy/OOB/link management, the SAS layer is concerned with: 12 12 13 * SAS Phy/Port/HA event management (LLDD 13 * SAS Phy/Port/HA event management (LLDD generates, 14 SAS Layer processes), 14 SAS Layer processes), 15 * SAS Port management (creation/destruct 15 * SAS Port management (creation/destruction), 16 * SAS Domain discovery and revalidation, 16 * SAS Domain discovery and revalidation, 17 * SAS Domain device management, 17 * SAS Domain device management, 18 * SCSI Host registration/unregistration, 18 * SCSI Host registration/unregistration, 19 * Device registration with SCSI Core (SA 19 * Device registration with SCSI Core (SAS) or libata 20 (SATA), and 20 (SATA), and 21 * Expander management and exporting expa 21 * Expander management and exporting expander control 22 to user space. 22 to user space. 23 23 24 A SAS LLDD is a PCI device driver. It is conc 24 A SAS LLDD is a PCI device driver. It is concerned with 25 phy/OOB management, and vendor specific tasks 25 phy/OOB management, and vendor specific tasks and generates 26 events to the SAS layer. 26 events to the SAS layer. 27 27 28 The SAS Layer does most SAS tasks as outlined 28 The SAS Layer does most SAS tasks as outlined in the SAS 1.1 29 spec. 29 spec. 30 30 31 The sas_ha_struct describes the SAS LLDD to th 31 The sas_ha_struct describes the SAS LLDD to the SAS layer. 32 Most of it is used by the SAS Layer but a few 32 Most of it is used by the SAS Layer but a few fields need to 33 be initialized by the LLDDs. 33 be initialized by the LLDDs. 34 34 35 After initializing your hardware, from the pro 35 After initializing your hardware, from the probe() function 36 you call sas_register_ha(). It will register y 36 you call sas_register_ha(). It will register your LLDD with 37 the SCSI subsystem, creating a SCSI host and i 37 the SCSI subsystem, creating a SCSI host and it will 38 register your SAS driver with the sysfs SAS tr 38 register your SAS driver with the sysfs SAS tree it creates. 39 It will then return. Then you enable your phy 39 It will then return. Then you enable your phys to actually 40 start OOB (at which point your driver will sta 40 start OOB (at which point your driver will start calling the 41 notify_* event callbacks). 41 notify_* event callbacks). 42 42 43 Structure descriptions 43 Structure descriptions 44 ====================== 44 ====================== 45 45 46 ``struct sas_phy`` 46 ``struct sas_phy`` 47 ------------------ 47 ------------------ 48 48 49 Normally this is statically embedded to your d 49 Normally this is statically embedded to your driver's 50 phy structure:: 50 phy structure:: 51 51 52 struct my_phy { 52 struct my_phy { 53 blah; 53 blah; 54 struct sas_phy sas_phy; 54 struct sas_phy sas_phy; 55 bleh; 55 bleh; 56 }; 56 }; 57 57 58 And then all the phys are an array of my_phy i 58 And then all the phys are an array of my_phy in your HA 59 struct (shown below). 59 struct (shown below). 60 60 61 Then as you go along and initialize your phys 61 Then as you go along and initialize your phys you also 62 initialize the sas_phy struct, along with your 62 initialize the sas_phy struct, along with your own 63 phy structure. 63 phy structure. 64 64 65 In general, the phys are managed by the LLDD a 65 In general, the phys are managed by the LLDD and the ports 66 are managed by the SAS layer. So the phys are 66 are managed by the SAS layer. So the phys are initialized 67 and updated by the LLDD and the ports are init 67 and updated by the LLDD and the ports are initialized and 68 updated by the SAS layer. 68 updated by the SAS layer. 69 69 70 There is a scheme where the LLDD can RW certai 70 There is a scheme where the LLDD can RW certain fields, 71 and the SAS layer can only read such ones, and 71 and the SAS layer can only read such ones, and vice versa. 72 The idea is to avoid unnecessary locking. 72 The idea is to avoid unnecessary locking. 73 73 74 enabled 74 enabled 75 - must be set (0/1) 75 - must be set (0/1) 76 76 77 id 77 id 78 - must be set [0,MAX_PHYS)] 78 - must be set [0,MAX_PHYS)] 79 79 80 class, proto, type, role, oob_mode, linkrate 80 class, proto, type, role, oob_mode, linkrate 81 - must be set 81 - must be set 82 82 83 oob_mode 83 oob_mode 84 - you set this when OOB has finished and t 84 - you set this when OOB has finished and then notify 85 the SAS Layer. 85 the SAS Layer. 86 86 87 sas_addr 87 sas_addr 88 - this normally points to an array holding 88 - this normally points to an array holding the sas 89 address of the phy, possibly somewhere i 89 address of the phy, possibly somewhere in your my_phy 90 struct. 90 struct. 91 91 92 attached_sas_addr 92 attached_sas_addr 93 - set this when you (LLDD) receive an 93 - set this when you (LLDD) receive an 94 IDENTIFY frame or a FIS frame, _before_ 94 IDENTIFY frame or a FIS frame, _before_ notifying the SAS 95 layer. The idea is that sometimes the L 95 layer. The idea is that sometimes the LLDD may want to fake 96 or provide a different SAS address on th 96 or provide a different SAS address on that phy/port and this 97 allows it to do this. At best you shoul 97 allows it to do this. At best you should copy the sas 98 address from the IDENTIFY frame or maybe 98 address from the IDENTIFY frame or maybe generate a SAS 99 address for SATA directly attached devic 99 address for SATA directly attached devices. The Discover 100 process may later change this. 100 process may later change this. 101 101 102 frame_rcvd 102 frame_rcvd 103 - this is where you copy the IDENTIFY/FIS 103 - this is where you copy the IDENTIFY/FIS frame 104 when you get it; you lock, copy, set fra 104 when you get it; you lock, copy, set frame_rcvd_size and 105 unlock the lock, and then call the event 105 unlock the lock, and then call the event. It is a pointer 106 since there's no way to know your hw fra 106 since there's no way to know your hw frame size _exactly_, 107 so you define the actual array in your p 107 so you define the actual array in your phy struct and let 108 this pointer point to it. You copy the 108 this pointer point to it. You copy the frame from your 109 DMAable memory to that area holding the 109 DMAable memory to that area holding the lock. 110 110 111 sas_prim 111 sas_prim 112 - this is where primitives go when they're 112 - this is where primitives go when they're 113 received. See sas.h. Grab the lock, set 113 received. See sas.h. Grab the lock, set the primitive, 114 release the lock, notify. 114 release the lock, notify. 115 115 116 port 116 port 117 - this points to the sas_port if the phy b 117 - this points to the sas_port if the phy belongs 118 to a port -- the LLDD only reads this. I 118 to a port -- the LLDD only reads this. It points to the 119 sas_port this phy is part of. Set by th 119 sas_port this phy is part of. Set by the SAS Layer. 120 120 121 ha 121 ha 122 - may be set; the SAS layer sets it anyway 122 - may be set; the SAS layer sets it anyway. 123 123 124 lldd_phy 124 lldd_phy 125 - you should set this to point to your phy 125 - you should set this to point to your phy so you 126 can find your way around faster when the 126 can find your way around faster when the SAS layer calls one 127 of your callbacks and passes you a phy. 127 of your callbacks and passes you a phy. If the sas_phy is 128 embedded you can also use container_of - 128 embedded you can also use container_of -- whatever you 129 prefer. 129 prefer. 130 130 131 131 132 ``struct sas_port`` 132 ``struct sas_port`` 133 ------------------- 133 ------------------- 134 134 135 The LLDD doesn't set any fields of this struct 135 The LLDD doesn't set any fields of this struct -- it only 136 reads them. They should be self explanatory. 136 reads them. They should be self explanatory. 137 137 138 phy_mask is 32 bit, this should be enough for 138 phy_mask is 32 bit, this should be enough for now, as I 139 haven't heard of a HA having more than 8 phys. 139 haven't heard of a HA having more than 8 phys. 140 140 141 lldd_port 141 lldd_port 142 - I haven't found use for that -- maybe ot 142 - I haven't found use for that -- maybe other 143 LLDD who wish to have internal port repr 143 LLDD who wish to have internal port representation can make 144 use of this. 144 use of this. 145 145 146 ``struct sas_ha_struct`` 146 ``struct sas_ha_struct`` 147 ------------------------ 147 ------------------------ 148 148 149 It normally is statically declared in your own 149 It normally is statically declared in your own LLDD 150 structure describing your adapter:: 150 structure describing your adapter:: 151 151 152 struct my_sas_ha { 152 struct my_sas_ha { 153 blah; 153 blah; 154 struct sas_ha_struct sas_ha; 154 struct sas_ha_struct sas_ha; 155 struct my_phy phys[MAX_PHYS]; 155 struct my_phy phys[MAX_PHYS]; 156 struct sas_port sas_ports[MAX_PHYS]; / 156 struct sas_port sas_ports[MAX_PHYS]; /* (1) */ 157 bleh; 157 bleh; 158 }; 158 }; 159 159 160 (1) If your LLDD doesn't have its own port 160 (1) If your LLDD doesn't have its own port representation. 161 161 162 What needs to be initialized (sample function 162 What needs to be initialized (sample function given below). 163 163 164 pcidev 164 pcidev 165 ^^^^^^ 165 ^^^^^^ 166 166 167 sas_addr 167 sas_addr 168 - since the SAS layer doesn't want to m 168 - since the SAS layer doesn't want to mess with 169 memory allocation, etc, this points t 169 memory allocation, etc, this points to statically 170 allocated array somewhere (say in you 170 allocated array somewhere (say in your host adapter 171 structure) and holds the SAS address 171 structure) and holds the SAS address of the host 172 adapter as given by you or the manufa 172 adapter as given by you or the manufacturer, etc. 173 173 174 sas_port 174 sas_port 175 ^^^^^^^^ 175 ^^^^^^^^ 176 176 177 sas_phy 177 sas_phy 178 - an array of pointers to structures. (s 178 - an array of pointers to structures. (see 179 note above on sas_addr). 179 note above on sas_addr). 180 These must be set. See more notes bel 180 These must be set. See more notes below. 181 181 182 num_phys 182 num_phys 183 - the number of phys present in the sas 183 - the number of phys present in the sas_phy array, 184 and the number of ports present in th 184 and the number of ports present in the sas_port 185 array. There can be a maximum num_ph 185 array. There can be a maximum num_phys ports (one per 186 port) so we drop the num_ports, and o 186 port) so we drop the num_ports, and only use 187 num_phys. 187 num_phys. 188 188 189 The event interface:: 189 The event interface:: 190 190 191 /* LLDD calls these to notify the clas 191 /* LLDD calls these to notify the class of an event. */ 192 void sas_notify_port_event(struct sas_ !! 192 void (*notify_ha_event)(struct sas_ha_struct *, enum ha_event); 193 void sas_notify_phy_event(struct sas_p !! 193 void sas_notify_port_event(struct sas_phy *, enum port_event); >> 194 void sas_notify_phy_event(struct sas_phy *, enum phy_event); >> 195 void sas_notify_port_event_gfp(struct sas_phy *, enum port_event, gfp_t); >> 196 void sas_notify_phy_event_gfp(struct sas_phy *, enum phy_event, gfp_t); 194 197 195 The port notification:: 198 The port notification:: 196 199 197 /* The class calls these to notify the 200 /* The class calls these to notify the LLDD of an event. */ 198 void (*lldd_port_formed)(struct sas_ph 201 void (*lldd_port_formed)(struct sas_phy *); 199 void (*lldd_port_deformed)(struct sas_ 202 void (*lldd_port_deformed)(struct sas_phy *); 200 203 201 If the LLDD wants notification when a port has 204 If the LLDD wants notification when a port has been formed 202 or deformed it sets those to a function satisf 205 or deformed it sets those to a function satisfying the type. 203 206 204 A SAS LLDD should also implement at least one 207 A SAS LLDD should also implement at least one of the Task 205 Management Functions (TMFs) described in SAM:: 208 Management Functions (TMFs) described in SAM:: 206 209 207 /* Task Management Functions. Must be 210 /* Task Management Functions. Must be called from process context. */ 208 int (*lldd_abort_task)(struct sas_task 211 int (*lldd_abort_task)(struct sas_task *); 209 int (*lldd_abort_task_set)(struct doma 212 int (*lldd_abort_task_set)(struct domain_device *, u8 *lun); >> 213 int (*lldd_clear_aca)(struct domain_device *, u8 *lun); 210 int (*lldd_clear_task_set)(struct doma 214 int (*lldd_clear_task_set)(struct domain_device *, u8 *lun); 211 int (*lldd_I_T_nexus_reset)(struct dom 215 int (*lldd_I_T_nexus_reset)(struct domain_device *); 212 int (*lldd_lu_reset)(struct domain_dev 216 int (*lldd_lu_reset)(struct domain_device *, u8 *lun); 213 int (*lldd_query_task)(struct sas_task 217 int (*lldd_query_task)(struct sas_task *); 214 218 215 For more information please read SAM from T10. 219 For more information please read SAM from T10.org. 216 220 217 Port and Adapter management:: 221 Port and Adapter management:: 218 222 219 /* Port and Adapter management */ 223 /* Port and Adapter management */ 220 int (*lldd_clear_nexus_port)(struct sa 224 int (*lldd_clear_nexus_port)(struct sas_port *); 221 int (*lldd_clear_nexus_ha)(struct sas_ 225 int (*lldd_clear_nexus_ha)(struct sas_ha_struct *); 222 226 223 A SAS LLDD should implement at least one of th 227 A SAS LLDD should implement at least one of those. 224 228 225 Phy management:: 229 Phy management:: 226 230 227 /* Phy management */ 231 /* Phy management */ 228 int (*lldd_control_phy)(struct sas_phy 232 int (*lldd_control_phy)(struct sas_phy *, enum phy_func); 229 233 230 lldd_ha 234 lldd_ha 231 - set this to point to your HA struct. You 235 - set this to point to your HA struct. You can also 232 use container_of if you embedded it as s 236 use container_of if you embedded it as shown above. 233 237 234 A sample initialization and registration funct 238 A sample initialization and registration function 235 can look like this (called last thing from pro 239 can look like this (called last thing from probe()) 236 *but* before you enable the phys to do OOB:: 240 *but* before you enable the phys to do OOB:: 237 241 238 static int register_sas_ha(struct my_sas_h 242 static int register_sas_ha(struct my_sas_ha *my_ha) 239 { 243 { 240 int i; 244 int i; 241 static struct sas_phy *sas_phys[ 245 static struct sas_phy *sas_phys[MAX_PHYS]; 242 static struct sas_port *sas_ports 246 static struct sas_port *sas_ports[MAX_PHYS]; 243 247 244 my_ha->sas_ha.sas_addr = &my_ha->s 248 my_ha->sas_ha.sas_addr = &my_ha->sas_addr[0]; 245 249 246 for (i = 0; i < MAX_PHYS; i++) { 250 for (i = 0; i < MAX_PHYS; i++) { 247 sas_phys[i] = &my_ha->phys 251 sas_phys[i] = &my_ha->phys[i].sas_phy; 248 sas_ports[i] = &my_ha->sas 252 sas_ports[i] = &my_ha->sas_ports[i]; 249 } 253 } 250 254 251 my_ha->sas_ha.sas_phy = sas_phys; 255 my_ha->sas_ha.sas_phy = sas_phys; 252 my_ha->sas_ha.sas_port = sas_ports 256 my_ha->sas_ha.sas_port = sas_ports; 253 my_ha->sas_ha.num_phys = MAX_PHYS; 257 my_ha->sas_ha.num_phys = MAX_PHYS; 254 258 255 my_ha->sas_ha.lldd_port_formed = m 259 my_ha->sas_ha.lldd_port_formed = my_port_formed; 256 260 257 my_ha->sas_ha.lldd_dev_found = my_ 261 my_ha->sas_ha.lldd_dev_found = my_dev_found; 258 my_ha->sas_ha.lldd_dev_gone = my_d 262 my_ha->sas_ha.lldd_dev_gone = my_dev_gone; 259 263 260 my_ha->sas_ha.lldd_execute_task = 264 my_ha->sas_ha.lldd_execute_task = my_execute_task; 261 265 262 my_ha->sas_ha.lldd_abort_task 266 my_ha->sas_ha.lldd_abort_task = my_abort_task; 263 my_ha->sas_ha.lldd_abort_task_set 267 my_ha->sas_ha.lldd_abort_task_set = my_abort_task_set; >> 268 my_ha->sas_ha.lldd_clear_aca = my_clear_aca; 264 my_ha->sas_ha.lldd_clear_task_set 269 my_ha->sas_ha.lldd_clear_task_set = my_clear_task_set; 265 my_ha->sas_ha.lldd_I_T_nexus_reset 270 my_ha->sas_ha.lldd_I_T_nexus_reset= NULL; (2) 266 my_ha->sas_ha.lldd_lu_reset 271 my_ha->sas_ha.lldd_lu_reset = my_lu_reset; 267 my_ha->sas_ha.lldd_query_task 272 my_ha->sas_ha.lldd_query_task = my_query_task; 268 273 269 my_ha->sas_ha.lldd_clear_nexus_por 274 my_ha->sas_ha.lldd_clear_nexus_port = my_clear_nexus_port; 270 my_ha->sas_ha.lldd_clear_nexus_ha 275 my_ha->sas_ha.lldd_clear_nexus_ha = my_clear_nexus_ha; 271 276 272 my_ha->sas_ha.lldd_control_phy = m 277 my_ha->sas_ha.lldd_control_phy = my_control_phy; 273 278 274 return sas_register_ha(&my_ha->sas 279 return sas_register_ha(&my_ha->sas_ha); 275 } 280 } 276 281 277 (2) SAS 1.1 does not define I_T Nexus Reset TM 282 (2) SAS 1.1 does not define I_T Nexus Reset TMF. 278 283 279 Events 284 Events 280 ====== 285 ====== 281 286 282 Events are **the only way** a SAS LLDD notifie 287 Events are **the only way** a SAS LLDD notifies the SAS layer 283 of anything. There is no other method or way 288 of anything. There is no other method or way a LLDD to tell 284 the SAS layer of anything happening internally 289 the SAS layer of anything happening internally or in the SAS 285 domain. 290 domain. 286 291 287 Phy events:: 292 Phy events:: 288 293 289 PHYE_LOSS_OF_SIGNAL, (C) 294 PHYE_LOSS_OF_SIGNAL, (C) 290 PHYE_OOB_DONE, 295 PHYE_OOB_DONE, 291 PHYE_OOB_ERROR, (C) 296 PHYE_OOB_ERROR, (C) 292 PHYE_SPINUP_HOLD. 297 PHYE_SPINUP_HOLD. 293 298 294 Port events, passed on a _phy_:: 299 Port events, passed on a _phy_:: 295 300 296 PORTE_BYTES_DMAED, (M) 301 PORTE_BYTES_DMAED, (M) 297 PORTE_BROADCAST_RCVD, (E) 302 PORTE_BROADCAST_RCVD, (E) 298 PORTE_LINK_RESET_ERR, (C) 303 PORTE_LINK_RESET_ERR, (C) 299 PORTE_TIMER_EVENT, (C) 304 PORTE_TIMER_EVENT, (C) 300 PORTE_HARD_RESET. 305 PORTE_HARD_RESET. 301 306 302 Host Adapter event: 307 Host Adapter event: 303 HAE_RESET 308 HAE_RESET 304 309 305 A SAS LLDD should be able to generate 310 A SAS LLDD should be able to generate 306 311 307 - at least one event from group C (cho 312 - at least one event from group C (choice), 308 - events marked M (mandatory) are mand 313 - events marked M (mandatory) are mandatory (only one), 309 - events marked E (expander) if it wan 314 - events marked E (expander) if it wants the SAS layer 310 to handle domain revalidation (only 315 to handle domain revalidation (only one such). 311 - Unmarked events are optional. 316 - Unmarked events are optional. 312 317 313 Meaning: 318 Meaning: 314 319 315 HAE_RESET 320 HAE_RESET 316 - when your HA got internal error and was 321 - when your HA got internal error and was reset. 317 322 318 PORTE_BYTES_DMAED 323 PORTE_BYTES_DMAED 319 - on receiving an IDENTIFY/FIS frame 324 - on receiving an IDENTIFY/FIS frame 320 325 321 PORTE_BROADCAST_RCVD 326 PORTE_BROADCAST_RCVD 322 - on receiving a primitive 327 - on receiving a primitive 323 328 324 PORTE_LINK_RESET_ERR 329 PORTE_LINK_RESET_ERR 325 - timer expired, loss of signal, loss of D 330 - timer expired, loss of signal, loss of DWS, etc. [1]_ 326 331 327 PORTE_TIMER_EVENT 332 PORTE_TIMER_EVENT 328 - DWS reset timeout timer expired [1]_ 333 - DWS reset timeout timer expired [1]_ 329 334 330 PORTE_HARD_RESET 335 PORTE_HARD_RESET 331 - Hard Reset primitive received. 336 - Hard Reset primitive received. 332 337 333 PHYE_LOSS_OF_SIGNAL 338 PHYE_LOSS_OF_SIGNAL 334 - the device is gone [1]_ 339 - the device is gone [1]_ 335 340 336 PHYE_OOB_DONE 341 PHYE_OOB_DONE 337 - OOB went fine and oob_mode is valid 342 - OOB went fine and oob_mode is valid 338 343 339 PHYE_OOB_ERROR 344 PHYE_OOB_ERROR 340 - Error while doing OOB, the device probab 345 - Error while doing OOB, the device probably 341 got disconnected. [1]_ 346 got disconnected. [1]_ 342 347 343 PHYE_SPINUP_HOLD 348 PHYE_SPINUP_HOLD 344 - SATA is present, COMWAKE not sent. 349 - SATA is present, COMWAKE not sent. 345 350 346 .. [1] should set/clear the appropriate fields 351 .. [1] should set/clear the appropriate fields in the phy, 347 or alternatively call the inlined sas_p 352 or alternatively call the inlined sas_phy_disconnected() 348 which is just a helper, from their task 353 which is just a helper, from their tasklet. 349 354 350 The Execute Command SCSI RPC:: 355 The Execute Command SCSI RPC:: 351 356 352 int (*lldd_execute_task)(struct sas_ta 357 int (*lldd_execute_task)(struct sas_task *, gfp_t gfp_flags); 353 358 354 Used to queue a task to the SAS LLDD. @task i 359 Used to queue a task to the SAS LLDD. @task is the task to be executed. 355 @gfp_mask is the gfp_mask defining the context 360 @gfp_mask is the gfp_mask defining the context of the caller. 356 361 357 This function should implement the Execute Com 362 This function should implement the Execute Command SCSI RPC, 358 363 359 That is, when lldd_execute_task() is called, t 364 That is, when lldd_execute_task() is called, the command 360 go out on the transport *immediately*. There 365 go out on the transport *immediately*. There is *no* 361 queuing of any sort and at any level in a SAS 366 queuing of any sort and at any level in a SAS LLDD. 362 367 363 Returns: 368 Returns: 364 369 365 * -SAS_QUEUE_FULL, -ENOMEM, nothing was que 370 * -SAS_QUEUE_FULL, -ENOMEM, nothing was queued; 366 * 0, the task(s) were queued. 371 * 0, the task(s) were queued. 367 372 368 :: 373 :: 369 374 370 struct sas_task { 375 struct sas_task { 371 dev -- the device this task is des 376 dev -- the device this task is destined to 372 task_proto -- _one_ of enum sas_pr 377 task_proto -- _one_ of enum sas_proto 373 scatter -- pointer to scatter gath 378 scatter -- pointer to scatter gather list array 374 num_scatter -- number of elements 379 num_scatter -- number of elements in scatter 375 total_xfer_len -- total number of 380 total_xfer_len -- total number of bytes expected to be transferred 376 data_dir -- PCI_DMA_... 381 data_dir -- PCI_DMA_... 377 task_done -- callback when the tas 382 task_done -- callback when the task has finished execution 378 }; 383 }; 379 384 380 Discovery 385 Discovery 381 ========= 386 ========= 382 387 383 The sysfs tree has the following purposes: 388 The sysfs tree has the following purposes: 384 389 385 a) It shows you the physical layout of the 390 a) It shows you the physical layout of the SAS domain at 386 the current time, i.e. how the domain l 391 the current time, i.e. how the domain looks in the 387 physical world right now. 392 physical world right now. 388 b) Shows some device parameters _at_discov 393 b) Shows some device parameters _at_discovery_time_. 389 394 390 This is a link to the tree(1) program, very us 395 This is a link to the tree(1) program, very useful in 391 viewing the SAS domain: 396 viewing the SAS domain: 392 ftp://mama.indstate.edu/linux/tree/ 397 ftp://mama.indstate.edu/linux/tree/ 393 398 394 I expect user space applications to actually c 399 I expect user space applications to actually create a 395 graphical interface of this. 400 graphical interface of this. 396 401 397 That is, the sysfs domain tree doesn't show or 402 That is, the sysfs domain tree doesn't show or keep state if 398 you e.g., change the meaning of the READY LED 403 you e.g., change the meaning of the READY LED MEANING 399 setting, but it does show you the current conn 404 setting, but it does show you the current connection status 400 of the domain device. 405 of the domain device. 401 406 402 Keeping internal device state changes is respo 407 Keeping internal device state changes is responsibility of 403 upper layers (Command set drivers) and user sp 408 upper layers (Command set drivers) and user space. 404 409 405 When a device or devices are unplugged from th 410 When a device or devices are unplugged from the domain, this 406 is reflected in the sysfs tree immediately, an 411 is reflected in the sysfs tree immediately, and the device(s) 407 removed from the system. 412 removed from the system. 408 413 409 The structure domain_device describes any devi 414 The structure domain_device describes any device in the SAS 410 domain. It is completely managed by the SAS l 415 domain. It is completely managed by the SAS layer. A task 411 points to a domain device, this is how the SAS 416 points to a domain device, this is how the SAS LLDD knows 412 where to send the task(s) to. A SAS LLDD only 417 where to send the task(s) to. A SAS LLDD only reads the 413 contents of the domain_device structure, but i 418 contents of the domain_device structure, but it never creates 414 or destroys one. 419 or destroys one. 415 420 416 Expander management from User Space 421 Expander management from User Space 417 =================================== 422 =================================== 418 423 419 In each expander directory in sysfs, there is 424 In each expander directory in sysfs, there is a file called 420 "smp_portal". It is a binary sysfs attribute 425 "smp_portal". It is a binary sysfs attribute file, which 421 implements an SMP portal (Note: this is *NOT* 426 implements an SMP portal (Note: this is *NOT* an SMP port), 422 to which user space applications can send SMP 427 to which user space applications can send SMP requests and 423 receive SMP responses. 428 receive SMP responses. 424 429 425 Functionality is deceptively simple: 430 Functionality is deceptively simple: 426 431 427 1. Build the SMP frame you want to send. The f 432 1. Build the SMP frame you want to send. The format and layout 428 is described in the SAS spec. Leave the CR 433 is described in the SAS spec. Leave the CRC field equal 0. 429 434 430 open(2) 435 open(2) 431 436 432 2. Open the expander's SMP portal sysfs file i 437 2. Open the expander's SMP portal sysfs file in RW mode. 433 438 434 write(2) 439 write(2) 435 440 436 3. Write the frame you built in 1. 441 3. Write the frame you built in 1. 437 442 438 read(2) 443 read(2) 439 444 440 4. Read the amount of data you expect to recei 445 4. Read the amount of data you expect to receive for the frame you built. 441 If you receive different amount of data you 446 If you receive different amount of data you expected to receive, 442 then there was some kind of error. 447 then there was some kind of error. 443 448 444 close(2) 449 close(2) 445 450 446 All this process is shown in detail in the fun 451 All this process is shown in detail in the function do_smp_func() 447 and its callers, in the file "expander_conf.c" 452 and its callers, in the file "expander_conf.c". 448 453 449 The kernel functionality is implemented in the 454 The kernel functionality is implemented in the file 450 "sas_expander.c". 455 "sas_expander.c". 451 456 452 The program "expander_conf.c" implements this. 457 The program "expander_conf.c" implements this. It takes one 453 argument, the sysfs file name of the SMP porta 458 argument, the sysfs file name of the SMP portal to the 454 expander, and gives expander information, incl 459 expander, and gives expander information, including routing 455 tables. 460 tables. 456 461 457 The SMP portal gives you complete control of t 462 The SMP portal gives you complete control of the expander, 458 so please be careful. 463 so please be careful.
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.