@@ -21,6 +21,9 @@ static void ionic_lif_rx_mode(struct ionic_lif *lif, unsigned int rx_mode);
21
21
static int ionic_lif_addr_add (struct ionic_lif * lif , const u8 * addr );
22
22
static int ionic_lif_addr_del (struct ionic_lif * lif , const u8 * addr );
23
23
static void ionic_link_status_check (struct ionic_lif * lif );
24
+ static void ionic_lif_handle_fw_down (struct ionic_lif * lif );
25
+ static void ionic_lif_handle_fw_up (struct ionic_lif * lif );
26
+ static void ionic_lif_set_netdev_info (struct ionic_lif * lif );
24
27
25
28
static int ionic_start_queues (struct ionic_lif * lif );
26
29
static void ionic_stop_queues (struct ionic_lif * lif );
@@ -53,6 +56,12 @@ static void ionic_lif_deferred_work(struct work_struct *work)
53
56
case IONIC_DW_TYPE_LINK_STATUS :
54
57
ionic_link_status_check (lif );
55
58
break ;
59
+ case IONIC_DW_TYPE_LIF_RESET :
60
+ if (w -> fw_status )
61
+ ionic_lif_handle_fw_up (lif );
62
+ else
63
+ ionic_lif_handle_fw_down (lif );
64
+ break ;
56
65
default :
57
66
break ;
58
67
}
@@ -61,8 +70,8 @@ static void ionic_lif_deferred_work(struct work_struct *work)
61
70
}
62
71
}
63
72
64
- static void ionic_lif_deferred_enqueue (struct ionic_deferred * def ,
65
- struct ionic_deferred_work * work )
73
+ void ionic_lif_deferred_enqueue (struct ionic_deferred * def ,
74
+ struct ionic_deferred_work * work )
66
75
{
67
76
spin_lock_bh (& def -> lock );
68
77
list_add_tail (& work -> list , & def -> list );
@@ -682,6 +691,7 @@ static bool ionic_notifyq_service(struct ionic_cq *cq,
682
691
struct ionic_cq_info * cq_info )
683
692
{
684
693
union ionic_notifyq_comp * comp = cq_info -> cq_desc ;
694
+ struct ionic_deferred_work * work ;
685
695
struct net_device * netdev ;
686
696
struct ionic_queue * q ;
687
697
struct ionic_lif * lif ;
@@ -707,11 +717,13 @@ static bool ionic_notifyq_service(struct ionic_cq *cq,
707
717
ionic_link_status_check_request (lif );
708
718
break ;
709
719
case IONIC_EVENT_RESET :
710
- netdev_info (netdev , "Notifyq IONIC_EVENT_RESET eid=%lld\n" ,
711
- eid );
712
- netdev_info (netdev , " reset_code=%d state=%d\n" ,
713
- comp -> reset .reset_code ,
714
- comp -> reset .state );
720
+ work = kzalloc (sizeof (* work ), GFP_ATOMIC );
721
+ if (!work ) {
722
+ netdev_err (lif -> netdev , "%s OOM\n" , __func__ );
723
+ } else {
724
+ work -> type = IONIC_DW_TYPE_LIF_RESET ;
725
+ ionic_lif_deferred_enqueue (& lif -> deferred , work );
726
+ }
715
727
break ;
716
728
default :
717
729
netdev_warn (netdev , "Notifyq unknown event ecode=%d eid=%lld\n" ,
@@ -1224,7 +1236,8 @@ static int ionic_init_nic_features(struct ionic_lif *lif)
1224
1236
netdev -> hw_features |= netdev -> hw_enc_features ;
1225
1237
netdev -> features |= netdev -> hw_features ;
1226
1238
1227
- netdev -> priv_flags |= IFF_UNICAST_FLT ;
1239
+ netdev -> priv_flags |= IFF_UNICAST_FLT |
1240
+ IFF_LIVE_ADDR_CHANGE ;
1228
1241
1229
1242
return 0 ;
1230
1243
}
@@ -1669,6 +1682,9 @@ int ionic_stop(struct net_device *netdev)
1669
1682
{
1670
1683
struct ionic_lif * lif = netdev_priv (netdev );
1671
1684
1685
+ if (test_bit (IONIC_LIF_F_FW_RESET , lif -> state ))
1686
+ return 0 ;
1687
+
1672
1688
ionic_stop_queues (lif );
1673
1689
ionic_txrx_deinit (lif );
1674
1690
ionic_txrx_free (lif );
@@ -2064,6 +2080,80 @@ static void ionic_lif_reset(struct ionic_lif *lif)
2064
2080
mutex_unlock (& lif -> ionic -> dev_cmd_lock );
2065
2081
}
2066
2082
2083
+ static void ionic_lif_handle_fw_down (struct ionic_lif * lif )
2084
+ {
2085
+ struct ionic * ionic = lif -> ionic ;
2086
+
2087
+ if (test_and_set_bit (IONIC_LIF_F_FW_RESET , lif -> state ))
2088
+ return ;
2089
+
2090
+ dev_info (ionic -> dev , "FW Down: Stopping LIFs\n" );
2091
+
2092
+ netif_device_detach (lif -> netdev );
2093
+
2094
+ if (test_bit (IONIC_LIF_F_UP , lif -> state )) {
2095
+ dev_info (ionic -> dev , "Surprise FW stop, stopping queues\n" );
2096
+ ionic_stop_queues (lif );
2097
+ }
2098
+
2099
+ if (netif_running (lif -> netdev )) {
2100
+ ionic_txrx_deinit (lif );
2101
+ ionic_txrx_free (lif );
2102
+ }
2103
+ ionic_lifs_deinit (ionic );
2104
+ ionic_qcqs_free (lif );
2105
+
2106
+ dev_info (ionic -> dev , "FW Down: LIFs stopped\n" );
2107
+ }
2108
+
2109
+ static void ionic_lif_handle_fw_up (struct ionic_lif * lif )
2110
+ {
2111
+ struct ionic * ionic = lif -> ionic ;
2112
+ int err ;
2113
+
2114
+ if (!test_bit (IONIC_LIF_F_FW_RESET , lif -> state ))
2115
+ return ;
2116
+
2117
+ dev_info (ionic -> dev , "FW Up: restarting LIFs\n" );
2118
+
2119
+ err = ionic_qcqs_alloc (lif );
2120
+ if (err )
2121
+ goto err_out ;
2122
+
2123
+ err = ionic_lifs_init (ionic );
2124
+ if (err )
2125
+ goto err_qcqs_free ;
2126
+
2127
+ if (lif -> registered )
2128
+ ionic_lif_set_netdev_info (lif );
2129
+
2130
+ if (netif_running (lif -> netdev )) {
2131
+ err = ionic_txrx_alloc (lif );
2132
+ if (err )
2133
+ goto err_lifs_deinit ;
2134
+
2135
+ err = ionic_txrx_init (lif );
2136
+ if (err )
2137
+ goto err_txrx_free ;
2138
+ }
2139
+
2140
+ clear_bit (IONIC_LIF_F_FW_RESET , lif -> state );
2141
+ ionic_link_status_check_request (lif );
2142
+ netif_device_attach (lif -> netdev );
2143
+ dev_info (ionic -> dev , "FW Up: LIFs restarted\n" );
2144
+
2145
+ return ;
2146
+
2147
+ err_txrx_free :
2148
+ ionic_txrx_free (lif );
2149
+ err_lifs_deinit :
2150
+ ionic_lifs_deinit (ionic );
2151
+ err_qcqs_free :
2152
+ ionic_qcqs_free (lif );
2153
+ err_out :
2154
+ dev_err (ionic -> dev , "FW Up: LIFs restart failed - err %d\n" , err );
2155
+ }
2156
+
2067
2157
static void ionic_lif_free (struct ionic_lif * lif )
2068
2158
{
2069
2159
struct device * dev = lif -> ionic -> dev ;
@@ -2076,7 +2166,8 @@ static void ionic_lif_free(struct ionic_lif *lif)
2076
2166
2077
2167
/* free queues */
2078
2168
ionic_qcqs_free (lif );
2079
- ionic_lif_reset (lif );
2169
+ if (!test_bit (IONIC_LIF_F_FW_RESET , lif -> state ))
2170
+ ionic_lif_reset (lif );
2080
2171
2081
2172
/* free lif info */
2082
2173
dma_free_coherent (dev , lif -> info_sz , lif -> info , lif -> info_pa );
@@ -2109,17 +2200,19 @@ void ionic_lifs_free(struct ionic *ionic)
2109
2200
2110
2201
static void ionic_lif_deinit (struct ionic_lif * lif )
2111
2202
{
2112
- if (!test_bit (IONIC_LIF_F_INITED , lif -> state ))
2203
+ if (!test_and_clear_bit (IONIC_LIF_F_INITED , lif -> state ))
2113
2204
return ;
2114
2205
2115
- clear_bit (IONIC_LIF_F_INITED , lif -> state );
2206
+ if (!test_bit (IONIC_LIF_F_FW_RESET , lif -> state )) {
2207
+ cancel_work_sync (& lif -> deferred .work );
2208
+ cancel_work_sync (& lif -> tx_timeout_work );
2209
+ }
2116
2210
2117
2211
ionic_rx_filters_deinit (lif );
2118
2212
if (lif -> netdev -> features & NETIF_F_RXHASH )
2119
2213
ionic_lif_rss_deinit (lif );
2120
2214
2121
2215
napi_disable (& lif -> adminqcq -> napi );
2122
- netif_napi_del (& lif -> adminqcq -> napi );
2123
2216
ionic_lif_qcq_deinit (lif , lif -> notifyqcq );
2124
2217
ionic_lif_qcq_deinit (lif , lif -> adminqcq );
2125
2218
@@ -2213,6 +2306,7 @@ static int ionic_lif_notifyq_init(struct ionic_lif *lif)
2213
2306
if (err )
2214
2307
return err ;
2215
2308
2309
+ lif -> last_eid = 0 ;
2216
2310
q -> hw_type = ctx .comp .q_init .hw_type ;
2217
2311
q -> hw_index = le32_to_cpu (ctx .comp .q_init .hw_index );
2218
2312
q -> dbval = IONIC_DBELL_QID (q -> hw_index );
@@ -2253,8 +2347,8 @@ static int ionic_station_set(struct ionic_lif *lif)
2253
2347
addr .sa_family = AF_INET ;
2254
2348
err = eth_prepare_mac_addr_change (netdev , & addr );
2255
2349
if (err ) {
2256
- netdev_warn (lif -> netdev , "ignoring bad MAC addr from NIC %pM\n" ,
2257
- addr .sa_data );
2350
+ netdev_warn (lif -> netdev , "ignoring bad MAC addr from NIC %pM - err %d \n" ,
2351
+ addr .sa_data , err );
2258
2352
return 0 ;
2259
2353
}
2260
2354
@@ -2464,12 +2558,8 @@ void ionic_lifs_unregister(struct ionic *ionic)
2464
2558
* current model, so don't bother searching the
2465
2559
* ionic->lif for candidates to unregister
2466
2560
*/
2467
- if (!ionic -> master_lif )
2468
- return ;
2469
-
2470
- cancel_work_sync (& ionic -> master_lif -> deferred .work );
2471
- cancel_work_sync (& ionic -> master_lif -> tx_timeout_work );
2472
- if (ionic -> master_lif -> netdev -> reg_state == NETREG_REGISTERED )
2561
+ if (ionic -> master_lif &&
2562
+ ionic -> master_lif -> netdev -> reg_state == NETREG_REGISTERED )
2473
2563
unregister_netdev (ionic -> master_lif -> netdev );
2474
2564
}
2475
2565
0 commit comments