| .. | .. |
|---|
| 18 | 18 | int rc = 0; |
|---|
| 19 | 19 | char *word; |
|---|
| 20 | 20 | |
|---|
| 21 | | - if (!card) |
|---|
| 22 | | - return -EINVAL; |
|---|
| 23 | | - |
|---|
| 24 | | - if (qeth_l2_vnicc_is_in_use(card)) |
|---|
| 21 | + if (!qeth_bridgeport_allowed(card)) |
|---|
| 25 | 22 | return sprintf(buf, "n/a (VNIC characteristics)\n"); |
|---|
| 26 | 23 | |
|---|
| 24 | + mutex_lock(&card->sbp_lock); |
|---|
| 27 | 25 | if (qeth_card_hw_is_reachable(card) && |
|---|
| 28 | 26 | card->options.sbp.supported_funcs) |
|---|
| 29 | 27 | rc = qeth_bridgeport_query_ports(card, |
|---|
| .. | .. |
|---|
| 57 | 55 | else |
|---|
| 58 | 56 | rc = sprintf(buf, "%s\n", word); |
|---|
| 59 | 57 | } |
|---|
| 58 | + mutex_unlock(&card->sbp_lock); |
|---|
| 60 | 59 | |
|---|
| 61 | 60 | return rc; |
|---|
| 62 | 61 | } |
|---|
| .. | .. |
|---|
| 66 | 65 | { |
|---|
| 67 | 66 | struct qeth_card *card = dev_get_drvdata(dev); |
|---|
| 68 | 67 | |
|---|
| 69 | | - if (qeth_l2_vnicc_is_in_use(card)) |
|---|
| 68 | + if (!qeth_bridgeport_allowed(card)) |
|---|
| 70 | 69 | return sprintf(buf, "n/a (VNIC characteristics)\n"); |
|---|
| 71 | 70 | |
|---|
| 72 | 71 | return qeth_bridge_port_role_state_show(dev, attr, buf, 0); |
|---|
| .. | .. |
|---|
| 79 | 78 | int rc = 0; |
|---|
| 80 | 79 | enum qeth_sbp_roles role; |
|---|
| 81 | 80 | |
|---|
| 82 | | - if (!card) |
|---|
| 83 | | - return -EINVAL; |
|---|
| 84 | 81 | if (sysfs_streq(buf, "primary")) |
|---|
| 85 | 82 | role = QETH_SBP_ROLE_PRIMARY; |
|---|
| 86 | 83 | else if (sysfs_streq(buf, "secondary")) |
|---|
| .. | .. |
|---|
| 91 | 88 | return -EINVAL; |
|---|
| 92 | 89 | |
|---|
| 93 | 90 | mutex_lock(&card->conf_mutex); |
|---|
| 91 | + mutex_lock(&card->sbp_lock); |
|---|
| 94 | 92 | |
|---|
| 95 | | - if (qeth_l2_vnicc_is_in_use(card)) |
|---|
| 93 | + if (!qeth_bridgeport_allowed(card)) |
|---|
| 96 | 94 | rc = -EBUSY; |
|---|
| 97 | 95 | else if (card->options.sbp.reflect_promisc) |
|---|
| 98 | 96 | /* Forbid direct manipulation */ |
|---|
| .. | .. |
|---|
| 104 | 102 | } else |
|---|
| 105 | 103 | card->options.sbp.role = role; |
|---|
| 106 | 104 | |
|---|
| 105 | + mutex_unlock(&card->sbp_lock); |
|---|
| 107 | 106 | mutex_unlock(&card->conf_mutex); |
|---|
| 108 | 107 | |
|---|
| 109 | 108 | return rc ? rc : count; |
|---|
| .. | .. |
|---|
| 117 | 116 | { |
|---|
| 118 | 117 | struct qeth_card *card = dev_get_drvdata(dev); |
|---|
| 119 | 118 | |
|---|
| 120 | | - if (qeth_l2_vnicc_is_in_use(card)) |
|---|
| 119 | + if (!qeth_bridgeport_allowed(card)) |
|---|
| 121 | 120 | return sprintf(buf, "n/a (VNIC characteristics)\n"); |
|---|
| 122 | 121 | |
|---|
| 123 | 122 | return qeth_bridge_port_role_state_show(dev, attr, buf, 1); |
|---|
| .. | .. |
|---|
| 132 | 131 | struct qeth_card *card = dev_get_drvdata(dev); |
|---|
| 133 | 132 | int enabled; |
|---|
| 134 | 133 | |
|---|
| 135 | | - if (!card) |
|---|
| 136 | | - return -EINVAL; |
|---|
| 137 | | - |
|---|
| 138 | | - if (qeth_l2_vnicc_is_in_use(card)) |
|---|
| 134 | + if (!qeth_bridgeport_allowed(card)) |
|---|
| 139 | 135 | return sprintf(buf, "n/a (VNIC characteristics)\n"); |
|---|
| 140 | 136 | |
|---|
| 141 | 137 | enabled = card->options.sbp.hostnotification; |
|---|
| .. | .. |
|---|
| 150 | 146 | bool enable; |
|---|
| 151 | 147 | int rc; |
|---|
| 152 | 148 | |
|---|
| 153 | | - if (!card) |
|---|
| 154 | | - return -EINVAL; |
|---|
| 155 | | - |
|---|
| 156 | 149 | rc = kstrtobool(buf, &enable); |
|---|
| 157 | 150 | if (rc) |
|---|
| 158 | 151 | return rc; |
|---|
| 159 | 152 | |
|---|
| 160 | 153 | mutex_lock(&card->conf_mutex); |
|---|
| 154 | + mutex_lock(&card->sbp_lock); |
|---|
| 161 | 155 | |
|---|
| 162 | | - if (qeth_l2_vnicc_is_in_use(card)) |
|---|
| 156 | + if (!qeth_bridgeport_allowed(card)) |
|---|
| 163 | 157 | rc = -EBUSY; |
|---|
| 164 | 158 | else if (qeth_card_hw_is_reachable(card)) { |
|---|
| 165 | 159 | rc = qeth_bridgeport_an_set(card, enable); |
|---|
| 160 | + /* sbp_lock ensures ordering vs notifications-stopped events */ |
|---|
| 166 | 161 | if (!rc) |
|---|
| 167 | 162 | card->options.sbp.hostnotification = enable; |
|---|
| 168 | 163 | } else |
|---|
| 169 | 164 | card->options.sbp.hostnotification = enable; |
|---|
| 170 | 165 | |
|---|
| 166 | + mutex_unlock(&card->sbp_lock); |
|---|
| 171 | 167 | mutex_unlock(&card->conf_mutex); |
|---|
| 172 | 168 | |
|---|
| 173 | 169 | return rc ? rc : count; |
|---|
| .. | .. |
|---|
| 183 | 179 | struct qeth_card *card = dev_get_drvdata(dev); |
|---|
| 184 | 180 | char *state; |
|---|
| 185 | 181 | |
|---|
| 186 | | - if (!card) |
|---|
| 187 | | - return -EINVAL; |
|---|
| 188 | | - |
|---|
| 189 | | - if (qeth_l2_vnicc_is_in_use(card)) |
|---|
| 182 | + if (!qeth_bridgeport_allowed(card)) |
|---|
| 190 | 183 | return sprintf(buf, "n/a (VNIC characteristics)\n"); |
|---|
| 191 | 184 | |
|---|
| 192 | 185 | if (card->options.sbp.reflect_promisc) { |
|---|
| .. | .. |
|---|
| 207 | 200 | int enable, primary; |
|---|
| 208 | 201 | int rc = 0; |
|---|
| 209 | 202 | |
|---|
| 210 | | - if (!card) |
|---|
| 211 | | - return -EINVAL; |
|---|
| 212 | | - |
|---|
| 213 | 203 | if (sysfs_streq(buf, "none")) { |
|---|
| 214 | 204 | enable = 0; |
|---|
| 215 | 205 | primary = 0; |
|---|
| .. | .. |
|---|
| 223 | 213 | return -EINVAL; |
|---|
| 224 | 214 | |
|---|
| 225 | 215 | mutex_lock(&card->conf_mutex); |
|---|
| 216 | + mutex_lock(&card->sbp_lock); |
|---|
| 226 | 217 | |
|---|
| 227 | | - if (qeth_l2_vnicc_is_in_use(card)) |
|---|
| 218 | + if (!qeth_bridgeport_allowed(card)) |
|---|
| 228 | 219 | rc = -EBUSY; |
|---|
| 229 | 220 | else if (card->options.sbp.role != QETH_SBP_ROLE_NONE) |
|---|
| 230 | 221 | rc = -EPERM; |
|---|
| .. | .. |
|---|
| 234 | 225 | rc = 0; |
|---|
| 235 | 226 | } |
|---|
| 236 | 227 | |
|---|
| 228 | + mutex_unlock(&card->sbp_lock); |
|---|
| 237 | 229 | mutex_unlock(&card->conf_mutex); |
|---|
| 238 | 230 | |
|---|
| 239 | 231 | return rc ? rc : count; |
|---|
| .. | .. |
|---|
| 254 | 246 | static struct attribute_group qeth_l2_bridgeport_attr_group = { |
|---|
| 255 | 247 | .attrs = qeth_l2_bridgeport_attrs, |
|---|
| 256 | 248 | }; |
|---|
| 257 | | - |
|---|
| 258 | | -/** |
|---|
| 259 | | - * qeth_l2_setup_bridgeport_attrs() - set/restore attrs when turning online. |
|---|
| 260 | | - * @card: qeth_card structure pointer |
|---|
| 261 | | - * |
|---|
| 262 | | - * Note: this function is called with conf_mutex held by the caller |
|---|
| 263 | | - */ |
|---|
| 264 | | -void qeth_l2_setup_bridgeport_attrs(struct qeth_card *card) |
|---|
| 265 | | -{ |
|---|
| 266 | | - int rc; |
|---|
| 267 | | - |
|---|
| 268 | | - if (!card) |
|---|
| 269 | | - return; |
|---|
| 270 | | - if (!card->options.sbp.supported_funcs) |
|---|
| 271 | | - return; |
|---|
| 272 | | - if (card->options.sbp.role != QETH_SBP_ROLE_NONE) { |
|---|
| 273 | | - /* Conditional to avoid spurious error messages */ |
|---|
| 274 | | - qeth_bridgeport_setrole(card, card->options.sbp.role); |
|---|
| 275 | | - /* Let the callback function refresh the stored role value. */ |
|---|
| 276 | | - qeth_bridgeport_query_ports(card, |
|---|
| 277 | | - &card->options.sbp.role, NULL); |
|---|
| 278 | | - } |
|---|
| 279 | | - if (card->options.sbp.hostnotification) { |
|---|
| 280 | | - rc = qeth_bridgeport_an_set(card, 1); |
|---|
| 281 | | - if (rc) |
|---|
| 282 | | - card->options.sbp.hostnotification = 0; |
|---|
| 283 | | - } else |
|---|
| 284 | | - qeth_bridgeport_an_set(card, 0); |
|---|
| 285 | | -} |
|---|
| 286 | 249 | |
|---|
| 287 | 250 | /* VNIC CHARS support */ |
|---|
| 288 | 251 | |
|---|
| .. | .. |
|---|
| 315 | 278 | u32 timeout; |
|---|
| 316 | 279 | int rc; |
|---|
| 317 | 280 | |
|---|
| 318 | | - if (!card) |
|---|
| 319 | | - return -EINVAL; |
|---|
| 320 | | - |
|---|
| 321 | 281 | rc = qeth_l2_vnicc_get_timeout(card, &timeout); |
|---|
| 322 | 282 | if (rc == -EBUSY) |
|---|
| 323 | 283 | return sprintf(buf, "n/a (BridgePort)\n"); |
|---|
| .. | .. |
|---|
| 334 | 294 | struct qeth_card *card = dev_get_drvdata(dev); |
|---|
| 335 | 295 | u32 timeout; |
|---|
| 336 | 296 | int rc; |
|---|
| 337 | | - |
|---|
| 338 | | - if (!card) |
|---|
| 339 | | - return -EINVAL; |
|---|
| 340 | 297 | |
|---|
| 341 | 298 | rc = kstrtou32(buf, 10, &timeout); |
|---|
| 342 | 299 | if (rc) |
|---|
| .. | .. |
|---|
| 357 | 314 | u32 vnicc; |
|---|
| 358 | 315 | int rc; |
|---|
| 359 | 316 | |
|---|
| 360 | | - if (!card) |
|---|
| 361 | | - return -EINVAL; |
|---|
| 362 | | - |
|---|
| 363 | 317 | vnicc = qeth_l2_vnicc_sysfs_attr_to_char(attr->attr.name); |
|---|
| 364 | 318 | rc = qeth_l2_vnicc_get_state(card, vnicc, &state); |
|---|
| 365 | 319 | |
|---|
| .. | .. |
|---|
| 379 | 333 | bool state; |
|---|
| 380 | 334 | u32 vnicc; |
|---|
| 381 | 335 | int rc; |
|---|
| 382 | | - |
|---|
| 383 | | - if (!card) |
|---|
| 384 | | - return -EINVAL; |
|---|
| 385 | 336 | |
|---|
| 386 | 337 | if (kstrtobool(buf, &state)) |
|---|
| 387 | 338 | return -EINVAL; |
|---|