Commit d7a0ccdd9bd78b5b74d2963ec7ab67c9d896902a

Authored by Dan Williams
Committed by James Bottomley
1 parent 16d3db1b29

[SCSI] isci: debug, provide state-enum-to-string conversions

Debugging the driver requires tracing the state transtions and tracing
state names is less work than decoding numbers.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>

Showing 10 changed files with 432 additions and 520 deletions Side-by-side Diff

drivers/scsi/isci/phy.c
... ... @@ -59,6 +59,16 @@
59 59 #include "scu_event_codes.h"
60 60 #include "probe_roms.h"
61 61  
  62 +#undef C
  63 +#define C(a) (#a)
  64 +static const char *phy_state_name(enum sci_phy_states state)
  65 +{
  66 + static const char * const strings[] = PHY_STATES;
  67 +
  68 + return strings[state];
  69 +}
  70 +#undef C
  71 +
62 72 /* Maximum arbitration wait time in micro-seconds */
63 73 #define SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME (700)
64 74  
... ... @@ -454,8 +464,8 @@
454 464 enum sci_phy_states state = iphy->sm.current_state_id;
455 465  
456 466 if (state != SCI_PHY_STOPPED) {
457   - dev_dbg(sciphy_to_dev(iphy),
458   - "%s: in wrong state: %d\n", __func__, state);
  467 + dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
  468 + __func__, phy_state_name(state));
459 469 return SCI_FAILURE_INVALID_STATE;
460 470 }
461 471  
... ... @@ -480,8 +490,8 @@
480 490 case SCI_PHY_READY:
481 491 break;
482 492 default:
483   - dev_dbg(sciphy_to_dev(iphy),
484   - "%s: in wrong state: %d\n", __func__, state);
  493 + dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
  494 + __func__, phy_state_name(state));
485 495 return SCI_FAILURE_INVALID_STATE;
486 496 }
487 497  
... ... @@ -494,8 +504,8 @@
494 504 enum sci_phy_states state = iphy->sm.current_state_id;
495 505  
496 506 if (state != SCI_PHY_READY) {
497   - dev_dbg(sciphy_to_dev(iphy),
498   - "%s: in wrong state: %d\n", __func__, state);
  507 + dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
  508 + __func__, phy_state_name(state));
499 509 return SCI_FAILURE_INVALID_STATE;
500 510 }
501 511  
... ... @@ -544,8 +554,8 @@
544 554 return SCI_SUCCESS;
545 555 }
546 556 default:
547   - dev_dbg(sciphy_to_dev(iphy),
548   - "%s: in wrong state: %d\n", __func__, state);
  557 + dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
  558 + __func__, phy_state_name(state));
549 559 return SCI_FAILURE_INVALID_STATE;
550 560 }
551 561 }
... ... @@ -870,8 +880,8 @@
870 880 }
871 881 return SCI_SUCCESS;
872 882 default:
873   - dev_dbg(sciphy_to_dev(iphy),
874   - "%s: in wrong state: %d\n", __func__, state);
  883 + dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
  884 + __func__, phy_state_name(state));
875 885 return SCI_FAILURE_INVALID_STATE;
876 886 }
877 887 }
... ... @@ -964,8 +974,8 @@
964 974 return result;
965 975 }
966 976 default:
967   - dev_dbg(sciphy_to_dev(iphy),
968   - "%s: in wrong state: %d\n", __func__, state);
  977 + dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
  978 + __func__, phy_state_name(state));
