aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulian Wiedmann <jwi@linux.ibm.com>2019-02-28 12:59:36 -0500
committerDavid S. Miller <davem@davemloft.net>2019-02-28 15:55:25 -0500
commitd7d543f252994387571462096ec646f5f335c4ee (patch)
tree47827bd3fefce9e8f79b330f63018a1a16112021
parent54903572c23c3ecda6bbfde350b104f31bdb3f58 (diff)
s390/qeth: remove RECOVER state
The offline code uses a specific RECOVER state to indicate that the interface should be brought up when a qeth device is set online again. Rather than having a specific card-state for this, just put it in an internal flag bit and set the state to DOWN. When working with the card's state transitions, this reduces the complexity quite a bit. Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/s390/net/qeth_core.h2
-rw-r--r--drivers/s390/net/qeth_core_main.c6
-rw-r--r--drivers/s390/net/qeth_core_sys.c14
-rw-r--r--drivers/s390/net/qeth_l2_main.c19
-rw-r--r--drivers/s390/net/qeth_l3_main.c19
-rw-r--r--drivers/s390/net/qeth_l3_sys.c12
6 files changed, 25 insertions, 47 deletions
diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h
index c0c46be0b251..79de890010c7 100644
--- a/drivers/s390/net/qeth_core.h
+++ b/drivers/s390/net/qeth_core.h
@@ -553,7 +553,6 @@ enum qeth_card_states {
553 CARD_STATE_HARDSETUP, 553 CARD_STATE_HARDSETUP,
554 CARD_STATE_SOFTSETUP, 554 CARD_STATE_SOFTSETUP,
555 CARD_STATE_UP, 555 CARD_STATE_UP,
556 CARD_STATE_RECOVER,
557}; 556};
558 557
559/** 558/**
@@ -665,6 +664,7 @@ struct qeth_card_info {
665 unsigned short chpid; 664 unsigned short chpid;
666 __u16 func_level; 665 __u16 func_level;
667 char mcl_level[QETH_MCL_LENGTH + 1]; 666 char mcl_level[QETH_MCL_LENGTH + 1];
667 u8 open_when_online:1;
668 int guestlan; 668 int guestlan;
669 int mac_bits; 669 int mac_bits;
670 enum qeth_card_types type; 670 enum qeth_card_types type;
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 4708df39f129..a69e31e9bdf1 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -265,8 +265,7 @@ int qeth_realloc_buffer_pool(struct qeth_card *card, int bufcnt)
265{ 265{
266 QETH_CARD_TEXT(card, 2, "realcbp"); 266 QETH_CARD_TEXT(card, 2, "realcbp");
267 267
268 if ((card->state != CARD_STATE_DOWN) && 268 if (card->state != CARD_STATE_DOWN)
269 (card->state != CARD_STATE_RECOVER))
270 return -EPERM; 269 return -EPERM;
271 270
272 /* TODO: steel/add buffers from/to a running card's buffer pool (?) */ 271 /* TODO: steel/add buffers from/to a running card's buffer pool (?) */
@@ -3479,8 +3478,7 @@ int qeth_configure_cq(struct qeth_card *card, enum qeth_cq cq)
3479 goto out; 3478 goto out;
3480 } 3479 }
3481 3480
3482 if (card->state != CARD_STATE_DOWN && 3481 if (card->state != CARD_STATE_DOWN) {
3483 card->state != CARD_STATE_RECOVER) {
3484 rc = -1; 3482 rc = -1;
3485 goto out; 3483 goto out;
3486 } 3484 }
diff --git a/drivers/s390/net/qeth_core_sys.c b/drivers/s390/net/qeth_core_sys.c
index 8b223cc2c19b..e24d204b780a 100644
--- a/drivers/s390/net/qeth_core_sys.c
+++ b/drivers/s390/net/qeth_core_sys.c
@@ -34,8 +34,6 @@ static ssize_t qeth_dev_state_show(struct device *dev,
34 return sprintf(buf, "UP (LAN %s)\n", 34 return sprintf(buf, "UP (LAN %s)\n",
35 netif_carrier_ok(card->dev) ? "ONLINE" : 35 netif_carrier_ok(card->dev) ? "ONLINE" :
36 "OFFLINE"); 36 "OFFLINE");
37 case CARD_STATE_RECOVER:
38 return sprintf(buf, "RECOVER\n");
39 default: 37 default:
40 return sprintf(buf, "UNKNOWN\n"); 38 return sprintf(buf, "UNKNOWN\n");
41 } 39 }
@@ -126,8 +124,7 @@ static ssize_t qeth_dev_portno_store(struct device *dev,
126 return -EINVAL; 124 return -EINVAL;
127 125
128 mutex_lock(&card->conf_mutex); 126 mutex_lock(&card->conf_mutex);
129 if ((card->state != CARD_STATE_DOWN) && 127 if (card->state != CARD_STATE_DOWN) {
130 (card->state != CARD_STATE_RECOVER)) {
131 rc = -EPERM; 128 rc = -EPERM;
132 goto out; 129 goto out;
133 } 130 }
@@ -202,8 +199,7 @@ static ssize_t qeth_dev_prioqing_store(struct device *dev,
202 return -EINVAL; 199 return -EINVAL;
203 200
204 mutex_lock(&card->conf_mutex); 201 mutex_lock(&card->conf_mutex);
205 if ((card->state != CARD_STATE_DOWN) && 202 if (card->state != CARD_STATE_DOWN) {
206 (card->state != CARD_STATE_RECOVER)) {
207 rc = -EPERM; 203 rc = -EPERM;
208 goto out; 204 goto out;
209 } 205 }
@@ -285,8 +281,7 @@ static ssize_t qeth_dev_bufcnt_store(struct device *dev,
285 return -EINVAL; 281 return -EINVAL;
286 282
287 mutex_lock(&card->conf_mutex); 283 mutex_lock(&card->conf_mutex);
288 if ((card->state != CARD_STATE_DOWN) && 284 if (card->state != CARD_STATE_DOWN) {
289 (card->state != CARD_STATE_RECOVER)) {
290 rc = -EPERM; 285 rc = -EPERM;
291 goto out; 286 goto out;
292 } 287 }
@@ -634,8 +629,7 @@ static ssize_t qeth_dev_blkt_store(struct qeth_card *card,
634 return -EINVAL; 629 return -EINVAL;
635 630
636 mutex_lock(&card->conf_mutex); 631 mutex_lock(&card->conf_mutex);
637 if ((card->state != CARD_STATE_DOWN) && 632 if (card->state != CARD_STATE_DOWN) {
638 (card->state != CARD_STATE_RECOVER)) {
639 rc = -EPERM; 633 rc = -EPERM;
640 goto out; 634 goto out;
641 } 635 }
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 2c9714215775..f621656f9ea7 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -807,7 +807,6 @@ static int __qeth_l2_set_online(struct ccwgroup_device *gdev, int recovery_mode)
807 struct qeth_card *card = dev_get_drvdata(&gdev->dev); 807 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
808 struct net_device *dev = card->dev; 808 struct net_device *dev = card->dev;
809 int rc = 0; 809 int rc = 0;
810 enum qeth_card_states recover_flag;
811 bool carrier_ok; 810 bool carrier_ok;
812 811
813 mutex_lock(&card->discipline_mutex); 812 mutex_lock(&card->discipline_mutex);
@@ -815,7 +814,6 @@ static int __qeth_l2_set_online(struct ccwgroup_device *gdev, int recovery_mode)
815 QETH_DBF_TEXT(SETUP, 2, "setonlin"); 814 QETH_DBF_TEXT(SETUP, 2, "setonlin");
816 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); 815 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *));
817 816
818 recover_flag = card->state;
819 rc = qeth_core_hardsetup_card(card, &carrier_ok); 817 rc = qeth_core_hardsetup_card(card, &carrier_ok);
820 if (rc) { 818 if (rc) {
821 QETH_DBF_TEXT_(SETUP, 2, "2err%04x", rc); 819 QETH_DBF_TEXT_(SETUP, 2, "2err%04x", rc);
@@ -881,7 +879,8 @@ static int __qeth_l2_set_online(struct ccwgroup_device *gdev, int recovery_mode)
881 netif_device_attach(dev); 879 netif_device_attach(dev);
882 qeth_enable_hw_features(dev); 880 qeth_enable_hw_features(dev);
883 881
884 if (recover_flag == CARD_STATE_RECOVER) { 882 if (card->info.open_when_online) {
883 card->info.open_when_online = 0;
885 if (recovery_mode && !IS_OSN(card)) { 884 if (recovery_mode && !IS_OSN(card)) {
886 if (!qeth_l2_validate_addr(dev)) { 885 if (!qeth_l2_validate_addr(dev)) {
887 qeth_open(dev); 886 qeth_open(dev);
@@ -905,10 +904,8 @@ out_remove:
905 ccw_device_set_offline(CARD_WDEV(card)); 904 ccw_device_set_offline(CARD_WDEV(card));
906 ccw_device_set_offline(CARD_RDEV(card)); 905 ccw_device_set_offline(CARD_RDEV(card));
907 qdio_free(CARD_DDEV(card)); 906 qdio_free(CARD_DDEV(card));
908 if (recover_flag == CARD_STATE_RECOVER) 907 card->state = CARD_STATE_DOWN;
909 card->state = CARD_STATE_RECOVER; 908
910 else
911 card->state = CARD_STATE_DOWN;
912 mutex_unlock(&card->conf_mutex); 909 mutex_unlock(&card->conf_mutex);
913 mutex_unlock(&card->discipline_mutex); 910 mutex_unlock(&card->discipline_mutex);
914 return rc; 911 return rc;
@@ -924,7 +921,6 @@ static int __qeth_l2_set_offline(struct ccwgroup_device *cgdev,
924{ 921{
925 struct qeth_card *card = dev_get_drvdata(&cgdev->dev); 922 struct qeth_card *card = dev_get_drvdata(&cgdev->dev);
926 int rc = 0, rc2 = 0, rc3 = 0; 923 int rc = 0, rc2 = 0, rc3 = 0;
927 enum qeth_card_states recover_flag;
928 924
929 mutex_lock(&card->discipline_mutex); 925 mutex_lock(&card->discipline_mutex);
930 mutex_lock(&card->conf_mutex); 926 mutex_lock(&card->conf_mutex);
@@ -932,11 +928,11 @@ static int __qeth_l2_set_offline(struct ccwgroup_device *cgdev,
932 QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *)); 928 QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *));
933 929
934 rtnl_lock(); 930 rtnl_lock();
931 card->info.open_when_online = card->dev->flags & IFF_UP;
935 netif_device_detach(card->dev); 932 netif_device_detach(card->dev);
936 netif_carrier_off(card->dev); 933 netif_carrier_off(card->dev);
937 rtnl_unlock(); 934 rtnl_unlock();
938 935
939 recover_flag = card->state;
940 if ((!recovery_mode && card->info.hwtrap) || card->info.hwtrap == 2) { 936 if ((!recovery_mode && card->info.hwtrap) || card->info.hwtrap == 2) {
941 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); 937 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
942 card->info.hwtrap = 1; 938 card->info.hwtrap = 1;
@@ -950,8 +946,7 @@ static int __qeth_l2_set_offline(struct ccwgroup_device *cgdev,
950 if (rc) 946 if (rc)
951 QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc); 947 QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc);
952 qdio_free(CARD_DDEV(card)); 948 qdio_free(CARD_DDEV(card));
953 if (recover_flag == CARD_STATE_UP) 949
954 card->state = CARD_STATE_RECOVER;
955 /* let user_space know that device is offline */ 950 /* let user_space know that device is offline */
956 kobject_uevent(&cgdev->dev.kobj, KOBJ_CHANGE); 951 kobject_uevent(&cgdev->dev.kobj, KOBJ_CHANGE);
957 mutex_unlock(&card->conf_mutex); 952 mutex_unlock(&card->conf_mutex);
@@ -1024,7 +1019,7 @@ static int qeth_l2_pm_resume(struct ccwgroup_device *gdev)
1024 struct qeth_card *card = dev_get_drvdata(&gdev->dev); 1019 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
1025 int rc = 0; 1020 int rc = 0;
1026 1021
1027 if (card->state == CARD_STATE_RECOVER) { 1022 if (card->info.open_when_online) {
1028 rc = __qeth_l2_set_online(card->gdev, 1); 1023 rc = __qeth_l2_set_online(card->gdev, 1);
1029 if (rc) { 1024 if (rc) {
1030 rtnl_lock(); 1025 rtnl_lock();
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 07c3149e228c..fe6b9a82f69e 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -2304,7 +2304,6 @@ static int __qeth_l3_set_online(struct ccwgroup_device *gdev, int recovery_mode)
2304 struct qeth_card *card = dev_get_drvdata(&gdev->dev); 2304 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
2305 struct net_device *dev = card->dev; 2305 struct net_device *dev = card->dev;
2306 int rc = 0; 2306 int rc = 0;
2307 enum qeth_card_states recover_flag;
2308 bool carrier_ok; 2307 bool carrier_ok;
2309 2308
2310 mutex_lock(&card->discipline_mutex); 2309 mutex_lock(&card->discipline_mutex);
@@ -2312,7 +2311,6 @@ static int __qeth_l3_set_online(struct ccwgroup_device *gdev, int recovery_mode)
2312 QETH_DBF_TEXT(SETUP, 2, "setonlin"); 2311 QETH_DBF_TEXT(SETUP, 2, "setonlin");
2313 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); 2312 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *));
2314 2313
2315 recover_flag = card->state;
2316 rc = qeth_core_hardsetup_card(card, &carrier_ok); 2314 rc = qeth_core_hardsetup_card(card, &carrier_ok);
2317 if (rc) { 2315 if (rc) {
2318 QETH_DBF_TEXT_(SETUP, 2, "2err%04x", rc); 2316 QETH_DBF_TEXT_(SETUP, 2, "2err%04x", rc);
@@ -2375,7 +2373,8 @@ static int __qeth_l3_set_online(struct ccwgroup_device *gdev, int recovery_mode)
2375 netif_device_attach(dev); 2373 netif_device_attach(dev);
2376 qeth_enable_hw_features(dev); 2374 qeth_enable_hw_features(dev);
2377 2375
2378 if (recover_flag == CARD_STATE_RECOVER) { 2376 if (card->info.open_when_online) {
2377 card->info.open_when_online = 0;
2379 if (recovery_mode) { 2378 if (recovery_mode) {
2380 qeth_open(dev); 2379 qeth_open(dev);
2381 qeth_l3_set_rx_mode(dev); 2380 qeth_l3_set_rx_mode(dev);
@@ -2397,10 +2396,8 @@ out_remove:
2397 ccw_device_set_offline(CARD_WDEV(card)); 2396 ccw_device_set_offline(CARD_WDEV(card));
2398 ccw_device_set_offline(CARD_RDEV(card)); 2397 ccw_device_set_offline(CARD_RDEV(card));
2399 qdio_free(CARD_DDEV(card)); 2398 qdio_free(CARD_DDEV(card));
2400 if (recover_flag == CARD_STATE_RECOVER) 2399 card->state = CARD_STATE_DOWN;
2401 card->state = CARD_STATE_RECOVER; 2400
2402 else
2403 card->state = CARD_STATE_DOWN;
2404 mutex_unlock(&card->conf_mutex); 2401 mutex_unlock(&card->conf_mutex);
2405 mutex_unlock(&card->discipline_mutex); 2402 mutex_unlock(&card->discipline_mutex);
2406 return rc; 2403 return rc;
@@ -2416,7 +2413,6 @@ static int __qeth_l3_set_offline(struct ccwgroup_device *cgdev,
2416{ 2413{
2417 struct qeth_card *card = dev_get_drvdata(&cgdev->dev); 2414 struct qeth_card *card = dev_get_drvdata(&cgdev->dev);
2418 int rc = 0, rc2 = 0, rc3 = 0; 2415 int rc = 0, rc2 = 0, rc3 = 0;
2419 enum qeth_card_states recover_flag;
2420 2416
2421 mutex_lock(&card->discipline_mutex); 2417 mutex_lock(&card->discipline_mutex);
2422 mutex_lock(&card->conf_mutex); 2418 mutex_lock(&card->conf_mutex);
@@ -2424,11 +2420,11 @@ static int __qeth_l3_set_offline(struct ccwgroup_device *cgdev,
2424 QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *)); 2420 QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *));
2425 2421
2426 rtnl_lock(); 2422 rtnl_lock();
2423 card->info.open_when_online = card->dev->flags & IFF_UP;
2427 netif_device_detach(card->dev); 2424 netif_device_detach(card->dev);
2428 netif_carrier_off(card->dev); 2425 netif_carrier_off(card->dev);
2429 rtnl_unlock(); 2426 rtnl_unlock();
2430 2427
2431 recover_flag = card->state;
2432 if ((!recovery_mode && card->info.hwtrap) || card->info.hwtrap == 2) { 2428 if ((!recovery_mode && card->info.hwtrap) || card->info.hwtrap == 2) {
2433 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); 2429 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
2434 card->info.hwtrap = 1; 2430 card->info.hwtrap = 1;
@@ -2447,8 +2443,7 @@ static int __qeth_l3_set_offline(struct ccwgroup_device *cgdev,
2447 if (rc) 2443 if (rc)
2448 QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc); 2444 QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc);
2449 qdio_free(CARD_DDEV(card)); 2445 qdio_free(CARD_DDEV(card));
2450 if (recover_flag == CARD_STATE_UP) 2446
2451 card->state = CARD_STATE_RECOVER;
2452 /* let user_space know that device is offline */ 2447 /* let user_space know that device is offline */
2453 kobject_uevent(&cgdev->dev.kobj, KOBJ_CHANGE); 2448 kobject_uevent(&cgdev->dev.kobj, KOBJ_CHANGE);
2454 mutex_unlock(&card->conf_mutex); 2449 mutex_unlock(&card->conf_mutex);
@@ -2511,7 +2506,7 @@ static int qeth_l3_pm_resume(struct ccwgroup_device *gdev)
2511 struct qeth_card *card = dev_get_drvdata(&gdev->dev); 2506 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
2512 int rc = 0; 2507 int rc = 0;
2513 2508
2514 if (card->state == CARD_STATE_RECOVER) { 2509 if (card->info.open_when_online) {
2515 rc = __qeth_l3_set_online(card->gdev, 1); 2510 rc = __qeth_l3_set_online(card->gdev, 1);
2516 if (rc) { 2511 if (rc) {
2517 rtnl_lock(); 2512 rtnl_lock();
diff --git a/drivers/s390/net/qeth_l3_sys.c b/drivers/s390/net/qeth_l3_sys.c
index 45ac6d8705c6..cff518b0f904 100644
--- a/drivers/s390/net/qeth_l3_sys.c
+++ b/drivers/s390/net/qeth_l3_sys.c
@@ -167,8 +167,7 @@ static ssize_t qeth_l3_dev_fake_broadcast_store(struct device *dev,
167 return -EINVAL; 167 return -EINVAL;
168 168
169 mutex_lock(&card->conf_mutex); 169 mutex_lock(&card->conf_mutex);
170 if ((card->state != CARD_STATE_DOWN) && 170 if (card->state != CARD_STATE_DOWN) {
171 (card->state != CARD_STATE_RECOVER)) {
172 rc = -EPERM; 171 rc = -EPERM;
173 goto out; 172 goto out;
174 } 173 }
@@ -213,8 +212,7 @@ static ssize_t qeth_l3_dev_sniffer_store(struct device *dev,
213 return -EPERM; 212 return -EPERM;
214 213
215 mutex_lock(&card->conf_mutex); 214 mutex_lock(&card->conf_mutex);
216 if ((card->state != CARD_STATE_DOWN) && 215 if (card->state != CARD_STATE_DOWN) {
217 (card->state != CARD_STATE_RECOVER)) {
218 rc = -EPERM; 216 rc = -EPERM;
219 goto out; 217 goto out;
220 } 218 }
@@ -280,8 +278,7 @@ static ssize_t qeth_l3_dev_hsuid_store(struct device *dev,
280 278
281 if (card->info.type != QETH_CARD_TYPE_IQD) 279 if (card->info.type != QETH_CARD_TYPE_IQD)
282 return -EPERM; 280 return -EPERM;
283 if (card->state != CARD_STATE_DOWN && 281 if (card->state != CARD_STATE_DOWN)
284 card->state != CARD_STATE_RECOVER)
285 return -EPERM; 282 return -EPERM;
286 if (card->options.sniffer) 283 if (card->options.sniffer)
287 return -EPERM; 284 return -EPERM;
@@ -356,8 +353,7 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
356 return -EINVAL; 353 return -EINVAL;
357 354
358 mutex_lock(&card->conf_mutex); 355 mutex_lock(&card->conf_mutex);
359 if ((card->state != CARD_STATE_DOWN) && 356 if (card->state != CARD_STATE_DOWN) {
360 (card->state != CARD_STATE_RECOVER)) {
361 rc = -EPERM; 357 rc = -EPERM;
362 goto out; 358 goto out;
363 } 359 }