Swen Schillig | 41fa2ada | 2007-09-07 09:15:31 +0200 | [diff] [blame] | 1 | /* |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 2 | * zfcp device driver |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 4 | * Error Recovery Procedures (ERP). |
Swen Schillig | 41fa2ada | 2007-09-07 09:15:31 +0200 | [diff] [blame] | 5 | * |
Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 6 | * Copyright IBM Corporation 2002, 2010 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
Christof Schmitt | ecf39d4 | 2008-12-25 13:39:53 +0100 | [diff] [blame] | 9 | #define KMSG_COMPONENT "zfcp" |
| 10 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 11 | |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 12 | #include <linux/kthread.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include "zfcp_ext.h" |
Christof Schmitt | b6bd2fb | 2010-02-17 11:18:50 +0100 | [diff] [blame] | 14 | #include "zfcp_reqlist.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 16 | #define ZFCP_MAX_ERPS 3 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 18 | enum zfcp_erp_act_flags { |
| 19 | ZFCP_STATUS_ERP_TIMEDOUT = 0x10000000, |
| 20 | ZFCP_STATUS_ERP_CLOSE_ONLY = 0x01000000, |
| 21 | ZFCP_STATUS_ERP_DISMISSING = 0x00100000, |
| 22 | ZFCP_STATUS_ERP_DISMISSED = 0x00200000, |
| 23 | ZFCP_STATUS_ERP_LOWMEM = 0x00400000, |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 24 | ZFCP_STATUS_ERP_NO_REF = 0x00800000, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 25 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 27 | enum zfcp_erp_steps { |
| 28 | ZFCP_ERP_STEP_UNINITIALIZED = 0x0000, |
| 29 | ZFCP_ERP_STEP_FSF_XCONFIG = 0x0001, |
| 30 | ZFCP_ERP_STEP_PHYS_PORT_CLOSING = 0x0010, |
| 31 | ZFCP_ERP_STEP_PORT_CLOSING = 0x0100, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 32 | ZFCP_ERP_STEP_PORT_OPENING = 0x0800, |
| 33 | ZFCP_ERP_STEP_UNIT_CLOSING = 0x1000, |
| 34 | ZFCP_ERP_STEP_UNIT_OPENING = 0x2000, |
| 35 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 37 | enum zfcp_erp_act_type { |
| 38 | ZFCP_ERP_ACTION_REOPEN_UNIT = 1, |
| 39 | ZFCP_ERP_ACTION_REOPEN_PORT = 2, |
| 40 | ZFCP_ERP_ACTION_REOPEN_PORT_FORCED = 3, |
| 41 | ZFCP_ERP_ACTION_REOPEN_ADAPTER = 4, |
| 42 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 44 | enum zfcp_erp_act_state { |
| 45 | ZFCP_ERP_ACTION_RUNNING = 1, |
| 46 | ZFCP_ERP_ACTION_READY = 2, |
| 47 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 49 | enum zfcp_erp_act_result { |
| 50 | ZFCP_ERP_SUCCEEDED = 0, |
| 51 | ZFCP_ERP_FAILED = 1, |
| 52 | ZFCP_ERP_CONTINUES = 2, |
| 53 | ZFCP_ERP_EXIT = 3, |
| 54 | ZFCP_ERP_DISMISSED = 4, |
| 55 | ZFCP_ERP_NOMEM = 5, |
| 56 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 58 | static void zfcp_erp_adapter_block(struct zfcp_adapter *adapter, int mask) |
Andreas Herrmann | 2abbe86 | 2006-09-18 22:29:56 +0200 | [diff] [blame] | 59 | { |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 60 | zfcp_erp_modify_adapter_status(adapter, "erablk1", NULL, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 61 | ZFCP_STATUS_COMMON_UNBLOCKED | mask, |
| 62 | ZFCP_CLEAR); |
Andreas Herrmann | 2abbe86 | 2006-09-18 22:29:56 +0200 | [diff] [blame] | 63 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 65 | static int zfcp_erp_action_exists(struct zfcp_erp_action *act) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 67 | struct zfcp_erp_action *curr_act; |
| 68 | |
| 69 | list_for_each_entry(curr_act, &act->adapter->erp_running_head, list) |
| 70 | if (act == curr_act) |
| 71 | return ZFCP_ERP_ACTION_RUNNING; |
| 72 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 75 | static void zfcp_erp_action_ready(struct zfcp_erp_action *act) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 77 | struct zfcp_adapter *adapter = act->adapter; |
| 78 | |
| 79 | list_move(&act->list, &act->adapter->erp_ready_head); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 80 | zfcp_dbf_rec_action("erardy1", act); |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 81 | wake_up(&adapter->erp_ready_wq); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 82 | zfcp_dbf_rec_thread("erardy2", adapter->dbf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | } |
| 84 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 85 | static void zfcp_erp_action_dismiss(struct zfcp_erp_action *act) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 87 | act->status |= ZFCP_STATUS_ERP_DISMISSED; |
| 88 | if (zfcp_erp_action_exists(act) == ZFCP_ERP_ACTION_RUNNING) |
| 89 | zfcp_erp_action_ready(act); |
| 90 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 92 | static void zfcp_erp_action_dismiss_unit(struct zfcp_unit *unit) |
| 93 | { |
| 94 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_INUSE) |
| 95 | zfcp_erp_action_dismiss(&unit->erp_action); |
| 96 | } |
| 97 | |
| 98 | static void zfcp_erp_action_dismiss_port(struct zfcp_port *port) |
| 99 | { |
| 100 | struct zfcp_unit *unit; |
| 101 | |
| 102 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_INUSE) |
| 103 | zfcp_erp_action_dismiss(&port->erp_action); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 104 | else { |
| 105 | read_lock(&port->unit_list_lock); |
| 106 | list_for_each_entry(unit, &port->unit_list, list) |
| 107 | zfcp_erp_action_dismiss_unit(unit); |
| 108 | read_unlock(&port->unit_list_lock); |
| 109 | } |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter) |
| 113 | { |
| 114 | struct zfcp_port *port; |
| 115 | |
| 116 | if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_INUSE) |
| 117 | zfcp_erp_action_dismiss(&adapter->erp_action); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 118 | else { |
| 119 | read_lock(&adapter->port_list_lock); |
| 120 | list_for_each_entry(port, &adapter->port_list, list) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 121 | zfcp_erp_action_dismiss_port(port); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 122 | read_unlock(&adapter->port_list_lock); |
| 123 | } |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter, |
| 127 | struct zfcp_port *port, |
| 128 | struct zfcp_unit *unit) |
| 129 | { |
| 130 | int need = want; |
| 131 | int u_status, p_status, a_status; |
| 132 | |
| 133 | switch (want) { |
| 134 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
| 135 | u_status = atomic_read(&unit->status); |
| 136 | if (u_status & ZFCP_STATUS_COMMON_ERP_INUSE) |
| 137 | return 0; |
| 138 | p_status = atomic_read(&port->status); |
| 139 | if (!(p_status & ZFCP_STATUS_COMMON_RUNNING) || |
| 140 | p_status & ZFCP_STATUS_COMMON_ERP_FAILED) |
| 141 | return 0; |
| 142 | if (!(p_status & ZFCP_STATUS_COMMON_UNBLOCKED)) |
| 143 | need = ZFCP_ERP_ACTION_REOPEN_PORT; |
| 144 | /* fall through */ |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 145 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
| 146 | p_status = atomic_read(&port->status); |
Christof Schmitt | 097ef3b | 2010-07-08 09:53:06 +0200 | [diff] [blame] | 147 | if (!(p_status & ZFCP_STATUS_COMMON_OPEN)) |
| 148 | need = ZFCP_ERP_ACTION_REOPEN_PORT; |
| 149 | /* fall through */ |
| 150 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
| 151 | p_status = atomic_read(&port->status); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 152 | if (p_status & ZFCP_STATUS_COMMON_ERP_INUSE) |
| 153 | return 0; |
| 154 | a_status = atomic_read(&adapter->status); |
| 155 | if (!(a_status & ZFCP_STATUS_COMMON_RUNNING) || |
| 156 | a_status & ZFCP_STATUS_COMMON_ERP_FAILED) |
| 157 | return 0; |
| 158 | if (!(a_status & ZFCP_STATUS_COMMON_UNBLOCKED)) |
| 159 | need = ZFCP_ERP_ACTION_REOPEN_ADAPTER; |
| 160 | /* fall through */ |
| 161 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
| 162 | a_status = atomic_read(&adapter->status); |
| 163 | if (a_status & ZFCP_STATUS_COMMON_ERP_INUSE) |
| 164 | return 0; |
Christof Schmitt | 143bb6b | 2009-08-18 15:43:27 +0200 | [diff] [blame] | 165 | if (!(a_status & ZFCP_STATUS_COMMON_RUNNING) && |
| 166 | !(a_status & ZFCP_STATUS_COMMON_OPEN)) |
| 167 | return 0; /* shutdown requested for closed adapter */ |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | return need; |
| 171 | } |
| 172 | |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 173 | static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 174 | struct zfcp_adapter *adapter, |
| 175 | struct zfcp_port *port, |
| 176 | struct zfcp_unit *unit) |
| 177 | { |
| 178 | struct zfcp_erp_action *erp_action; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 179 | |
| 180 | switch (need) { |
| 181 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 182 | if (!(act_status & ZFCP_STATUS_ERP_NO_REF)) |
| 183 | if (!get_device(&unit->dev)) |
| 184 | return NULL; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 185 | atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status); |
| 186 | erp_action = &unit->erp_action; |
| 187 | if (!(atomic_read(&unit->status) & ZFCP_STATUS_COMMON_RUNNING)) |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 188 | act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 189 | break; |
| 190 | |
| 191 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
| 192 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 193 | if (!get_device(&port->dev)) |
Swen Schillig | 6b183334 | 2009-11-24 16:54:05 +0100 | [diff] [blame] | 194 | return NULL; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 195 | zfcp_erp_action_dismiss_port(port); |
| 196 | atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status); |
| 197 | erp_action = &port->erp_action; |
| 198 | if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_RUNNING)) |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 199 | act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 200 | break; |
| 201 | |
| 202 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 203 | kref_get(&adapter->ref); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 204 | zfcp_erp_action_dismiss_adapter(adapter); |
| 205 | atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status); |
| 206 | erp_action = &adapter->erp_action; |
| 207 | if (!(atomic_read(&adapter->status) & |
| 208 | ZFCP_STATUS_COMMON_RUNNING)) |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 209 | act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 210 | break; |
| 211 | |
| 212 | default: |
| 213 | return NULL; |
| 214 | } |
| 215 | |
| 216 | memset(erp_action, 0, sizeof(struct zfcp_erp_action)); |
| 217 | erp_action->adapter = adapter; |
| 218 | erp_action->port = port; |
| 219 | erp_action->unit = unit; |
| 220 | erp_action->action = need; |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 221 | erp_action->status = act_status; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 222 | |
| 223 | return erp_action; |
| 224 | } |
| 225 | |
| 226 | static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter, |
| 227 | struct zfcp_port *port, |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 228 | struct zfcp_unit *unit, char *id, void *ref, |
| 229 | u32 act_status) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 230 | { |
| 231 | int retval = 1, need; |
| 232 | struct zfcp_erp_action *act = NULL; |
| 233 | |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 234 | if (!adapter->erp_thread) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 235 | return -EIO; |
| 236 | |
| 237 | need = zfcp_erp_required_act(want, adapter, port, unit); |
| 238 | if (!need) |
| 239 | goto out; |
| 240 | |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 241 | act = zfcp_erp_setup_act(need, act_status, adapter, port, unit); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 242 | if (!act) |
| 243 | goto out; |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 244 | atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 245 | ++adapter->erp_total_count; |
| 246 | list_add_tail(&act->list, &adapter->erp_ready_head); |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 247 | wake_up(&adapter->erp_ready_wq); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 248 | zfcp_dbf_rec_thread("eracte1", adapter->dbf); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 249 | retval = 0; |
| 250 | out: |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 251 | zfcp_dbf_rec_trigger(id, ref, want, need, act, adapter, port, unit); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 252 | return retval; |
| 253 | } |
| 254 | |
| 255 | static int _zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 256 | int clear_mask, char *id, void *ref) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 257 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | zfcp_erp_adapter_block(adapter, clear_mask); |
Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame] | 259 | zfcp_scsi_schedule_rports_block(adapter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 261 | /* ensure propagation of failed status to new devices */ |
| 262 | if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 263 | zfcp_erp_adapter_failed(adapter, "erareo1", NULL); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 264 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | } |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 266 | return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER, |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 267 | adapter, NULL, NULL, id, ref, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | /** |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 271 | * zfcp_erp_adapter_reopen - Reopen adapter. |
| 272 | * @adapter: Adapter to reopen. |
| 273 | * @clear: Status flags to clear. |
| 274 | * @id: Id for debug trace event. |
| 275 | * @ref: Reference for debug trace event. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | */ |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 277 | void zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear, |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 278 | char *id, void *ref) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 280 | unsigned long flags; |
| 281 | |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 282 | zfcp_erp_adapter_block(adapter, clear); |
| 283 | zfcp_scsi_schedule_rports_block(adapter); |
| 284 | |
| 285 | write_lock_irqsave(&adapter->erp_lock, flags); |
| 286 | if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) |
| 287 | zfcp_erp_adapter_failed(adapter, "erareo1", NULL); |
| 288 | else |
| 289 | zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER, adapter, |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 290 | NULL, NULL, id, ref, 0); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 291 | write_unlock_irqrestore(&adapter->erp_lock, flags); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | /** |
| 295 | * zfcp_erp_adapter_shutdown - Shutdown adapter. |
| 296 | * @adapter: Adapter to shut down. |
| 297 | * @clear: Status flags to clear. |
| 298 | * @id: Id for debug trace event. |
| 299 | * @ref: Reference for debug trace event. |
| 300 | */ |
| 301 | void zfcp_erp_adapter_shutdown(struct zfcp_adapter *adapter, int clear, |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 302 | char *id, void *ref) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 303 | { |
| 304 | int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; |
| 305 | zfcp_erp_adapter_reopen(adapter, clear | flags, id, ref); |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * zfcp_erp_port_shutdown - Shutdown port |
| 310 | * @port: Port to shut down. |
| 311 | * @clear: Status flags to clear. |
| 312 | * @id: Id for debug trace event. |
| 313 | * @ref: Reference for debug trace event. |
| 314 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 315 | void zfcp_erp_port_shutdown(struct zfcp_port *port, int clear, char *id, |
| 316 | void *ref) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 317 | { |
| 318 | int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; |
| 319 | zfcp_erp_port_reopen(port, clear | flags, id, ref); |
| 320 | } |
| 321 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 322 | static void zfcp_erp_port_block(struct zfcp_port *port, int clear) |
| 323 | { |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 324 | zfcp_erp_modify_port_status(port, "erpblk1", NULL, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 325 | ZFCP_STATUS_COMMON_UNBLOCKED | clear, |
| 326 | ZFCP_CLEAR); |
| 327 | } |
| 328 | |
| 329 | static void _zfcp_erp_port_forced_reopen(struct zfcp_port *port, |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 330 | int clear, char *id, void *ref) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 331 | { |
| 332 | zfcp_erp_port_block(port, clear); |
Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame] | 333 | zfcp_scsi_schedule_rport_block(port); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 334 | |
| 335 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) |
| 336 | return; |
| 337 | |
| 338 | zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED, |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 339 | port->adapter, port, NULL, id, ref, 0); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | /** |
| 343 | * zfcp_erp_port_forced_reopen - Forced close of port and open again |
| 344 | * @port: Port to force close and to reopen. |
| 345 | * @id: Id for debug trace event. |
| 346 | * @ref: Reference for debug trace event. |
| 347 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 348 | void zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear, char *id, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 349 | void *ref) |
| 350 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | unsigned long flags; |
| 352 | struct zfcp_adapter *adapter = port->adapter; |
| 353 | |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 354 | write_lock_irqsave(&adapter->erp_lock, flags); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 355 | _zfcp_erp_port_forced_reopen(port, clear, id, ref); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 356 | write_unlock_irqrestore(&adapter->erp_lock, flags); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 357 | } |
| 358 | |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 359 | static int _zfcp_erp_port_reopen(struct zfcp_port *port, int clear, char *id, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 360 | void *ref) |
| 361 | { |
| 362 | zfcp_erp_port_block(port, clear); |
Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame] | 363 | zfcp_scsi_schedule_rport_block(port); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 364 | |
| 365 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { |
| 366 | /* ensure propagation of failed status to new devices */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 367 | zfcp_erp_port_failed(port, "erpreo1", NULL); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 368 | return -EIO; |
| 369 | } |
| 370 | |
| 371 | return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT, |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 372 | port->adapter, port, NULL, id, ref, 0); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | /** |
| 376 | * zfcp_erp_port_reopen - trigger remote port recovery |
| 377 | * @port: port to recover |
| 378 | * @clear_mask: flags in port status to be cleared |
| 379 | * |
| 380 | * Returns 0 if recovery has been triggered, < 0 if not. |
| 381 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 382 | int zfcp_erp_port_reopen(struct zfcp_port *port, int clear, char *id, void *ref) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 383 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 384 | int retval; |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 385 | unsigned long flags; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 386 | struct zfcp_adapter *adapter = port->adapter; |
| 387 | |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 388 | write_lock_irqsave(&adapter->erp_lock, flags); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 389 | retval = _zfcp_erp_port_reopen(port, clear, id, ref); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 390 | write_unlock_irqrestore(&adapter->erp_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | |
| 392 | return retval; |
| 393 | } |
| 394 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 395 | static void zfcp_erp_unit_block(struct zfcp_unit *unit, int clear_mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | { |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 397 | zfcp_erp_modify_unit_status(unit, "erublk1", NULL, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 398 | ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask, |
| 399 | ZFCP_CLEAR); |
| 400 | } |
| 401 | |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 402 | static void _zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, char *id, |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 403 | void *ref, u32 act_status) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 404 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | struct zfcp_adapter *adapter = unit->port->adapter; |
| 406 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 407 | zfcp_erp_unit_block(unit, clear); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 409 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_FAILED) |
| 410 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 412 | zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_UNIT, |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 413 | adapter, unit->port, unit, id, ref, act_status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | /** |
| 417 | * zfcp_erp_unit_reopen - initiate reopen of a unit |
| 418 | * @unit: unit to be reopened |
| 419 | * @clear_mask: specifies flags in unit status to be cleared |
| 420 | * Return: 0 on success, < 0 on error |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 422 | void zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, char *id, |
| 423 | void *ref) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | unsigned long flags; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 426 | struct zfcp_port *port = unit->port; |
| 427 | struct zfcp_adapter *adapter = port->adapter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 429 | write_lock_irqsave(&adapter->erp_lock, flags); |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 430 | _zfcp_erp_unit_reopen(unit, clear, id, ref, 0); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 431 | write_unlock_irqrestore(&adapter->erp_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | } |
| 433 | |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 434 | /** |
| 435 | * zfcp_erp_unit_shutdown - Shutdown unit |
| 436 | * @unit: Unit to shut down. |
| 437 | * @clear: Status flags to clear. |
| 438 | * @id: Id for debug trace event. |
| 439 | * @ref: Reference for debug trace event. |
| 440 | */ |
| 441 | void zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear, char *id, |
| 442 | void *ref) |
| 443 | { |
| 444 | int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; |
| 445 | zfcp_erp_unit_reopen(unit, clear | flags, id, ref); |
| 446 | } |
| 447 | |
| 448 | /** |
| 449 | * zfcp_erp_unit_shutdown_wait - Shutdown unit and wait for erp completion |
| 450 | * @unit: Unit to shut down. |
| 451 | * @id: Id for debug trace event. |
| 452 | * |
| 453 | * Do not acquire a reference for the unit when creating the ERP |
| 454 | * action. It is safe, because this function waits for the ERP to |
| 455 | * complete first. |
| 456 | */ |
| 457 | void zfcp_erp_unit_shutdown_wait(struct zfcp_unit *unit, char *id) |
| 458 | { |
| 459 | unsigned long flags; |
| 460 | struct zfcp_port *port = unit->port; |
| 461 | struct zfcp_adapter *adapter = port->adapter; |
| 462 | int clear = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; |
| 463 | |
| 464 | write_lock_irqsave(&adapter->erp_lock, flags); |
| 465 | _zfcp_erp_unit_reopen(unit, clear, id, NULL, ZFCP_STATUS_ERP_NO_REF); |
| 466 | write_unlock_irqrestore(&adapter->erp_lock, flags); |
| 467 | |
| 468 | zfcp_erp_wait(adapter); |
| 469 | } |
| 470 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 471 | static int status_change_set(unsigned long mask, atomic_t *status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 473 | return (atomic_read(status) ^ mask) & mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | } |
| 475 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 476 | static int status_change_clear(unsigned long mask, atomic_t *status) |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 477 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 478 | return atomic_read(status) & mask; |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 479 | } |
| 480 | |
Andreas Herrmann | f6c0e7a | 2006-08-02 11:05:52 +0200 | [diff] [blame] | 481 | static void zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 483 | if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status)) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 484 | zfcp_dbf_rec_adapter("eraubl1", NULL, adapter->dbf); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 485 | atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | } |
| 487 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 488 | static void zfcp_erp_port_unblock(struct zfcp_port *port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 490 | if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status)) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 491 | zfcp_dbf_rec_port("erpubl1", NULL, port); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 492 | atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | } |
| 494 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 495 | static void zfcp_erp_unit_unblock(struct zfcp_unit *unit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 497 | if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status)) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 498 | zfcp_dbf_rec_unit("eruubl1", NULL, unit); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 499 | atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | } |
| 501 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 502 | static void zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 504 | list_move(&erp_action->list, &erp_action->adapter->erp_running_head); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 505 | zfcp_dbf_rec_action("erator1", erp_action); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | } |
| 507 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 508 | static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 510 | struct zfcp_adapter *adapter = act->adapter; |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 511 | struct zfcp_fsf_req *req; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 513 | if (!act->fsf_req_id) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 514 | return; |
| 515 | |
Christof Schmitt | b6bd2fb | 2010-02-17 11:18:50 +0100 | [diff] [blame] | 516 | spin_lock(&adapter->req_list->lock); |
| 517 | req = _zfcp_reqlist_find(adapter->req_list, act->fsf_req_id); |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 518 | if (req && req->erp_action == act) { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 519 | if (act->status & (ZFCP_STATUS_ERP_DISMISSED | |
| 520 | ZFCP_STATUS_ERP_TIMEDOUT)) { |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 521 | req->status |= ZFCP_STATUS_FSFREQ_DISMISSED; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 522 | zfcp_dbf_rec_action("erscf_1", act); |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 523 | req->erp_action = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | } |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 525 | if (act->status & ZFCP_STATUS_ERP_TIMEDOUT) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 526 | zfcp_dbf_rec_action("erscf_2", act); |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 527 | if (req->status & ZFCP_STATUS_FSFREQ_DISMISSED) |
| 528 | act->fsf_req_id = 0; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 529 | } else |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 530 | act->fsf_req_id = 0; |
Christof Schmitt | b6bd2fb | 2010-02-17 11:18:50 +0100 | [diff] [blame] | 531 | spin_unlock(&adapter->req_list->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | } |
| 533 | |
Andreas Herrmann | f6c0e7a | 2006-08-02 11:05:52 +0200 | [diff] [blame] | 534 | /** |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 535 | * zfcp_erp_notify - Trigger ERP action. |
| 536 | * @erp_action: ERP action to continue. |
| 537 | * @set_mask: ERP action status flags to set. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | */ |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 539 | void zfcp_erp_notify(struct zfcp_erp_action *erp_action, unsigned long set_mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | { |
| 541 | struct zfcp_adapter *adapter = erp_action->adapter; |
| 542 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | |
| 544 | write_lock_irqsave(&adapter->erp_lock, flags); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 545 | if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING) { |
| 546 | erp_action->status |= set_mask; |
| 547 | zfcp_erp_action_ready(erp_action); |
| 548 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | write_unlock_irqrestore(&adapter->erp_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | } |
| 551 | |
Andreas Herrmann | f6c0e7a | 2006-08-02 11:05:52 +0200 | [diff] [blame] | 552 | /** |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 553 | * zfcp_erp_timeout_handler - Trigger ERP action from timed out ERP request |
| 554 | * @data: ERP action (from timer data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | */ |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 556 | void zfcp_erp_timeout_handler(unsigned long data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 558 | struct zfcp_erp_action *act = (struct zfcp_erp_action *) data; |
| 559 | zfcp_erp_notify(act, ZFCP_STATUS_ERP_TIMEDOUT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | } |
| 561 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 562 | static void zfcp_erp_memwait_handler(unsigned long data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 564 | zfcp_erp_notify((struct zfcp_erp_action *)data, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | } |
| 566 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 567 | static void zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | init_timer(&erp_action->timer); |
| 570 | erp_action->timer.function = zfcp_erp_memwait_handler; |
| 571 | erp_action->timer.data = (unsigned long) erp_action; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 572 | erp_action->timer.expires = jiffies + HZ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | add_timer(&erp_action->timer); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | static void _zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 577 | int clear, char *id, void *ref) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 578 | { |
| 579 | struct zfcp_port *port; |
| 580 | |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 581 | read_lock(&adapter->port_list_lock); |
| 582 | list_for_each_entry(port, &adapter->port_list, list) |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 583 | _zfcp_erp_port_reopen(port, clear, id, ref); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 584 | read_unlock(&adapter->port_list_lock); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 585 | } |
| 586 | |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 587 | static void _zfcp_erp_unit_reopen_all(struct zfcp_port *port, int clear, |
| 588 | char *id, void *ref) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 589 | { |
| 590 | struct zfcp_unit *unit; |
| 591 | |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 592 | read_lock(&port->unit_list_lock); |
| 593 | list_for_each_entry(unit, &port->unit_list, list) |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 594 | _zfcp_erp_unit_reopen(unit, clear, id, ref, 0); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 595 | read_unlock(&port->unit_list_lock); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 596 | } |
| 597 | |
Christof Schmitt | 85600f7 | 2009-07-13 15:06:09 +0200 | [diff] [blame] | 598 | static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 599 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 600 | switch (act->action) { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 601 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
Christof Schmitt | 85600f7 | 2009-07-13 15:06:09 +0200 | [diff] [blame] | 602 | _zfcp_erp_adapter_reopen(act->adapter, 0, "ersff_1", NULL); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 603 | break; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 604 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
Christof Schmitt | 85600f7 | 2009-07-13 15:06:09 +0200 | [diff] [blame] | 605 | _zfcp_erp_port_forced_reopen(act->port, 0, "ersff_2", NULL); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 606 | break; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 607 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
Christof Schmitt | 85600f7 | 2009-07-13 15:06:09 +0200 | [diff] [blame] | 608 | _zfcp_erp_port_reopen(act->port, 0, "ersff_3", NULL); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 609 | break; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 610 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 611 | _zfcp_erp_unit_reopen(act->unit, 0, "ersff_4", NULL, 0); |
Christof Schmitt | 85600f7 | 2009-07-13 15:06:09 +0200 | [diff] [blame] | 612 | break; |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | static void zfcp_erp_strategy_followup_success(struct zfcp_erp_action *act) |
| 617 | { |
| 618 | switch (act->action) { |
| 619 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
| 620 | _zfcp_erp_port_reopen_all(act->adapter, 0, "ersfs_1", NULL); |
| 621 | break; |
| 622 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
| 623 | _zfcp_erp_port_reopen(act->port, 0, "ersfs_2", NULL); |
| 624 | break; |
| 625 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
| 626 | _zfcp_erp_unit_reopen_all(act->port, 0, "ersfs_3", NULL); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 627 | break; |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | static void zfcp_erp_wakeup(struct zfcp_adapter *adapter) |
| 632 | { |
| 633 | unsigned long flags; |
| 634 | |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 635 | read_lock_irqsave(&adapter->erp_lock, flags); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 636 | if (list_empty(&adapter->erp_ready_head) && |
| 637 | list_empty(&adapter->erp_running_head)) { |
| 638 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, |
| 639 | &adapter->status); |
| 640 | wake_up(&adapter->erp_done_wqh); |
| 641 | } |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 642 | read_unlock_irqrestore(&adapter->erp_lock, flags); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | static int zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *act) |
| 646 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 647 | struct zfcp_qdio *qdio = act->adapter->qdio; |
| 648 | |
| 649 | if (zfcp_qdio_open(qdio)) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 650 | return ZFCP_ERP_FAILED; |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 651 | init_waitqueue_head(&qdio->req_q_wq); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 652 | atomic_set_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &act->adapter->status); |
| 653 | return ZFCP_ERP_SUCCEEDED; |
| 654 | } |
| 655 | |
| 656 | static void zfcp_erp_enqueue_ptp_port(struct zfcp_adapter *adapter) |
| 657 | { |
| 658 | struct zfcp_port *port; |
| 659 | port = zfcp_port_enqueue(adapter, adapter->peer_wwpn, 0, |
| 660 | adapter->peer_d_id); |
| 661 | if (IS_ERR(port)) /* error or port already attached */ |
| 662 | return; |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 663 | _zfcp_erp_port_reopen(port, 0, "ereptp1", NULL); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | static int zfcp_erp_adapter_strat_fsf_xconf(struct zfcp_erp_action *erp_action) |
| 667 | { |
| 668 | int retries; |
| 669 | int sleep = 1; |
| 670 | struct zfcp_adapter *adapter = erp_action->adapter; |
| 671 | |
| 672 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, &adapter->status); |
| 673 | |
| 674 | for (retries = 7; retries; retries--) { |
| 675 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, |
| 676 | &adapter->status); |
| 677 | write_lock_irq(&adapter->erp_lock); |
| 678 | zfcp_erp_action_to_running(erp_action); |
| 679 | write_unlock_irq(&adapter->erp_lock); |
| 680 | if (zfcp_fsf_exchange_config_data(erp_action)) { |
| 681 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, |
| 682 | &adapter->status); |
| 683 | return ZFCP_ERP_FAILED; |
| 684 | } |
| 685 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 686 | zfcp_dbf_rec_thread_lock("erasfx1", adapter->dbf); |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 687 | wait_event(adapter->erp_ready_wq, |
| 688 | !list_empty(&adapter->erp_ready_head)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 689 | zfcp_dbf_rec_thread_lock("erasfx2", adapter->dbf); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 690 | if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) |
| 691 | break; |
| 692 | |
| 693 | if (!(atomic_read(&adapter->status) & |
| 694 | ZFCP_STATUS_ADAPTER_HOST_CON_INIT)) |
| 695 | break; |
| 696 | |
| 697 | ssleep(sleep); |
| 698 | sleep *= 2; |
| 699 | } |
| 700 | |
| 701 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, |
| 702 | &adapter->status); |
| 703 | |
| 704 | if (!(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_XCONFIG_OK)) |
| 705 | return ZFCP_ERP_FAILED; |
| 706 | |
| 707 | if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP) |
| 708 | zfcp_erp_enqueue_ptp_port(adapter); |
| 709 | |
| 710 | return ZFCP_ERP_SUCCEEDED; |
| 711 | } |
| 712 | |
| 713 | static int zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *act) |
| 714 | { |
| 715 | int ret; |
| 716 | struct zfcp_adapter *adapter = act->adapter; |
| 717 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 718 | write_lock_irq(&adapter->erp_lock); |
| 719 | zfcp_erp_action_to_running(act); |
| 720 | write_unlock_irq(&adapter->erp_lock); |
| 721 | |
| 722 | ret = zfcp_fsf_exchange_port_data(act); |
| 723 | if (ret == -EOPNOTSUPP) |
| 724 | return ZFCP_ERP_SUCCEEDED; |
| 725 | if (ret) |
| 726 | return ZFCP_ERP_FAILED; |
| 727 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 728 | zfcp_dbf_rec_thread_lock("erasox1", adapter->dbf); |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 729 | wait_event(adapter->erp_ready_wq, |
| 730 | !list_empty(&adapter->erp_ready_head)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 731 | zfcp_dbf_rec_thread_lock("erasox2", adapter->dbf); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 732 | if (act->status & ZFCP_STATUS_ERP_TIMEDOUT) |
| 733 | return ZFCP_ERP_FAILED; |
| 734 | |
| 735 | return ZFCP_ERP_SUCCEEDED; |
| 736 | } |
| 737 | |
| 738 | static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *act) |
| 739 | { |
| 740 | if (zfcp_erp_adapter_strat_fsf_xconf(act) == ZFCP_ERP_FAILED) |
| 741 | return ZFCP_ERP_FAILED; |
| 742 | |
| 743 | if (zfcp_erp_adapter_strategy_open_fsf_xport(act) == ZFCP_ERP_FAILED) |
| 744 | return ZFCP_ERP_FAILED; |
| 745 | |
Christof Schmitt | 8d88cf3 | 2010-06-21 10:11:33 +0200 | [diff] [blame] | 746 | if (mempool_resize(act->adapter->pool.status_read_data, |
| 747 | act->adapter->stat_read_buf_num, GFP_KERNEL)) |
| 748 | return ZFCP_ERP_FAILED; |
| 749 | |
| 750 | if (mempool_resize(act->adapter->pool.status_read_req, |
| 751 | act->adapter->stat_read_buf_num, GFP_KERNEL)) |
| 752 | return ZFCP_ERP_FAILED; |
| 753 | |
Christof Schmitt | 64deb6e | 2010-04-30 18:09:36 +0200 | [diff] [blame] | 754 | atomic_set(&act->adapter->stat_miss, act->adapter->stat_read_buf_num); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 755 | if (zfcp_status_read_refill(act->adapter)) |
| 756 | return ZFCP_ERP_FAILED; |
| 757 | |
| 758 | return ZFCP_ERP_SUCCEEDED; |
| 759 | } |
| 760 | |
Swen Schillig | cf13c08 | 2009-03-02 13:09:03 +0100 | [diff] [blame] | 761 | static void zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *act) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 762 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 763 | struct zfcp_adapter *adapter = act->adapter; |
| 764 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 765 | /* close queues to ensure that buffers are not accessed by adapter */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 766 | zfcp_qdio_close(adapter->qdio); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 767 | zfcp_fsf_req_dismiss_all(adapter); |
| 768 | adapter->fsf_req_seq_no = 0; |
Christof Schmitt | 55c770f | 2009-08-18 15:43:12 +0200 | [diff] [blame] | 769 | zfcp_fc_wka_ports_force_offline(adapter->gs); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 770 | /* all ports and units are closed */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 771 | zfcp_erp_modify_adapter_status(adapter, "erascl1", NULL, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 772 | ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR); |
Swen Schillig | cf13c08 | 2009-03-02 13:09:03 +0100 | [diff] [blame] | 773 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 774 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK | |
Swen Schillig | cf13c08 | 2009-03-02 13:09:03 +0100 | [diff] [blame] | 775 | ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status); |
| 776 | } |
| 777 | |
| 778 | static int zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *act) |
| 779 | { |
| 780 | struct zfcp_adapter *adapter = act->adapter; |
| 781 | |
| 782 | if (zfcp_erp_adapter_strategy_open_qdio(act)) { |
| 783 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK | |
| 784 | ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, |
| 785 | &adapter->status); |
| 786 | return ZFCP_ERP_FAILED; |
| 787 | } |
| 788 | |
| 789 | if (zfcp_erp_adapter_strategy_open_fsf(act)) { |
| 790 | zfcp_erp_adapter_strategy_close(act); |
| 791 | return ZFCP_ERP_FAILED; |
| 792 | } |
| 793 | |
| 794 | atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &adapter->status); |
| 795 | |
| 796 | return ZFCP_ERP_SUCCEEDED; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *act) |
| 800 | { |
Swen Schillig | cf13c08 | 2009-03-02 13:09:03 +0100 | [diff] [blame] | 801 | struct zfcp_adapter *adapter = act->adapter; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 802 | |
Swen Schillig | cf13c08 | 2009-03-02 13:09:03 +0100 | [diff] [blame] | 803 | if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_OPEN) { |
| 804 | zfcp_erp_adapter_strategy_close(act); |
| 805 | if (act->status & ZFCP_STATUS_ERP_CLOSE_ONLY) |
| 806 | return ZFCP_ERP_EXIT; |
| 807 | } |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 808 | |
Swen Schillig | cf13c08 | 2009-03-02 13:09:03 +0100 | [diff] [blame] | 809 | if (zfcp_erp_adapter_strategy_open(act)) { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 810 | ssleep(8); |
Swen Schillig | cf13c08 | 2009-03-02 13:09:03 +0100 | [diff] [blame] | 811 | return ZFCP_ERP_FAILED; |
| 812 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | |
Swen Schillig | cf13c08 | 2009-03-02 13:09:03 +0100 | [diff] [blame] | 814 | return ZFCP_ERP_SUCCEEDED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | } |
| 816 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 817 | static int zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *act) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 819 | int retval; |
| 820 | |
| 821 | retval = zfcp_fsf_close_physical_port(act); |
| 822 | if (retval == -ENOMEM) |
| 823 | return ZFCP_ERP_NOMEM; |
| 824 | act->step = ZFCP_ERP_STEP_PHYS_PORT_CLOSING; |
| 825 | if (retval) |
| 826 | return ZFCP_ERP_FAILED; |
| 827 | |
| 828 | return ZFCP_ERP_CONTINUES; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | } |
| 830 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 831 | static void zfcp_erp_port_strategy_clearstati(struct zfcp_port *port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | { |
Christof Schmitt | a5b11dd | 2009-03-02 13:08:54 +0100 | [diff] [blame] | 833 | atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED, &port->status); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 834 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 836 | static int zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action) |
| 837 | { |
| 838 | struct zfcp_port *port = erp_action->port; |
| 839 | int status = atomic_read(&port->status); |
| 840 | |
| 841 | switch (erp_action->step) { |
| 842 | case ZFCP_ERP_STEP_UNINITIALIZED: |
| 843 | zfcp_erp_port_strategy_clearstati(port); |
| 844 | if ((status & ZFCP_STATUS_PORT_PHYS_OPEN) && |
| 845 | (status & ZFCP_STATUS_COMMON_OPEN)) |
| 846 | return zfcp_erp_port_forced_strategy_close(erp_action); |
| 847 | else |
| 848 | return ZFCP_ERP_FAILED; |
| 849 | |
| 850 | case ZFCP_ERP_STEP_PHYS_PORT_CLOSING: |
Christof Schmitt | ddb3e0c | 2009-07-13 15:06:08 +0200 | [diff] [blame] | 851 | if (!(status & ZFCP_STATUS_PORT_PHYS_OPEN)) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 852 | return ZFCP_ERP_SUCCEEDED; |
| 853 | } |
| 854 | return ZFCP_ERP_FAILED; |
| 855 | } |
| 856 | |
| 857 | static int zfcp_erp_port_strategy_close(struct zfcp_erp_action *erp_action) |
| 858 | { |
| 859 | int retval; |
| 860 | |
| 861 | retval = zfcp_fsf_close_port(erp_action); |
| 862 | if (retval == -ENOMEM) |
| 863 | return ZFCP_ERP_NOMEM; |
| 864 | erp_action->step = ZFCP_ERP_STEP_PORT_CLOSING; |
| 865 | if (retval) |
| 866 | return ZFCP_ERP_FAILED; |
| 867 | return ZFCP_ERP_CONTINUES; |
| 868 | } |
| 869 | |
| 870 | static int zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *erp_action) |
| 871 | { |
| 872 | int retval; |
| 873 | |
| 874 | retval = zfcp_fsf_open_port(erp_action); |
| 875 | if (retval == -ENOMEM) |
| 876 | return ZFCP_ERP_NOMEM; |
| 877 | erp_action->step = ZFCP_ERP_STEP_PORT_OPENING; |
| 878 | if (retval) |
| 879 | return ZFCP_ERP_FAILED; |
| 880 | return ZFCP_ERP_CONTINUES; |
| 881 | } |
| 882 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 883 | static int zfcp_erp_open_ptp_port(struct zfcp_erp_action *act) |
| 884 | { |
| 885 | struct zfcp_adapter *adapter = act->adapter; |
| 886 | struct zfcp_port *port = act->port; |
| 887 | |
| 888 | if (port->wwpn != adapter->peer_wwpn) { |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 889 | zfcp_erp_port_failed(port, "eroptp1", NULL); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 890 | return ZFCP_ERP_FAILED; |
| 891 | } |
| 892 | port->d_id = adapter->peer_d_id; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 893 | return zfcp_erp_port_strategy_open_port(act); |
| 894 | } |
| 895 | |
| 896 | static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *act) |
| 897 | { |
| 898 | struct zfcp_adapter *adapter = act->adapter; |
| 899 | struct zfcp_port *port = act->port; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 900 | int p_status = atomic_read(&port->status); |
| 901 | |
| 902 | switch (act->step) { |
| 903 | case ZFCP_ERP_STEP_UNINITIALIZED: |
| 904 | case ZFCP_ERP_STEP_PHYS_PORT_CLOSING: |
| 905 | case ZFCP_ERP_STEP_PORT_CLOSING: |
| 906 | if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP) |
| 907 | return zfcp_erp_open_ptp_port(act); |
Christof Schmitt | b98478d | 2008-12-19 16:56:59 +0100 | [diff] [blame] | 908 | if (!port->d_id) { |
Christof Schmitt | 934aeb587 | 2009-10-14 11:00:43 +0200 | [diff] [blame] | 909 | zfcp_fc_trigger_did_lookup(port); |
Christof Schmitt | 799b76d | 2009-08-18 15:43:20 +0200 | [diff] [blame] | 910 | return ZFCP_ERP_EXIT; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 911 | } |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 912 | return zfcp_erp_port_strategy_open_port(act); |
| 913 | |
| 914 | case ZFCP_ERP_STEP_PORT_OPENING: |
| 915 | /* D_ID might have changed during open */ |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 916 | if (p_status & ZFCP_STATUS_COMMON_OPEN) { |
Christof Schmitt | 934aeb587 | 2009-10-14 11:00:43 +0200 | [diff] [blame] | 917 | if (!port->d_id) { |
| 918 | zfcp_fc_trigger_did_lookup(port); |
| 919 | return ZFCP_ERP_EXIT; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 920 | } |
Christof Schmitt | 934aeb587 | 2009-10-14 11:00:43 +0200 | [diff] [blame] | 921 | return ZFCP_ERP_SUCCEEDED; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 922 | } |
Swen Schillig | ea460a8 | 2009-05-15 13:18:20 +0200 | [diff] [blame] | 923 | if (port->d_id && !(p_status & ZFCP_STATUS_COMMON_NOESC)) { |
| 924 | port->d_id = 0; |
Christof Schmitt | f7bd7c3 | 2010-07-08 09:53:10 +0200 | [diff] [blame] | 925 | return ZFCP_ERP_FAILED; |
Swen Schillig | ea460a8 | 2009-05-15 13:18:20 +0200 | [diff] [blame] | 926 | } |
| 927 | /* fall through otherwise */ |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 928 | } |
| 929 | return ZFCP_ERP_FAILED; |
| 930 | } |
| 931 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 932 | static int zfcp_erp_port_strategy(struct zfcp_erp_action *erp_action) |
| 933 | { |
| 934 | struct zfcp_port *port = erp_action->port; |
Christof Schmitt | 934aeb587 | 2009-10-14 11:00:43 +0200 | [diff] [blame] | 935 | int p_status = atomic_read(&port->status); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 936 | |
Christof Schmitt | 934aeb587 | 2009-10-14 11:00:43 +0200 | [diff] [blame] | 937 | if ((p_status & ZFCP_STATUS_COMMON_NOESC) && |
| 938 | !(p_status & ZFCP_STATUS_COMMON_OPEN)) |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 939 | goto close_init_done; |
| 940 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 941 | switch (erp_action->step) { |
| 942 | case ZFCP_ERP_STEP_UNINITIALIZED: |
| 943 | zfcp_erp_port_strategy_clearstati(port); |
Christof Schmitt | 934aeb587 | 2009-10-14 11:00:43 +0200 | [diff] [blame] | 944 | if (p_status & ZFCP_STATUS_COMMON_OPEN) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 945 | return zfcp_erp_port_strategy_close(erp_action); |
| 946 | break; |
| 947 | |
| 948 | case ZFCP_ERP_STEP_PORT_CLOSING: |
Christof Schmitt | 934aeb587 | 2009-10-14 11:00:43 +0200 | [diff] [blame] | 949 | if (p_status & ZFCP_STATUS_COMMON_OPEN) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 950 | return ZFCP_ERP_FAILED; |
| 951 | break; |
| 952 | } |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 953 | |
| 954 | close_init_done: |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 955 | if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY) |
| 956 | return ZFCP_ERP_EXIT; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 957 | |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 958 | return zfcp_erp_port_strategy_open_common(erp_action); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 959 | } |
| 960 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 961 | static void zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *unit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | { |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 963 | atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 964 | ZFCP_STATUS_UNIT_SHARED | |
| 965 | ZFCP_STATUS_UNIT_READONLY, |
| 966 | &unit->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | } |
| 968 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 969 | static int zfcp_erp_unit_strategy_close(struct zfcp_erp_action *erp_action) |
| 970 | { |
| 971 | int retval = zfcp_fsf_close_unit(erp_action); |
| 972 | if (retval == -ENOMEM) |
| 973 | return ZFCP_ERP_NOMEM; |
| 974 | erp_action->step = ZFCP_ERP_STEP_UNIT_CLOSING; |
| 975 | if (retval) |
| 976 | return ZFCP_ERP_FAILED; |
| 977 | return ZFCP_ERP_CONTINUES; |
| 978 | } |
| 979 | |
| 980 | static int zfcp_erp_unit_strategy_open(struct zfcp_erp_action *erp_action) |
| 981 | { |
| 982 | int retval = zfcp_fsf_open_unit(erp_action); |
| 983 | if (retval == -ENOMEM) |
| 984 | return ZFCP_ERP_NOMEM; |
| 985 | erp_action->step = ZFCP_ERP_STEP_UNIT_OPENING; |
| 986 | if (retval) |
| 987 | return ZFCP_ERP_FAILED; |
| 988 | return ZFCP_ERP_CONTINUES; |
| 989 | } |
| 990 | |
| 991 | static int zfcp_erp_unit_strategy(struct zfcp_erp_action *erp_action) |
| 992 | { |
| 993 | struct zfcp_unit *unit = erp_action->unit; |
| 994 | |
| 995 | switch (erp_action->step) { |
| 996 | case ZFCP_ERP_STEP_UNINITIALIZED: |
| 997 | zfcp_erp_unit_strategy_clearstati(unit); |
| 998 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN) |
| 999 | return zfcp_erp_unit_strategy_close(erp_action); |
| 1000 | /* already closed, fall through */ |
| 1001 | case ZFCP_ERP_STEP_UNIT_CLOSING: |
| 1002 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN) |
| 1003 | return ZFCP_ERP_FAILED; |
| 1004 | if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY) |
| 1005 | return ZFCP_ERP_EXIT; |
| 1006 | return zfcp_erp_unit_strategy_open(erp_action); |
| 1007 | |
| 1008 | case ZFCP_ERP_STEP_UNIT_OPENING: |
| 1009 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN) |
| 1010 | return ZFCP_ERP_SUCCEEDED; |
| 1011 | } |
| 1012 | return ZFCP_ERP_FAILED; |
| 1013 | } |
| 1014 | |
| 1015 | static int zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result) |
| 1016 | { |
| 1017 | switch (result) { |
| 1018 | case ZFCP_ERP_SUCCEEDED : |
| 1019 | atomic_set(&unit->erp_counter, 0); |
| 1020 | zfcp_erp_unit_unblock(unit); |
| 1021 | break; |
| 1022 | case ZFCP_ERP_FAILED : |
| 1023 | atomic_inc(&unit->erp_counter); |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1024 | if (atomic_read(&unit->erp_counter) > ZFCP_MAX_ERPS) { |
| 1025 | dev_err(&unit->port->adapter->ccw_device->dev, |
| 1026 | "ERP failed for unit 0x%016Lx on " |
| 1027 | "port 0x%016Lx\n", |
Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 1028 | (unsigned long long)unit->fcp_lun, |
| 1029 | (unsigned long long)unit->port->wwpn); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1030 | zfcp_erp_unit_failed(unit, "erusck1", NULL); |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1031 | } |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1032 | break; |
| 1033 | } |
| 1034 | |
| 1035 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { |
| 1036 | zfcp_erp_unit_block(unit, 0); |
| 1037 | result = ZFCP_ERP_EXIT; |
| 1038 | } |
| 1039 | return result; |
| 1040 | } |
| 1041 | |
| 1042 | static int zfcp_erp_strategy_check_port(struct zfcp_port *port, int result) |
| 1043 | { |
| 1044 | switch (result) { |
| 1045 | case ZFCP_ERP_SUCCEEDED : |
| 1046 | atomic_set(&port->erp_counter, 0); |
| 1047 | zfcp_erp_port_unblock(port); |
| 1048 | break; |
| 1049 | |
| 1050 | case ZFCP_ERP_FAILED : |
| 1051 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_NOESC) { |
| 1052 | zfcp_erp_port_block(port, 0); |
| 1053 | result = ZFCP_ERP_EXIT; |
| 1054 | } |
| 1055 | atomic_inc(&port->erp_counter); |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1056 | if (atomic_read(&port->erp_counter) > ZFCP_MAX_ERPS) { |
| 1057 | dev_err(&port->adapter->ccw_device->dev, |
| 1058 | "ERP failed for remote port 0x%016Lx\n", |
Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 1059 | (unsigned long long)port->wwpn); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1060 | zfcp_erp_port_failed(port, "erpsck1", NULL); |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1061 | } |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1062 | break; |
| 1063 | } |
| 1064 | |
| 1065 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { |
| 1066 | zfcp_erp_port_block(port, 0); |
| 1067 | result = ZFCP_ERP_EXIT; |
| 1068 | } |
| 1069 | return result; |
| 1070 | } |
| 1071 | |
| 1072 | static int zfcp_erp_strategy_check_adapter(struct zfcp_adapter *adapter, |
| 1073 | int result) |
| 1074 | { |
| 1075 | switch (result) { |
| 1076 | case ZFCP_ERP_SUCCEEDED : |
| 1077 | atomic_set(&adapter->erp_counter, 0); |
| 1078 | zfcp_erp_adapter_unblock(adapter); |
| 1079 | break; |
| 1080 | |
| 1081 | case ZFCP_ERP_FAILED : |
| 1082 | atomic_inc(&adapter->erp_counter); |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1083 | if (atomic_read(&adapter->erp_counter) > ZFCP_MAX_ERPS) { |
| 1084 | dev_err(&adapter->ccw_device->dev, |
| 1085 | "ERP cannot recover an error " |
| 1086 | "on the FCP device\n"); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1087 | zfcp_erp_adapter_failed(adapter, "erasck1", NULL); |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1088 | } |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1089 | break; |
| 1090 | } |
| 1091 | |
| 1092 | if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { |
| 1093 | zfcp_erp_adapter_block(adapter, 0); |
| 1094 | result = ZFCP_ERP_EXIT; |
| 1095 | } |
| 1096 | return result; |
| 1097 | } |
| 1098 | |
| 1099 | static int zfcp_erp_strategy_check_target(struct zfcp_erp_action *erp_action, |
| 1100 | int result) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1101 | { |
| 1102 | struct zfcp_adapter *adapter = erp_action->adapter; |
| 1103 | struct zfcp_port *port = erp_action->port; |
| 1104 | struct zfcp_unit *unit = erp_action->unit; |
| 1105 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1106 | switch (erp_action->action) { |
| 1107 | |
| 1108 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
| 1109 | result = zfcp_erp_strategy_check_unit(unit, result); |
| 1110 | break; |
| 1111 | |
| 1112 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
| 1113 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
| 1114 | result = zfcp_erp_strategy_check_port(port, result); |
| 1115 | break; |
| 1116 | |
| 1117 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
| 1118 | result = zfcp_erp_strategy_check_adapter(adapter, result); |
| 1119 | break; |
| 1120 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | return result; |
| 1122 | } |
| 1123 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1124 | static int zfcp_erp_strat_change_det(atomic_t *target_status, u32 erp_status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1126 | int status = atomic_read(target_status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1128 | if ((status & ZFCP_STATUS_COMMON_RUNNING) && |
| 1129 | (erp_status & ZFCP_STATUS_ERP_CLOSE_ONLY)) |
| 1130 | return 1; /* take it online */ |
| 1131 | |
| 1132 | if (!(status & ZFCP_STATUS_COMMON_RUNNING) && |
| 1133 | !(erp_status & ZFCP_STATUS_ERP_CLOSE_ONLY)) |
| 1134 | return 1; /* take it offline */ |
| 1135 | |
| 1136 | return 0; |
| 1137 | } |
| 1138 | |
| 1139 | static int zfcp_erp_strategy_statechange(struct zfcp_erp_action *act, int ret) |
| 1140 | { |
| 1141 | int action = act->action; |
| 1142 | struct zfcp_adapter *adapter = act->adapter; |
| 1143 | struct zfcp_port *port = act->port; |
| 1144 | struct zfcp_unit *unit = act->unit; |
| 1145 | u32 erp_status = act->status; |
| 1146 | |
| 1147 | switch (action) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1149 | if (zfcp_erp_strat_change_det(&adapter->status, erp_status)) { |
| 1150 | _zfcp_erp_adapter_reopen(adapter, |
| 1151 | ZFCP_STATUS_COMMON_ERP_FAILED, |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1152 | "ersscg1", NULL); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1153 | return ZFCP_ERP_EXIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1154 | } |
| 1155 | break; |
| 1156 | |
| 1157 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
| 1158 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1159 | if (zfcp_erp_strat_change_det(&port->status, erp_status)) { |
| 1160 | _zfcp_erp_port_reopen(port, |
| 1161 | ZFCP_STATUS_COMMON_ERP_FAILED, |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1162 | "ersscg2", NULL); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1163 | return ZFCP_ERP_EXIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | } |
| 1165 | break; |
| 1166 | |
| 1167 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1168 | if (zfcp_erp_strat_change_det(&unit->status, erp_status)) { |
| 1169 | _zfcp_erp_unit_reopen(unit, |
| 1170 | ZFCP_STATUS_COMMON_ERP_FAILED, |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 1171 | "ersscg3", NULL, 0); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1172 | return ZFCP_ERP_EXIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1173 | } |
| 1174 | break; |
| 1175 | } |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1176 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | } |
| 1178 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1179 | static void zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1180 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1181 | struct zfcp_adapter *adapter = erp_action->adapter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1182 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1183 | adapter->erp_total_count--; |
| 1184 | if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) { |
| 1185 | adapter->erp_low_mem_count--; |
| 1186 | erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1187 | } |
| 1188 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1189 | list_del(&erp_action->list); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1190 | zfcp_dbf_rec_action("eractd1", erp_action); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1192 | switch (erp_action->action) { |
| 1193 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
| 1194 | atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE, |
| 1195 | &erp_action->unit->status); |
| 1196 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1197 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1198 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
| 1199 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
| 1200 | atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE, |
| 1201 | &erp_action->port->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | break; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1203 | |
| 1204 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
| 1205 | atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE, |
| 1206 | &erp_action->adapter->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1207 | break; |
| 1208 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | } |
| 1210 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1211 | static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result) |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 1212 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1213 | struct zfcp_adapter *adapter = act->adapter; |
| 1214 | struct zfcp_port *port = act->port; |
| 1215 | struct zfcp_unit *unit = act->unit; |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 1216 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1217 | switch (act->action) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1218 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
Christof Schmitt | fdbd1c5 | 2010-09-08 14:39:54 +0200 | [diff] [blame^] | 1219 | if (!(act->status & ZFCP_STATUS_ERP_NO_REF)) |
| 1220 | put_device(&unit->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | break; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1222 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1223 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame] | 1224 | if (result == ZFCP_ERP_SUCCEEDED) |
| 1225 | zfcp_scsi_schedule_rport_register(port); |
Christof Schmitt | 5767620 | 2010-07-08 09:53:05 +0200 | [diff] [blame] | 1226 | /* fall through */ |
| 1227 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 1228 | put_device(&port->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1229 | break; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1230 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1231 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame] | 1232 | if (result == ZFCP_ERP_SUCCEEDED) { |
Christof Schmitt | bd43a42b7 | 2008-12-25 13:38:50 +0100 | [diff] [blame] | 1233 | register_service_level(&adapter->service_level); |
Swen Schillig | 9eae07e | 2009-11-24 16:54:06 +0100 | [diff] [blame] | 1234 | queue_work(adapter->work_queue, &adapter->scan_work); |
Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame] | 1235 | } else |
| 1236 | unregister_service_level(&adapter->service_level); |
Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 1237 | kref_put(&adapter->ref, zfcp_adapter_release); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1238 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1239 | } |
| 1240 | } |
| 1241 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1242 | static int zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action) |
| 1243 | { |
| 1244 | switch (erp_action->action) { |
| 1245 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
| 1246 | return zfcp_erp_adapter_strategy(erp_action); |
| 1247 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
| 1248 | return zfcp_erp_port_forced_strategy(erp_action); |
| 1249 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
| 1250 | return zfcp_erp_port_strategy(erp_action); |
| 1251 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
| 1252 | return zfcp_erp_unit_strategy(erp_action); |
| 1253 | } |
| 1254 | return ZFCP_ERP_FAILED; |
| 1255 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1256 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1257 | static int zfcp_erp_strategy(struct zfcp_erp_action *erp_action) |
| 1258 | { |
| 1259 | int retval; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1260 | unsigned long flags; |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1261 | struct zfcp_adapter *adapter = erp_action->adapter; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1262 | |
Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 1263 | kref_get(&adapter->ref); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1264 | |
Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 1265 | write_lock_irqsave(&adapter->erp_lock, flags); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1266 | zfcp_erp_strategy_check_fsfreq(erp_action); |
| 1267 | |
| 1268 | if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) { |
| 1269 | zfcp_erp_action_dequeue(erp_action); |
| 1270 | retval = ZFCP_ERP_DISMISSED; |
| 1271 | goto unlock; |
| 1272 | } |
| 1273 | |
Christof Schmitt | 9c785d9 | 2010-07-08 09:53:09 +0200 | [diff] [blame] | 1274 | if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) { |
| 1275 | retval = ZFCP_ERP_FAILED; |
| 1276 | goto check_target; |
| 1277 | } |
| 1278 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1279 | zfcp_erp_action_to_running(erp_action); |
| 1280 | |
| 1281 | /* no lock to allow for blocking operations */ |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1282 | write_unlock_irqrestore(&adapter->erp_lock, flags); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1283 | retval = zfcp_erp_strategy_do_action(erp_action); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1284 | write_lock_irqsave(&adapter->erp_lock, flags); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1285 | |
| 1286 | if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) |
| 1287 | retval = ZFCP_ERP_CONTINUES; |
| 1288 | |
| 1289 | switch (retval) { |
| 1290 | case ZFCP_ERP_NOMEM: |
| 1291 | if (!(erp_action->status & ZFCP_STATUS_ERP_LOWMEM)) { |
| 1292 | ++adapter->erp_low_mem_count; |
| 1293 | erp_action->status |= ZFCP_STATUS_ERP_LOWMEM; |
| 1294 | } |
| 1295 | if (adapter->erp_total_count == adapter->erp_low_mem_count) |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1296 | _zfcp_erp_adapter_reopen(adapter, 0, "erstgy1", NULL); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1297 | else { |
| 1298 | zfcp_erp_strategy_memwait(erp_action); |
| 1299 | retval = ZFCP_ERP_CONTINUES; |
| 1300 | } |
| 1301 | goto unlock; |
| 1302 | |
| 1303 | case ZFCP_ERP_CONTINUES: |
| 1304 | if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) { |
| 1305 | --adapter->erp_low_mem_count; |
| 1306 | erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM; |
| 1307 | } |
| 1308 | goto unlock; |
| 1309 | } |
| 1310 | |
Christof Schmitt | 9c785d9 | 2010-07-08 09:53:09 +0200 | [diff] [blame] | 1311 | check_target: |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1312 | retval = zfcp_erp_strategy_check_target(erp_action, retval); |
| 1313 | zfcp_erp_action_dequeue(erp_action); |
| 1314 | retval = zfcp_erp_strategy_statechange(erp_action, retval); |
| 1315 | if (retval == ZFCP_ERP_EXIT) |
| 1316 | goto unlock; |
Christof Schmitt | 85600f7 | 2009-07-13 15:06:09 +0200 | [diff] [blame] | 1317 | if (retval == ZFCP_ERP_SUCCEEDED) |
| 1318 | zfcp_erp_strategy_followup_success(erp_action); |
| 1319 | if (retval == ZFCP_ERP_FAILED) |
| 1320 | zfcp_erp_strategy_followup_failed(erp_action); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1321 | |
| 1322 | unlock: |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1323 | write_unlock_irqrestore(&adapter->erp_lock, flags); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1324 | |
| 1325 | if (retval != ZFCP_ERP_CONTINUES) |
| 1326 | zfcp_erp_action_cleanup(erp_action, retval); |
| 1327 | |
Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 1328 | kref_put(&adapter->ref, zfcp_adapter_release); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1329 | return retval; |
| 1330 | } |
| 1331 | |
| 1332 | static int zfcp_erp_thread(void *data) |
| 1333 | { |
| 1334 | struct zfcp_adapter *adapter = (struct zfcp_adapter *) data; |
| 1335 | struct list_head *next; |
| 1336 | struct zfcp_erp_action *act; |
| 1337 | unsigned long flags; |
| 1338 | |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 1339 | for (;;) { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1340 | zfcp_dbf_rec_thread_lock("erthrd1", adapter->dbf); |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 1341 | wait_event_interruptible(adapter->erp_ready_wq, |
| 1342 | !list_empty(&adapter->erp_ready_head) || |
| 1343 | kthread_should_stop()); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1344 | zfcp_dbf_rec_thread_lock("erthrd2", adapter->dbf); |
Swen Schillig | 94ab4b3 | 2009-04-17 15:08:06 +0200 | [diff] [blame] | 1345 | |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 1346 | if (kthread_should_stop()) |
| 1347 | break; |
| 1348 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1349 | write_lock_irqsave(&adapter->erp_lock, flags); |
| 1350 | next = adapter->erp_ready_head.next; |
| 1351 | write_unlock_irqrestore(&adapter->erp_lock, flags); |
| 1352 | |
| 1353 | if (next != &adapter->erp_ready_head) { |
| 1354 | act = list_entry(next, struct zfcp_erp_action, list); |
| 1355 | |
| 1356 | /* there is more to come after dismission, no notify */ |
| 1357 | if (zfcp_erp_strategy(act) != ZFCP_ERP_DISMISSED) |
| 1358 | zfcp_erp_wakeup(adapter); |
| 1359 | } |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1360 | } |
| 1361 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1362 | return 0; |
| 1363 | } |
| 1364 | |
| 1365 | /** |
| 1366 | * zfcp_erp_thread_setup - Start ERP thread for adapter |
| 1367 | * @adapter: Adapter to start the ERP thread for |
| 1368 | * |
| 1369 | * Returns 0 on success or error code from kernel_thread() |
| 1370 | */ |
| 1371 | int zfcp_erp_thread_setup(struct zfcp_adapter *adapter) |
| 1372 | { |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 1373 | struct task_struct *thread; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1374 | |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 1375 | thread = kthread_run(zfcp_erp_thread, adapter, "zfcperp%s", |
| 1376 | dev_name(&adapter->ccw_device->dev)); |
| 1377 | if (IS_ERR(thread)) { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1378 | dev_err(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1379 | "Creating an ERP thread for the FCP device failed.\n"); |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 1380 | return PTR_ERR(thread); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1381 | } |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 1382 | |
| 1383 | adapter->erp_thread = thread; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1384 | return 0; |
| 1385 | } |
| 1386 | |
| 1387 | /** |
| 1388 | * zfcp_erp_thread_kill - Stop ERP thread. |
| 1389 | * @adapter: Adapter where the ERP thread should be stopped. |
| 1390 | * |
| 1391 | * The caller of this routine ensures that the specified adapter has |
| 1392 | * been shut down and that this operation has been completed. Thus, |
| 1393 | * there are no pending erp_actions which would need to be handled |
| 1394 | * here. |
| 1395 | */ |
| 1396 | void zfcp_erp_thread_kill(struct zfcp_adapter *adapter) |
| 1397 | { |
Christof Schmitt | 347c6a9 | 2009-08-18 15:43:25 +0200 | [diff] [blame] | 1398 | kthread_stop(adapter->erp_thread); |
| 1399 | adapter->erp_thread = NULL; |
Christof Schmitt | 143bb6b | 2009-08-18 15:43:27 +0200 | [diff] [blame] | 1400 | WARN_ON(!list_empty(&adapter->erp_ready_head)); |
| 1401 | WARN_ON(!list_empty(&adapter->erp_running_head)); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1402 | } |
| 1403 | |
| 1404 | /** |
| 1405 | * zfcp_erp_adapter_failed - Set adapter status to failed. |
| 1406 | * @adapter: Failed adapter. |
| 1407 | * @id: Event id for debug trace. |
| 1408 | * @ref: Reference for debug trace. |
| 1409 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1410 | void zfcp_erp_adapter_failed(struct zfcp_adapter *adapter, char *id, void *ref) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1411 | { |
| 1412 | zfcp_erp_modify_adapter_status(adapter, id, ref, |
| 1413 | ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1414 | } |
| 1415 | |
| 1416 | /** |
| 1417 | * zfcp_erp_port_failed - Set port status to failed. |
| 1418 | * @port: Failed port. |
| 1419 | * @id: Event id for debug trace. |
| 1420 | * @ref: Reference for debug trace. |
| 1421 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1422 | void zfcp_erp_port_failed(struct zfcp_port *port, char *id, void *ref) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1423 | { |
| 1424 | zfcp_erp_modify_port_status(port, id, ref, |
| 1425 | ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1426 | } |
| 1427 | |
| 1428 | /** |
| 1429 | * zfcp_erp_unit_failed - Set unit status to failed. |
| 1430 | * @unit: Failed unit. |
| 1431 | * @id: Event id for debug trace. |
| 1432 | * @ref: Reference for debug trace. |
| 1433 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1434 | void zfcp_erp_unit_failed(struct zfcp_unit *unit, char *id, void *ref) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1435 | { |
| 1436 | zfcp_erp_modify_unit_status(unit, id, ref, |
| 1437 | ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1438 | } |
| 1439 | |
| 1440 | /** |
| 1441 | * zfcp_erp_wait - wait for completion of error recovery on an adapter |
| 1442 | * @adapter: adapter for which to wait for completion of its error recovery |
| 1443 | */ |
| 1444 | void zfcp_erp_wait(struct zfcp_adapter *adapter) |
| 1445 | { |
| 1446 | wait_event(adapter->erp_done_wqh, |
| 1447 | !(atomic_read(&adapter->status) & |
| 1448 | ZFCP_STATUS_ADAPTER_ERP_PENDING)); |
| 1449 | } |
| 1450 | |
| 1451 | /** |
| 1452 | * zfcp_erp_modify_adapter_status - change adapter status bits |
| 1453 | * @adapter: adapter to change the status |
| 1454 | * @id: id for the debug trace |
| 1455 | * @ref: reference for the debug trace |
| 1456 | * @mask: status bits to change |
| 1457 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR |
| 1458 | * |
| 1459 | * Changes in common status bits are propagated to attached ports and units. |
| 1460 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1461 | void zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter, char *id, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1462 | void *ref, u32 mask, int set_or_clear) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1463 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | struct zfcp_port *port; |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1465 | unsigned long flags; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1466 | u32 common_mask = mask & ZFCP_COMMON_FLAGS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1467 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1468 | if (set_or_clear == ZFCP_SET) { |
| 1469 | if (status_change_set(mask, &adapter->status)) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1470 | zfcp_dbf_rec_adapter(id, ref, adapter->dbf); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1471 | atomic_set_mask(mask, &adapter->status); |
| 1472 | } else { |
| 1473 | if (status_change_clear(mask, &adapter->status)) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1474 | zfcp_dbf_rec_adapter(id, ref, adapter->dbf); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1475 | atomic_clear_mask(mask, &adapter->status); |
| 1476 | if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) |
| 1477 | atomic_set(&adapter->erp_counter, 0); |
| 1478 | } |
| 1479 | |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1480 | if (common_mask) { |
| 1481 | read_lock_irqsave(&adapter->port_list_lock, flags); |
| 1482 | list_for_each_entry(port, &adapter->port_list, list) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1483 | zfcp_erp_modify_port_status(port, id, ref, common_mask, |
| 1484 | set_or_clear); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1485 | read_unlock_irqrestore(&adapter->port_list_lock, flags); |
| 1486 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1487 | } |
| 1488 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1489 | /** |
| 1490 | * zfcp_erp_modify_port_status - change port status bits |
| 1491 | * @port: port to change the status bits |
| 1492 | * @id: id for the debug trace |
| 1493 | * @ref: reference for the debug trace |
| 1494 | * @mask: status bits to change |
| 1495 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR |
| 1496 | * |
| 1497 | * Changes in common status bits are propagated to attached units. |
| 1498 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1499 | void zfcp_erp_modify_port_status(struct zfcp_port *port, char *id, void *ref, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1500 | u32 mask, int set_or_clear) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1501 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1502 | struct zfcp_unit *unit; |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1503 | unsigned long flags; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1504 | u32 common_mask = mask & ZFCP_COMMON_FLAGS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1505 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1506 | if (set_or_clear == ZFCP_SET) { |
| 1507 | if (status_change_set(mask, &port->status)) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1508 | zfcp_dbf_rec_port(id, ref, port); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1509 | atomic_set_mask(mask, &port->status); |
| 1510 | } else { |
| 1511 | if (status_change_clear(mask, &port->status)) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1512 | zfcp_dbf_rec_port(id, ref, port); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1513 | atomic_clear_mask(mask, &port->status); |
| 1514 | if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) |
| 1515 | atomic_set(&port->erp_counter, 0); |
| 1516 | } |
| 1517 | |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1518 | if (common_mask) { |
| 1519 | read_lock_irqsave(&port->unit_list_lock, flags); |
| 1520 | list_for_each_entry(unit, &port->unit_list, list) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1521 | zfcp_erp_modify_unit_status(unit, id, ref, common_mask, |
| 1522 | set_or_clear); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1523 | read_unlock_irqrestore(&port->unit_list_lock, flags); |
| 1524 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1525 | } |
| 1526 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1527 | /** |
| 1528 | * zfcp_erp_modify_unit_status - change unit status bits |
| 1529 | * @unit: unit to change the status bits |
| 1530 | * @id: id for the debug trace |
| 1531 | * @ref: reference for the debug trace |
| 1532 | * @mask: status bits to change |
| 1533 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR |
| 1534 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1535 | void zfcp_erp_modify_unit_status(struct zfcp_unit *unit, char *id, void *ref, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1536 | u32 mask, int set_or_clear) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1537 | { |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1538 | if (set_or_clear == ZFCP_SET) { |
| 1539 | if (status_change_set(mask, &unit->status)) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1540 | zfcp_dbf_rec_unit(id, ref, unit); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1541 | atomic_set_mask(mask, &unit->status); |
| 1542 | } else { |
| 1543 | if (status_change_clear(mask, &unit->status)) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1544 | zfcp_dbf_rec_unit(id, ref, unit); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1545 | atomic_clear_mask(mask, &unit->status); |
| 1546 | if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) { |
| 1547 | atomic_set(&unit->erp_counter, 0); |
| 1548 | } |
| 1549 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1550 | } |
| 1551 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1552 | /** |
| 1553 | * zfcp_erp_port_boxed - Mark port as "boxed" and start ERP |
| 1554 | * @port: The "boxed" port. |
| 1555 | * @id: The debug trace id. |
| 1556 | * @id: Reference for the debug trace. |
| 1557 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1558 | void zfcp_erp_port_boxed(struct zfcp_port *port, char *id, void *ref) |
Andreas Herrmann | d736a27b | 2005-06-13 13:23:57 +0200 | [diff] [blame] | 1559 | { |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 1560 | zfcp_erp_modify_port_status(port, id, ref, |
| 1561 | ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET); |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 1562 | zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); |
Andreas Herrmann | d736a27b | 2005-06-13 13:23:57 +0200 | [diff] [blame] | 1563 | } |
| 1564 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1565 | /** |
| 1566 | * zfcp_erp_unit_boxed - Mark unit as "boxed" and start ERP |
| 1567 | * @port: The "boxed" unit. |
| 1568 | * @id: The debug trace id. |
| 1569 | * @id: Reference for the debug trace. |
| 1570 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1571 | void zfcp_erp_unit_boxed(struct zfcp_unit *unit, char *id, void *ref) |
Andreas Herrmann | d736a27b | 2005-06-13 13:23:57 +0200 | [diff] [blame] | 1572 | { |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 1573 | zfcp_erp_modify_unit_status(unit, id, ref, |
| 1574 | ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET); |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 1575 | zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); |
Andreas Herrmann | d736a27b | 2005-06-13 13:23:57 +0200 | [diff] [blame] | 1576 | } |
| 1577 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1578 | /** |
| 1579 | * zfcp_erp_port_access_denied - Adapter denied access to port. |
| 1580 | * @port: port where access has been denied |
| 1581 | * @id: id for debug trace |
| 1582 | * @ref: reference for debug trace |
| 1583 | * |
| 1584 | * Since the adapter has denied access, stop using the port and the |
| 1585 | * attached units. |
| 1586 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1587 | void zfcp_erp_port_access_denied(struct zfcp_port *port, char *id, void *ref) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1588 | { |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 1589 | zfcp_erp_modify_port_status(port, id, ref, |
| 1590 | ZFCP_STATUS_COMMON_ERP_FAILED | |
| 1591 | ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1592 | } |
| 1593 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1594 | /** |
| 1595 | * zfcp_erp_unit_access_denied - Adapter denied access to unit. |
| 1596 | * @unit: unit where access has been denied |
| 1597 | * @id: id for debug trace |
| 1598 | * @ref: reference for debug trace |
| 1599 | * |
| 1600 | * Since the adapter has denied access, stop using the unit. |
| 1601 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1602 | void zfcp_erp_unit_access_denied(struct zfcp_unit *unit, char *id, void *ref) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1603 | { |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 1604 | zfcp_erp_modify_unit_status(unit, id, ref, |
| 1605 | ZFCP_STATUS_COMMON_ERP_FAILED | |
| 1606 | ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1607 | } |
| 1608 | |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1609 | static void zfcp_erp_unit_access_changed(struct zfcp_unit *unit, char *id, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1610 | void *ref) |
| 1611 | { |
| 1612 | int status = atomic_read(&unit->status); |
| 1613 | if (!(status & (ZFCP_STATUS_COMMON_ACCESS_DENIED | |
| 1614 | ZFCP_STATUS_COMMON_ACCESS_BOXED))) |
| 1615 | return; |
| 1616 | |
| 1617 | zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); |
| 1618 | } |
| 1619 | |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1620 | static void zfcp_erp_port_access_changed(struct zfcp_port *port, char *id, |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1621 | void *ref) |
| 1622 | { |
| 1623 | struct zfcp_unit *unit; |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1624 | unsigned long flags; |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1625 | int status = atomic_read(&port->status); |
| 1626 | |
| 1627 | if (!(status & (ZFCP_STATUS_COMMON_ACCESS_DENIED | |
| 1628 | ZFCP_STATUS_COMMON_ACCESS_BOXED))) { |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1629 | read_lock_irqsave(&port->unit_list_lock, flags); |
| 1630 | list_for_each_entry(unit, &port->unit_list, list) |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1631 | zfcp_erp_unit_access_changed(unit, id, ref); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1632 | read_unlock_irqrestore(&port->unit_list_lock, flags); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1633 | return; |
| 1634 | } |
| 1635 | |
| 1636 | zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); |
| 1637 | } |
| 1638 | |
| 1639 | /** |
| 1640 | * zfcp_erp_adapter_access_changed - Process change in adapter ACT |
| 1641 | * @adapter: Adapter where the Access Control Table (ACT) changed |
| 1642 | * @id: Id for debug trace |
| 1643 | * @ref: Reference for debug trace |
| 1644 | */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1645 | void zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter, char *id, |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 1646 | void *ref) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1647 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1648 | unsigned long flags; |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1649 | struct zfcp_port *port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1650 | |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 1651 | if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) |
| 1652 | return; |
| 1653 | |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1654 | read_lock_irqsave(&adapter->port_list_lock, flags); |
| 1655 | list_for_each_entry(port, &adapter->port_list, list) |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1656 | zfcp_erp_port_access_changed(port, id, ref); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1657 | read_unlock_irqrestore(&adapter->port_list_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1658 | } |