969 979 return SCI_FAILURE_INVALID_STATE;
970 980 }
971 981  
drivers/scsi/isci/phy.h
... ... @@ -343,101 +343,65 @@
343 343 SCIC_PHY_COUNTER_SN_DWORD_SYNC_ERROR
344 344 };
345 345  
346   -enum sci_phy_states {
347   - /**
348   - * Simply the initial state for the base domain state machine.
349   - */
350   - SCI_PHY_INITIAL,
351   -
352   - /**
353   - * This state indicates that the phy has successfully been stopped.
354   - * In this state no new IO operations are permitted on this phy.
355   - * This state is entered from the INITIAL state.
356   - * This state is entered from the STARTING state.
357   - * This state is entered from the READY state.
358   - * This state is entered from the RESETTING state.
359   - */
360   - SCI_PHY_STOPPED,
361   -
362   - /**
363   - * This state indicates that the phy is in the process of becomming
364   - * ready. In this state no new IO operations are permitted on this phy.
365   - * This state is entered from the STOPPED state.
366   - * This state is entered from the READY state.
367   - * This state is entered from the RESETTING state.
368   - */
369   - SCI_PHY_STARTING,
370   -
371   - /**
372   - * Initial state
373   - */
374   - SCI_PHY_SUB_INITIAL,
375   -
376   - /**
377   - * Wait state for the hardware OSSP event type notification
378   - */
379   - SCI_PHY_SUB_AWAIT_OSSP_EN,
380   -
381   - /**
382   - * Wait state for the PHY speed notification
383   - */
384   - SCI_PHY_SUB_AWAIT_SAS_SPEED_EN,
385   -
386   - /**
387   - * Wait state for the IAF Unsolicited frame notification
388   - */
389   - SCI_PHY_SUB_AWAIT_IAF_UF,
390   -
391   - /**
392   - * Wait state for the request to consume power
393   - */
394   - SCI_PHY_SUB_AWAIT_SAS_POWER,
395   -
396   - /**
397   - * Wait state for request to consume power
398   - */
399   - SCI_PHY_SUB_AWAIT_SATA_POWER,
400   -
401   - /**
402   - * Wait state for the SATA PHY notification
403   - */
404   - SCI_PHY_SUB_AWAIT_SATA_PHY_EN,
405   -
406   - /**
407   - * Wait for the SATA PHY speed notification
408   - */
409   - SCI_PHY_SUB_AWAIT_SATA_SPEED_EN,
410   -
411   - /**
412   - * Wait state for the SIGNATURE FIS unsolicited frame notification
413   - */
414   - SCI_PHY_SUB_AWAIT_SIG_FIS_UF,
415   -
416   - /**
417   - * Exit state for this state machine
418   - */
419   - SCI_PHY_SUB_FINAL,
420   -
421   - /**
422   - * This state indicates the the phy is now ready. Thus, the user
423   - * is able to perform IO operations utilizing this phy as long as it
424   - * is currently part of a valid port.
425   - * This state is entered from the STARTING state.
426   - */
427   - SCI_PHY_READY,
428   -
429   - /**
430   - * This state indicates that the phy is in the process of being reset.
431   - * In this state no new IO operations are permitted on this phy.
432   - * This state is entered from the READY state.
433   - */
434   - SCI_PHY_RESETTING,
435   -
436   - /**
437   - * Simply the final state for the base phy state machine.
438   - */
439   - SCI_PHY_FINAL,
440   -};
  346 +/**
  347 + * enum sci_phy_states - phy state machine states
  348 + * @SCI_PHY_INITIAL: Simply the initial state for the base domain state
  349 + * machine.
  350 + * @SCI_PHY_STOPPED: phy has successfully been stopped. In this state
  351 + * no new IO operations are permitted on this phy.
  352 + * @SCI_PHY_STARTING: the phy is in the process of becomming ready. In
  353 + * this state no new IO operations are permitted on
  354 + * this phy.
  355 + * @SCI_PHY_SUB_INITIAL: Initial state
  356 + * @SCI_PHY_SUB_AWAIT_OSSP_EN: Wait state for the hardware OSSP event
  357 + * type notification
  358 + * @SCI_PHY_SUB_AWAIT_SAS_SPEED_EN: Wait state for the PHY speed
  359 + * notification
  360 + * @SCI_PHY_SUB_AWAIT_IAF_UF: Wait state for the IAF Unsolicited frame
  361 + * notification
  362 + * @SCI_PHY_SUB_AWAIT_SAS_POWER: Wait state for the request to consume
  363 + * power
  364 + * @SCI_PHY_SUB_AWAIT_SATA_POWER: Wait state for request to consume
  365 + * power
  366 + * @SCI_PHY_SUB_AWAIT_SATA_PHY_EN: Wait state for the SATA PHY
  367 + * notification
  368 + * @SCI_PHY_SUB_AWAIT_SATA_SPEED_EN: Wait for the SATA PHY speed
  369 + * notification
  370 + * @SCI_PHY_SUB_AWAIT_SIG_FIS_UF: Wait state for the SIGNATURE FIS
  371 + * unsolicited frame notification
  372 + * @SCI_PHY_SUB_FINAL: Exit state for this state machine
  373 + * @SCI_PHY_READY: phy is now ready. Thus, the user is able to perform
  374 + * IO operations utilizing this phy as long as it is
  375 + * currently part of a valid port. This state is
  376 + * entered from the STARTING state.
  377 + * @SCI_PHY_RESETTING: phy is in the process of being reset. In this
  378 + * state no new IO operations are permitted on this
  379 + * phy. This state is entered from the READY state.
  380 + * @SCI_PHY_FINAL: Simply the final state for the base phy state
  381 + * machine.
  382 + */
  383 +#define PHY_STATES {\
  384 + C(PHY_INITIAL),\
  385 + C(PHY_STOPPED),\
  386 + C(PHY_STARTING),\
  387 + C(PHY_SUB_INITIAL),\
  388 + C(PHY_SUB_AWAIT_OSSP_EN),\
  389 + C(PHY_SUB_AWAIT_SAS_SPEED_EN),\
  390 + C(PHY_SUB_AWAIT_IAF_UF),\
  391 + C(PHY_SUB_AWAIT_SAS_POWER),\
  392 + C(PHY_SUB_AWAIT_SATA_POWER),\
  393 + C(PHY_SUB_AWAIT_SATA_PHY_EN),\
  394 + C(PHY_SUB_AWAIT_SATA_SPEED_EN),\
  395 + C(PHY_SUB_AWAIT_SIG_FIS_UF),\
  396 + C(PHY_SUB_FINAL),\
  397 + C(PHY_READY),\
  398 + C(PHY_RESETTING),\
  399 + C(PHY_FINAL),\
  400 + }
  401 +#undef C
  402 +#define C(a) SCI_##a
  403 +enum sci_phy_states PHY_STATES;
  404 +#undef C
441 405  
442 406 void sci_phy_construct(
443 407 struct isci_phy *iphy,
drivers/scsi/isci/port.c
... ... @@ -60,6 +60,16 @@
60 60 #define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000)
61 61 #define SCU_DUMMY_INDEX (0xFFFF)
62 62  
  63 +#undef C
  64 +#define C(a) (#a)
  65 +const char *port_state_name(enum sci_port_states state)
  66 +{
  67 + static const char * const strings[] = PORT_STATES;
  68 +
  69 + return strings[state];
  70 +}
  71 +#undef C
  72 +
63 73 static struct device *sciport_to_dev(struct isci_port *iport)
64 74 {
65 75 int i = iport->physical_port_index;
... ... @@ -1054,8 +1064,8 @@
1054 1064  
1055 1065 state = iport->sm.current_state_id;
1056 1066 if (state != SCI_PORT_STOPPED) {
1057   - dev_warn(sciport_to_dev(iport),
1058   - "%s: in wrong state: %d\n", __func__, state);
  1067 + dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
  1068 + __func__, port_state_name(state));
1059 1069 return SCI_FAILURE_INVALID_STATE;
1060 1070 }
1061 1071  
... ... @@ -1129,8 +1139,8 @@
1129 1139 SCI_PORT_STOPPING);
1130 1140 return SCI_SUCCESS;
1131 1141 default:
1132   - dev_warn(sciport_to_dev(iport),
1133   - "%s: in wrong state: %d\n", __func__, state);
  1142 + dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
  1143 + __func__, port_state_name(state));
1134 1144 return SCI_FAILURE_INVALID_STATE;
1135 1145 }
1136 1146 }
... ... @@ -1144,8 +1154,8 @@
1144 1154  
1145 1155 state = iport->sm.current_state_id;
1146 1156 if (state != SCI_PORT_SUB_OPERATIONAL) {
1147   - dev_warn(sciport_to_dev(iport),
1148   - "%s: in wrong state: %d\n", __func__, state);
  1157 + dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
  1158 + __func__, port_state_name(state));
1149 1159 return SCI_FAILURE_INVALID_STATE;
1150 1160 }
1151 1161  
... ... @@ -1239,8 +1249,8 @@
1239 1249 SCI_PORT_SUB_CONFIGURING);
1240 1250 return SCI_SUCCESS;
1241 1251 default:
1242   - dev_warn(sciport_to_dev(iport),
1243   - "%s: in wrong state: %d\n", __func__, state);
  1252 + dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
  1253 + __func__, port_state_name(state));
1244 1254 return SCI_FAILURE_INVALID_STATE;
1245 1255 }
1246 1256 }
... ... @@ -1289,8 +1299,8 @@
1289 1299 SCI_PORT_SUB_CONFIGURING);
1290 1300 return SCI_SUCCESS;
1291 1301 default:
1292   - dev_warn(sciport_to_dev(iport),
1293   - "%s: in wrong state: %d\n", __func__, state);
  1302 + dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
  1303 + __func__, port_state_name(state));
1294 1304 return SCI_FAILURE_INVALID_STATE;
1295 1305 }
1296 1306 }
... ... @@ -1332,8 +1342,8 @@
1332 1342 sci_port_general_link_up_handler(iport, iphy, PF_RESUME);
1333 1343 return SCI_SUCCESS;
1334 1344 default:
1335   - dev_warn(sciport_to_dev(iport),
1336   - "%s: in wrong state: %d\n", __func__, state);
  1345 + dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
  1346 + __func__, port_state_name(state));
1337 1347 return SCI_FAILURE_INVALID_STATE;
1338 1348 }
1339 1349 }
... ... @@ -1362,8 +1372,8 @@
1362 1372 sci_port_deactivate_phy(iport, iphy, false);
1363 1373 return SCI_SUCCESS;
1364 1374 default:
1365   - dev_warn(sciport_to_dev(iport),
1366   - "%s: in wrong state: %d\n", __func__, state);
  1375 + dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
  1376 + __func__, port_state_name(state));
1367 1377 return SCI_FAILURE_INVALID_STATE;
1368 1378 }
1369 1379 }
... ... @@ -1382,8 +1392,8 @@
1382 1392 iport->started_request_count++;
1383 1393 return SCI_SUCCESS;
1384 1394 default:
1385   - dev_warn(sciport_to_dev(iport),
1386   - "%s: in wrong state: %d\n", __func__, state);
  1395 + dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
  1396 + __func__, port_state_name(state));
1387 1397 return SCI_FAILURE_INVALID_STATE;
1388 1398 }
1389 1399 }
... ... @@ -1397,8 +1407,8 @@
1397 1407 state = iport->sm.current_state_id;
1398 1408 switch (state) {
1399 1409 case SCI_PORT_STOPPED:
1400   - dev_warn(sciport_to_dev(iport),
1401   - "%s: in wrong state: %d\n", __func__, state);
  1410 + dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
  1411 + __func__, port_state_name(state));
1402 1412 return SCI_FAILURE_INVALID_STATE;
1403 1413 case SCI_PORT_STOPPING:
1404 1414 sci_port_decrement_request_count(iport);
drivers/scsi/isci/port.h
... ... @@ -144,70 +144,47 @@
144 144 };
145 145  
146 146 /**
147   - * enum sci_port_states - This enumeration depicts all the states for the
148   - * common port state machine.
149   - *
150   - *
  147 + * enum sci_port_states - port state machine states
  148 + * @SCI_PORT_STOPPED: port has successfully been stopped. In this state
  149 + * no new IO operations are permitted. This state is
  150 + * entered from the STOPPING state.
  151 + * @SCI_PORT_STOPPING: port is in the process of stopping. In this
  152 + * state no new IO operations are permitted, but
  153 + * existing IO operations are allowed to complete.
  154 + * This state is entered from the READY state.
  155 + * @SCI_PORT_READY: port is now ready. Thus, the user is able to
  156 + * perform IO operations on this port. This state is
  157 + * entered from the STARTING state.
  158 + * @SCI_PORT_SUB_WAITING: port is started and ready but has no active
  159 + * phys.
  160 + * @SCI_PORT_SUB_OPERATIONAL: port is started and ready and there is at
  161 + * least one phy operational.
  162 + * @SCI_PORT_SUB_CONFIGURING: port is started and there was an
  163 + * add/remove phy event. This state is only
  164 + * used in Automatic Port Configuration Mode
  165 + * (APC)
  166 + * @SCI_PORT_RESETTING: port is in the process of performing a hard
  167 + * reset. Thus, the user is unable to perform IO
  168 + * operations on this port. This state is entered
  169 + * from the READY state.
  170 + * @SCI_PORT_FAILED: port has failed a reset request. This state is
  171 + * entered when a port reset request times out. This
  172 + * state is entered from the RESETTING state.
151 173 */
152   -enum sci_port_states {
153   - /**
154   - * This state indicates that the port has successfully been stopped.
155   - * In this state no new IO operations are permitted.
156   - * This state is entered from the STOPPING state.
157   - */
158   - SCI_PORT_STOPPED,
159   -
160   - /**
161   - * This state indicates that the port is in the process of stopping.
162   - * In this state no new IO operations are permitted, but existing IO
163   - * operations are allowed to complete.
164   - * This state is entered from the READY state.
165   - */
166   - SCI_PORT_STOPPING,
167   -
168   - /**
169   - * This state indicates the port is now ready. Thus, the user is
170   - * able to perform IO operations on this port.
171   - * This state is entered from the STARTING state.
172   - */
173   - SCI_PORT_READY,
174   -
175   - /**
176   - * The substate where the port is started and ready but has no
177   - * active phys.
178   - */
179   - SCI_PORT_SUB_WAITING,
180   -
181   - /**
182   - * The substate where the port is started and ready and there is
183   - * at least one phy operational.
184   - */
185   - SCI_PORT_SUB_OPERATIONAL,
186   -
187   - /**
188   - * The substate where the port is started and there was an
189   - * add/remove phy event. This state is only used in Automatic
190   - * Port Configuration Mode (APC)
191   - */
192   - SCI_PORT_SUB_CONFIGURING,
193   -
194   - /**
195   - * This state indicates the port is in the process of performing a hard
196   - * reset. Thus, the user is unable to perform IO operations on this
197   - * port.
198   - * This state is entered from the READY state.
199   - */
200   - SCI_PORT_RESETTING,
201   -
202   - /**
203   - * This state indicates the port has failed a reset request. This state
204   - * is entered when a port reset request times out.
205   - * This state is entered from the RESETTING state.
206   - */
207   - SCI_PORT_FAILED,
208   -
209   -
210   -};
  174 +#define PORT_STATES {\
  175 + C(PORT_STOPPED),\
  176 + C(PORT_STOPPING),\
  177 + C(PORT_READY),\
  178 + C(PORT_SUB_WAITING),\
  179 + C(PORT_SUB_OPERATIONAL),\
  180 + C(PORT_SUB_CONFIGURING),\
  181 + C(PORT_RESETTING),\
  182 + C(PORT_FAILED),\
  183 + }
  184 +#undef C
  185 +#define C(a) SCI_##a
  186 +enum sci_port_states PORT_STATES;
  187 +#undef C
211 188  
212 189 static inline void sci_port_decrement_request_count(struct isci_port *iport)
213 190 {
drivers/scsi/isci/remote_device.c
... ... @@ -62,6 +62,16 @@
62 62 #include "scu_event_codes.h"
63 63 #include "task.h"
64 64  
  65 +#undef C
  66 +#define C(a) (#a)
  67 +const char *dev_state_name(enum sci_remote_device_states state)
  68 +{
  69 + static const char * const strings[] = REMOTE_DEV_STATES;
  70 +
  71 + return strings[state];
  72 +}
  73 +#undef C
  74 +
65 75 /**
66 76 * isci_remote_device_not_ready() - This function is called by the ihost when
67 77 * the remote device is not ready. We mark the isci device as ready (not
... ... @@ -167,8 +177,8 @@
167 177 case SCI_DEV_FAILED:
168 178 case SCI_DEV_FINAL:
169 179 default:
170   - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n",
171   - __func__, state);
  180 + dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
  181 + __func__, dev_state_name(state));
172 182 return SCI_FAILURE_INVALID_STATE;
173 183 case SCI_DEV_STOPPED:
174 184 return SCI_SUCCESS;
... ... @@ -226,8 +236,8 @@
226 236 case SCI_DEV_RESETTING:
227 237 case SCI_DEV_FINAL:
228 238 default:
229   - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n",
230   - __func__, state);
  239 + dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
  240 + __func__, dev_state_name(state));
231 241 return SCI_FAILURE_INVALID_STATE;
232 242 case SCI_DEV_READY:
233 243 case SCI_STP_DEV_IDLE:
... ... @@ -246,8 +256,8 @@
246 256 enum sci_remote_device_states state = sm->current_state_id;
247 257  
248 258 if (state != SCI_DEV_RESETTING) {
249   - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n",
250   - __func__, state);
  259 + dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
  260 + __func__, dev_state_name(state));
251 261 return SCI_FAILURE_INVALID_STATE;
252 262 }
253 263  
... ... @@ -262,8 +272,8 @@
262 272 enum sci_remote_device_states state = sm->current_state_id;
263 273  
264 274 if (state != SCI_STP_DEV_CMD) {
265   - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n",
266   - __func__, state);
  275 + dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
  276 + __func__, dev_state_name(state));
267 277 return SCI_FAILURE_INVALID_STATE;
268 278 }
269 279  
... ... @@ -287,8 +297,8 @@
287 297 case SCI_SMP_DEV_IDLE:
288 298 case SCI_DEV_FINAL:
289 299 default:
290   - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n",
291   - __func__, state);
  300 + dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
  301 + __func__, dev_state_name(state));
292 302 /* Return the frame back to the controller */
293 303 sci_controller_release_frame(ihost, frame_index);
294 304 return SCI_FAILURE_INVALID_STATE;
... ... @@ -502,8 +512,8 @@
502 512 case SCI_DEV_RESETTING:
503 513 case SCI_DEV_FINAL:
504 514 default:
505   - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n",
506   - __func__, state);
  515 + dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
  516 + __func__, dev_state_name(state));
507 517 return SCI_FAILURE_INVALID_STATE;
508 518 case SCI_DEV_READY:
509 519 /* attempt to start an io request for this device object. The remote
... ... @@ -637,8 +647,8 @@
637 647 case SCI_DEV_FAILED:
638 648 case SCI_DEV_FINAL:
639 649 default:
640   - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n",
641   - __func__, state);
  650 + dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
  651 + __func__, dev_state_name(state));
642 652 return SCI_FAILURE_INVALID_STATE;
643 653 case SCI_DEV_READY:
644 654 case SCI_STP_DEV_AWAIT_RESET:
... ... @@ -721,8 +731,8 @@
721 731 case SCI_DEV_RESETTING:
722 732 case SCI_DEV_FINAL:
723 733 default:
724   - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n",
725   - __func__, state);
  734 + dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
  735 + __func__, dev_state_name(state));
726 736 return SCI_FAILURE_INVALID_STATE;
727 737 case SCI_STP_DEV_IDLE:
728 738 case SCI_STP_DEV_CMD:
... ... @@ -853,8 +863,8 @@
853 863 struct isci_host *ihost;
854 864  
855 865 if (state != SCI_DEV_STOPPED) {
856   - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n",
857   - __func__, state);
  866 + dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
  867 + __func__, dev_state_name(state));
858 868 return SCI_FAILURE_INVALID_STATE;
859 869 }
860 870  
... ... @@ -1204,8 +1214,8 @@
1204 1214 enum sci_status status;
1205 1215  
1206 1216 if (state != SCI_DEV_STOPPED) {
1207   - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n",
1208   - __func__, state);
  1217 + dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
  1218 + __func__, dev_state_name(state));
1209 1219 return SCI_FAILURE_INVALID_STATE;
1210 1220 }
1211 1221  
drivers/scsi/isci/remote_device.h
... ... @@ -179,122 +179,101 @@
179 179 /**
180 180 * enum sci_remote_device_states - This enumeration depicts all the states
181 181 * for the common remote device state machine.
  182 + * @SCI_DEV_INITIAL: Simply the initial state for the base remote device
  183 + * state machine.
182 184 *
  185 + * @SCI_DEV_STOPPED: This state indicates that the remote device has
  186 + * successfully been stopped. In this state no new IO operations are
  187 + * permitted. This state is entered from the INITIAL state. This state
  188 + * is entered from the STOPPING state.
183 189 *
  190 + * @SCI_DEV_STARTING: This state indicates the the remote device is in
  191 + * the process of becoming ready (i.e. starting). In this state no new
  192 + * IO operations are permitted. This state is entered from the STOPPED
  193 + * state.
  194 + *
  195 + * @SCI_DEV_READY: This state indicates the remote device is now ready.
  196 + * Thus, the user is able to perform IO operations on the remote device.
  197 + * This state is entered from the STARTING state.
  198 + *
  199 + * @SCI_STP_DEV_IDLE: This is the idle substate for the stp remote
  200 + * device. When there are no active IO for the device it is is in this
  201 + * state.
  202 + *
  203 + * @SCI_STP_DEV_CMD: This is the command state for for the STP remote
  204 + * device. This state is entered when the device is processing a
  205 + * non-NCQ command. The device object will fail any new start IO
  206 + * requests until this command is complete.
  207 + *
  208 + * @SCI_STP_DEV_NCQ: This is the NCQ state for the STP remote device.
  209 + * This state is entered when the device is processing an NCQ reuqest.
  210 + * It will remain in this state so long as there is one or more NCQ
  211 + * requests being processed.
  212 + *
  213 + * @SCI_STP_DEV_NCQ_ERROR: This is the NCQ error state for the STP
  214 + * remote device. This state is entered when an SDB error FIS is
  215 + * received by the device object while in the NCQ state. The device
  216 + * object will only accept a READ LOG command while in this state.
  217 + *
  218 + * @SCI_STP_DEV_ATAPI_ERROR: This is the ATAPI error state for the STP
  219 + * ATAPI remote device. This state is entered when ATAPI device sends
  220 + * error status FIS without data while the device object is in CMD
  221 + * state. A suspension event is expected in this state. The device
  222 + * object will resume right away.
  223 + *
  224 + * @SCI_STP_DEV_AWAIT_RESET: This is the READY substate indicates the
  225 + * device is waiting for the RESET task coming to be recovered from
  226 + * certain hardware specific error.
  227 + *
  228 + * @SCI_SMP_DEV_IDLE: This is the ready operational substate for the
  229 + * remote device. This is the normal operational state for a remote
  230 + * device.
  231 + *
  232 + * @SCI_SMP_DEV_CMD: This is the suspended state for the remote device.
  233 + * This is the state that the device is placed in when a RNC suspend is
  234 + * received by the SCU hardware.
  235 + *
  236 + * @SCI_DEV_STOPPING: This state indicates that the remote device is in
  237 + * the process of stopping. In this state no new IO operations are
  238 + * permitted, but existing IO operations are allowed to complete. This
  239 + * state is entered from the READY state. This state is entered from
  240 + * the FAILED state.
  241 + *
  242 + * @SCI_DEV_FAILED: This state indicates that the remote device has
  243 + * failed. In this state no new IO operations are permitted. This
  244 + * state is entered from the INITIALIZING state. This state is entered
  245 + * from the READY state.
  246 + *
  247 + * @SCI_DEV_RESETTING: This state indicates the device is being reset.
  248 + * In this state no new IO operations are permitted. This state is
  249 + * entered from the READY state.
  250 + *
  251 + * @SCI_DEV_FINAL: Simply the final state for the base remote device
  252 + * state machine.
184 253 */
185   -enum sci_remote_device_states {
186   - /**
187   - * Simply the initial state for the base remote device state machine.
188   - */
189   - SCI_DEV_INITIAL,
190   -
191   - /**
192   - * This state indicates that the remote device has successfully been
193   - * stopped. In this state no new IO operations are permitted.
194   - * This state is entered from the INITIAL state.
195   - * This state is entered from the STOPPING state.
196   - */
197   - SCI_DEV_STOPPED,
198   -
199   - /**
200   - * This state indicates the the remote device is in the process of
201   - * becoming ready (i.e. starting). In this state no new IO operations
202   - * are permitted.
203   - * This state is entered from the STOPPED state.
204   - */
205   - SCI_DEV_STARTING,
206   -
207   - /**
208   - * This state indicates the remote device is now ready. Thus, the user
209   - * is able to perform IO operations on the remote device.
210   - * This state is entered from the STARTING state.
211   - */
212   - SCI_DEV_READY,
213   -
214   - /**
215   - * This is the idle substate for the stp remote device. When there are no
216   - * active IO for the device it is is in this state.
217   - */
218   - SCI_STP_DEV_IDLE,
219   -
220   - /**
221   - * This is the command state for for the STP remote device. This state is
222   - * entered when the device is processing a non-NCQ command. The device object
223   - * will fail any new start IO requests until this command is complete.
224   - */
225   - SCI_STP_DEV_CMD,
226   -
227   - /**
228   - * This is the NCQ state for the STP remote device. This state is entered
229   - * when the device is processing an NCQ reuqest. It will remain in this state
230   - * so long as there is one or more NCQ requests being processed.
231   - */
232   - SCI_STP_DEV_NCQ,
233   -
234   - /**
235   - * This is the NCQ error state for the STP remote device. This state is
236   - * entered when an SDB error FIS is received by the device object while in the
237   - * NCQ state. The device object will only accept a READ LOG command while in
238   - * this state.
239   - */
240   - SCI_STP_DEV_NCQ_ERROR,
241   -
242   - /**
243   - * This is the ATAPI error state for the STP ATAPI remote device.
244   - * This state is entered when ATAPI device sends error status FIS
245   - * without data while the device object is in CMD state.
246   - * A suspension event is expected in this state.
247   - * The device object will resume right away.
248   - */
249   - SCI_STP_DEV_ATAPI_ERROR,
250   -
251   - /**
252   - * This is the READY substate indicates the device is waiting for the RESET task
253   - * coming to be recovered from certain hardware specific error.
254   - */
255   - SCI_STP_DEV_AWAIT_RESET,
256   -
257   - /**
258   - * This is the ready operational substate for the remote device. This is the
259   - * normal operational state for a remote device.
260   - */
261   - SCI_SMP_DEV_IDLE,
262   -
263   - /**
264   - * This is the suspended state for the remote device. This is the state that
265   - * the device is placed in when a RNC suspend is received by the SCU hardware.
266   - */
267   - SCI_SMP_DEV_CMD,
268   -
269   - /**
270   - * This state indicates that the remote device is in the process of
271   - * stopping. In this state no new IO operations are permitted, but
272   - * existing IO operations are allowed to complete.
273   - * This state is entered from the READY state.
274   - * This state is entered from the FAILED state.
275   - */
276   - SCI_DEV_STOPPING,
277   -
278   - /**
279   - * This state indicates that the remote device has failed.
280   - * In this state no new IO operations are permitted.
281   - * This state is entered from the INITIALIZING state.
282   - * This state is entered from the READY state.
283   - */
284   - SCI_DEV_FAILED,
285   -
286   - /**
287   - * This state indicates the device is being reset.
288   - * In this state no new IO operations are permitted.
289   - * This state is entered from the READY state.
290   - */
291   - SCI_DEV_RESETTING,
292   -
293   - /**
294   - * Simply the final state for the base remote device state machine.
295   - */
296   - SCI_DEV_FINAL,
297   -};
  254 +#define REMOTE_DEV_STATES {\
  255 + C(DEV_INITIAL),\
  256 + C(DEV_STOPPED),\
  257 + C(DEV_STARTING),\
  258 + C(DEV_READY),\
  259 + C(STP_DEV_IDLE),\
  260 + C(STP_DEV_CMD),\
  261 + C(STP_DEV_NCQ),\
  262 + C(STP_DEV_NCQ_ERROR),\
  263 + C(STP_DEV_ATAPI_ERROR),\
  264 + C(STP_DEV_AWAIT_RESET),\
  265 + C(SMP_DEV_IDLE),\
  266 + C(SMP_DEV_CMD),\
  267 + C(DEV_STOPPING),\
  268 + C(DEV_FAILED),\
  269 + C(DEV_RESETTING),\
  270 + C(DEV_FINAL),\
  271 + }
  272 +#undef C
  273 +#define C(a) SCI_##a
  274 +enum sci_remote_device_states REMOTE_DEV_STATES;
  275 +#undef C
  276 +const char *dev_state_name(enum sci_remote_device_states state);
298 277  
299 278 static inline struct isci_remote_device *rnc_to_dev(struct sci_remote_node_context *rnc)
300 279 {
drivers/scsi/isci/remote_node_context.c
... ... @@ -60,18 +60,15 @@
60 60 #include "scu_event_codes.h"
61 61 #include "scu_task_context.h"
62 62  
  63 +#undef C
  64 +#define C(a) (#a)
  65 +const char *rnc_state_name(enum scis_sds_remote_node_context_states state)
  66 +{
  67 + static const char * const strings[] = RNC_STATES;
63 68  
64   -/**
65   - *
66   - * @sci_rnc: The RNC for which the is posted request is being made.
67   - *
68   - * This method will return true if the RNC is not in the initial state. In all
69   - * other states the RNC is considered active and this will return true. The
70   - * destroy request of the state machine drives the RNC back to the initial
71   - * state. If the state machine changes then this routine will also have to be
72   - * changed. bool true if the state machine is not in the initial state false if
73   - * the state machine is in the initial state
74   - */
  69 + return strings[state];
  70 +}
  71 +#undef C
75 72  
76 73 /**
77 74 *
drivers/scsi/isci/remote_node_context.h
... ... @@ -85,61 +85,50 @@
85 85 typedef void (*scics_sds_remote_node_context_callback)(void *);
86 86  
87 87 /**
88   - * This is the enumeration of the remote node context states.
  88 + * enum sci_remote_node_context_states
  89 + * @SCI_RNC_INITIAL initial state for a remote node context. On a resume
  90 + * request the remote node context will transition to the posting state.
  91 + *
  92 + * @SCI_RNC_POSTING: transition state that posts the RNi to the hardware. Once
  93 + * the RNC is posted the remote node context will be made ready.
  94 + *
  95 + * @SCI_RNC_INVALIDATING: transition state that will post an RNC invalidate to
  96 + * the hardware. Once the invalidate is complete the remote node context will
  97 + * transition to the posting state.
  98 + *
  99 + * @SCI_RNC_RESUMING: transition state that will post an RNC resume to the
  100 + * hardare. Once the event notification of resume complete is received the
  101 + * remote node context will transition to the ready state.
  102 + *
  103 + * @SCI_RNC_READY: state that the remote node context must be in to accept io
  104 + * request operations.
  105 + *
  106 + * @SCI_RNC_TX_SUSPENDED: state that the remote node context transitions to when
  107 + * it gets a TX suspend notification from the hardware.
  108 + *
  109 + * @SCI_RNC_TX_RX_SUSPENDED: state that the remote node context transitions to
  110 + * when it gets a TX RX suspend notification from the hardware.
  111 + *
  112 + * @SCI_RNC_AWAIT_SUSPENSION: wait state for the remote node context that waits
  113 + * for a suspend notification from the hardware. This state is entered when
  114 + * either there is a request to supend the remote node context or when there is
  115 + * a TC completion where the remote node will be suspended by the hardware.
89 116 */
90   -enum scis_sds_remote_node_context_states {
91   - /**
92   - * This state is the initial state for a remote node context. On a resume
93   - * request the remote node context will transition to the posting state.
94   - */
95   - SCI_RNC_INITIAL,
96   -
97   - /**
98   - * This is a transition state that posts the RNi to the hardware. Once the RNC
99   - * is posted the remote node context will be made ready.
100   - */
101   - SCI_RNC_POSTING,
102   -
103   - /**
104   - * This is a transition state that will post an RNC invalidate to the
105   - * hardware. Once the invalidate is complete the remote node context will
106   - * transition to the posting state.
107   - */
108   - SCI_RNC_INVALIDATING,
109   -
110   - /**
111   - * This is a transition state that will post an RNC resume to the hardare.
112   - * Once the event notification of resume complete is received the remote node
113   - * context will transition to the ready state.
114   - */
115   - SCI_RNC_RESUMING,
116   -
117   - /**
118   - * This is the state that the remote node context must be in to accept io
119   - * request operations.
120   - */
121   - SCI_RNC_READY,
122   -
123   - /**
124   - * This is the state that the remote node context transitions to when it gets
125   - * a TX suspend notification from the hardware.
126   - */
127   - SCI_RNC_TX_SUSPENDED,
128   -
129   - /**
130   - * This is the state that the remote node context transitions to when it gets
131   - * a TX RX suspend notification from the hardware.
132   - */
133   - SCI_RNC_TX_RX_SUSPENDED,
134   -
135   - /**
136   - * This state is a wait state for the remote node context that waits for a
137   - * suspend notification from the hardware. This state is entered when either
138   - * there is a request to supend the remote node context or when there is a TC
139   - * completion where the remote node will be suspended by the hardware.
140   - */
141   - SCI_RNC_AWAIT_SUSPENSION
142   -};
  117 +#define RNC_STATES {\
  118 + C(RNC_INITIAL),\
  119 + C(RNC_POSTING),\
  120 + C(RNC_INVALIDATING),\
  121 + C(RNC_RESUMING),\
  122 + C(RNC_READY),\
  123 + C(RNC_TX_SUSPENDED),\
  124 + C(RNC_TX_RX_SUSPENDED),\
  125 + C(RNC_AWAIT_SUSPENSION),\
  126 + }
  127 +#undef C
  128 +#define C(a) SCI_##a
  129 +enum scis_sds_remote_node_context_states RNC_STATES;
  130 +#undef C
  131 +const char *rnc_state_name(enum scis_sds_remote_node_context_states state);
143 132  
144 133 /**
145 134 *
drivers/scsi/isci/request.c
... ... @@ -61,6 +61,16 @@
61 61 #include "scu_event_codes.h"
62 62 #include "sas.h"
63 63  
  64 +#undef C
  65 +#define C(a) (#a)
  66 +const char *req_state_name(enum sci_base_request_states state)
  67 +{
  68 + static const char * const strings[] = REQUEST_STATES;
  69 +
  70 + return strings[state];
  71 +}
  72 +#undef C
  73 +
64 74 static struct scu_sgl_element_pair *to_sgl_element_pair(struct isci_request *ireq,
65 75 int idx)
66 76 {
... ... @@ -910,7 +920,8 @@
910 920  
911 921 state = ireq->sm.current_state_id;
912 922 if (WARN_ONCE(state != SCI_REQ_COMPLETED,
913   - "isci: request completion from wrong state (%d)\n", state))
  923 + "isci: request completion from wrong state (%s)\n",
  924 + req_state_name(state)))
914 925 return SCI_FAILURE_INVALID_STATE;
915 926  
916 927 if (ireq->saved_rx_frame_index != SCU_INVALID_FRAME_INDEX)
... ... @@ -931,8 +942,8 @@
931 942 state = ireq->sm.current_state_id;
932 943  
933 944 if (state != SCI_REQ_STP_PIO_DATA_IN) {
934   - dev_warn(&ihost->pdev->dev, "%s: (%x) in wrong state %d\n",
935   - __func__, event_code, state);
  945 + dev_warn(&ihost->pdev->dev, "%s: (%x) in wrong state %s\n",
  946 + __func__, event_code, req_state_name(state));
936 947  
937 948 return SCI_FAILURE_INVALID_STATE;
938 949 }
... ... @@ -2306,12 +2317,8 @@
2306 2317 return atapi_data_tc_completion_handler(ireq, completion_code);
2307 2318  
2308 2319 default:
2309   - dev_warn(&ihost->pdev->dev,
2310   - "%s: SCIC IO Request given task completion "
2311   - "notification %x while in wrong state %d\n",
2312   - __func__,
2313   - completion_code,
2314   - state);
  2320 + dev_warn(&ihost->pdev->dev, "%s: %x in wrong state %s\n",
  2321 + __func__, completion_code, req_state_name(state));
2315 2322 return SCI_FAILURE_INVALID_STATE;
2316 2323 }
2317 2324 }
drivers/scsi/isci/request.h
... ... @@ -182,134 +182,103 @@
182 182 }
183 183  
184 184 /**
185   - * enum sci_base_request_states - This enumeration depicts all the states for
186   - * the common request state machine.
  185 + * enum sci_base_request_states - request state machine states
187 186 *
  187 + * @SCI_REQ_INIT: Simply the initial state for the base request state machine.
188 188 *
  189 + * @SCI_REQ_CONSTRUCTED: This state indicates that the request has been
  190 + * constructed. This state is entered from the INITIAL state.
  191 + *
  192 + * @SCI_REQ_STARTED: This state indicates that the request has been started.
  193 + * This state is entered from the CONSTRUCTED state.
  194 + *
  195 + * @SCI_REQ_STP_UDMA_WAIT_TC_COMP:
  196 + * @SCI_REQ_STP_UDMA_WAIT_D2H:
  197 + * @SCI_REQ_STP_NON_DATA_WAIT_H2D:
  198 + * @SCI_REQ_STP_NON_DATA_WAIT_D2H:
  199 + *
  200 + * @SCI_REQ_STP_PIO_WAIT_H2D: While in this state the IO request object is
  201 + * waiting for the TC completion notification for the H2D Register FIS
  202 + *
  203 + * @SCI_REQ_STP_PIO_WAIT_FRAME: While in this state the IO request object is
  204 + * waiting for either a PIO Setup FIS or a D2H register FIS. The type of frame
  205 + * received is based on the result of the prior frame and line conditions.
  206 + *
  207 + * @SCI_REQ_STP_PIO_DATA_IN: While in this state the IO request object is
  208 + * waiting for a DATA frame from the device.
  209 + *
  210 + * @SCI_REQ_STP_PIO_DATA_OUT: While in this state the IO request object is
  211 + * waiting to transmit the next data frame to the device.
  212 + *
  213 + * @SCI_REQ_ATAPI_WAIT_H2D: While in this state the IO request object is
  214 + * waiting for the TC completion notification for the H2D Register FIS
  215 + *
  216 + * @SCI_REQ_ATAPI_WAIT_PIO_SETUP: While in this state the IO request object is
  217 + * waiting for either a PIO Setup.
  218 + *
  219 + * @SCI_REQ_ATAPI_WAIT_D2H: The non-data IO transit to this state in this state
  220 + * after receiving TC completion. While in this state IO request object is
  221 + * waiting for D2H status frame as UF.
  222 + *
  223 + * @SCI_REQ_ATAPI_WAIT_TC_COMP: When transmitting raw frames hardware reports
  224 + * task context completion after every frame submission, so in the
  225 + * non-accelerated case we need to expect the completion for the "cdb" frame.
  226 + *
  227 + * @SCI_REQ_TASK_WAIT_TC_COMP: The AWAIT_TC_COMPLETION sub-state indicates that
  228 + * the started raw task management request is waiting for the transmission of
  229 + * the initial frame (i.e. command, task, etc.).
  230 + *
  231 + * @SCI_REQ_TASK_WAIT_TC_RESP: This sub-state indicates that the started task
  232 + * management request is waiting for the reception of an unsolicited frame
  233 + * (i.e. response IU).
  234 + *
  235 + * @SCI_REQ_SMP_WAIT_RESP: This sub-state indicates that the started task
  236 + * management request is waiting for the reception of an unsolicited frame
  237 + * (i.e. response IU).
  238 + *
  239 + * @SCI_REQ_SMP_WAIT_TC_COMP: The AWAIT_TC_COMPLETION sub-state indicates that
  240 + * the started SMP request is waiting for the transmission of the initial frame
  241 + * (i.e. command, task, etc.).
  242 + *
  243 + * @SCI_REQ_COMPLETED: This state indicates that the request has completed.
  244 + * This state is entered from the STARTED state. This state is entered from the
  245 + * ABORTING state.
  246 + *
  247 + * @SCI_REQ_ABORTING: This state indicates that the request is in the process
  248 + * of being terminated/aborted. This state is entered from the CONSTRUCTED
  249 + * state. This state is entered from the STARTED state.
  250 + *
  251 + * @SCI_REQ_FINAL: Simply the final state for the base request state machine.
189 252 */
190   -enum sci_base_request_states {
191   - /*
192   - * Simply the initial state for the base request state machine.
193   - */
194   - SCI_REQ_INIT,
195   -
196   - /*
197   - * This state indicates that the request has been constructed.
198   - * This state is entered from the INITIAL state.
199   - */
200   - SCI_REQ_CONSTRUCTED,
201   -
202   - /*
203   - * This state indicates that the request has been started. This state
204   - * is entered from the CONSTRUCTED state.
205   - */
206   - SCI_REQ_STARTED,
207   -
208   - SCI_REQ_STP_UDMA_WAIT_TC_COMP,
209   - SCI_REQ_STP_UDMA_WAIT_D2H,
210   -
211   - SCI_REQ_STP_NON_DATA_WAIT_H2D,
212   - SCI_REQ_STP_NON_DATA_WAIT_D2H,
213   -
214   - /*
215   - * While in this state the IO request object is waiting for the TC
216   - * completion notification for the H2D Register FIS
217   - */
218   - SCI_REQ_STP_PIO_WAIT_H2D,
219   -
220   - /*
221   - * While in this state the IO request object is waiting for either a
222   - * PIO Setup FIS or a D2H register FIS. The type of frame received is
223   - * based on the result of the prior frame and line conditions.
224   - */
225   - SCI_REQ_STP_PIO_WAIT_FRAME,
226   -
227   - /*
228   - * While in this state the IO request object is waiting for a DATA
229   - * frame from the device.
230   - */
231   - SCI_REQ_STP_PIO_DATA_IN,
232   -
233   - /*
234   - * While in this state the IO request object is waiting to transmit
235   - * the next data frame to the device.
236   - */
237   - SCI_REQ_STP_PIO_DATA_OUT,
238   -
239   - /*
240   - * While in this state the IO request object is waiting for the TC
241   - * completion notification for the H2D Register FIS
242   - */
243   - SCI_REQ_ATAPI_WAIT_H2D,
244   -
245   - /*
246   - * While in this state the IO request object is waiting for either a
247   - * PIO Setup.
248   - */
249   - SCI_REQ_ATAPI_WAIT_PIO_SETUP,
250   -
251   - /*
252   - * The non-data IO transit to this state in this state after receiving
253   - * TC completion. While in this state IO request object is waiting for
254   - * D2H status frame as UF.
255   - */
256   - SCI_REQ_ATAPI_WAIT_D2H,
257   -
258   - /*
259   - * When transmitting raw frames hardware reports task context completion
260   - * after every frame submission, so in the non-accelerated case we need
261   - * to expect the completion for the "cdb" frame.
262   - */
263   - SCI_REQ_ATAPI_WAIT_TC_COMP,
264   -
265   - /*
266   - * The AWAIT_TC_COMPLETION sub-state indicates that the started raw
267   - * task management request is waiting for the transmission of the
268   - * initial frame (i.e. command, task, etc.).
269   - */
270   - SCI_REQ_TASK_WAIT_TC_COMP,
271   -
272   - /*
273   - * This sub-state indicates that the started task management request
274   - * is waiting for the reception of an unsolicited frame
275   - * (i.e. response IU).
276   - */
277   - SCI_REQ_TASK_WAIT_TC_RESP,
278   -
279   - /*
280   - * This sub-state indicates that the started task management request
281   - * is waiting for the reception of an unsolicited frame
282   - * (i.e. response IU).
283   - */
284   - SCI_REQ_SMP_WAIT_RESP,
285   -
286   - /*
287   - * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP
288   - * request is waiting for the transmission of the initial frame
289   - * (i.e. command, task, etc.).
290   - */
291   - SCI_REQ_SMP_WAIT_TC_COMP,
292   -
293   - /*
294   - * This state indicates that the request has completed.
295   - * This state is entered from the STARTED state. This state is entered
296   - * from the ABORTING state.
297   - */
298   - SCI_REQ_COMPLETED,
299   -
300   - /*
301   - * This state indicates that the request is in the process of being
302   - * terminated/aborted.
303   - * This state is entered from the CONSTRUCTED state.
304   - * This state is entered from the STARTED state.
305   - */
306   - SCI_REQ_ABORTING,
307   -
308   - /*
309   - * Simply the final state for the base request state machine.
310   - */
311   - SCI_REQ_FINAL,
312   -};
  253 +#define REQUEST_STATES {\
  254 + C(REQ_INIT),\
  255 + C(REQ_CONSTRUCTED),\
  256 + C(REQ_STARTED),\
  257 + C(REQ_STP_UDMA_WAIT_TC_COMP),\
  258 + C(REQ_STP_UDMA_WAIT_D2H),\
  259 + C(REQ_STP_NON_DATA_WAIT_H2D),\
  260 + C(REQ_STP_NON_DATA_WAIT_D2H),\
  261 + C(REQ_STP_PIO_WAIT_H2D),\
  262 + C(REQ_STP_PIO_WAIT_FRAME),\
  263 + C(REQ_STP_PIO_DATA_IN),\
  264 + C(REQ_STP_PIO_DATA_OUT),\
  265 + C(REQ_ATAPI_WAIT_H2D),\
  266 + C(REQ_ATAPI_WAIT_PIO_SETUP),\
  267 + C(REQ_ATAPI_WAIT_D2H),\
  268 + C(REQ_ATAPI_WAIT_TC_COMP),\
  269 + C(REQ_TASK_WAIT_TC_COMP),\
  270 + C(REQ_TASK_WAIT_TC_RESP),\
  271 + C(REQ_SMP_WAIT_RESP),\
  272 + C(REQ_SMP_WAIT_TC_COMP),\
  273 + C(REQ_COMPLETED),\
  274 + C(REQ_ABORTING),\
  275 + C(REQ_FINAL),\
  276 + }
  277 +#undef C
  278 +#define C(a) SCI_##a
  279 +enum sci_base_request_states REQUEST_STATES;
  280 +#undef C
  281 +const char *req_state_name(enum sci_base_request_states state);
313 282  
314 283 enum sci_status sci_request_start(struct isci_request *ireq);
315 284 enum sci_status sci_io_request_terminate(struct isci_request *ireq);