@@ -83,7 +83,7 @@ static void bnxt_re_dev_stop(struct bnxt_re_dev *rdev);
83
83
static int bnxt_re_netdev_event (struct notifier_block * notifier ,
84
84
unsigned long event , void * ptr );
85
85
static struct bnxt_re_dev * bnxt_re_from_netdev (struct net_device * netdev );
86
- static void bnxt_re_dev_uninit (struct bnxt_re_dev * rdev );
86
+ static void bnxt_re_dev_uninit (struct bnxt_re_dev * rdev , u8 op_type );
87
87
static int bnxt_re_hwrm_qcaps (struct bnxt_re_dev * rdev );
88
88
89
89
static int bnxt_re_hwrm_qcfg (struct bnxt_re_dev * rdev , u32 * db_len ,
@@ -169,6 +169,7 @@ static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev)
169
169
170
170
en_dev = rdev -> en_dev ;
171
171
172
+ rdev -> qplib_res .pdev = en_dev -> pdev ;
172
173
chip_ctx = kzalloc (sizeof (* chip_ctx ), GFP_KERNEL );
173
174
if (!chip_ctx )
174
175
return - ENOMEM ;
@@ -301,7 +302,7 @@ static void bnxt_re_shutdown(struct auxiliary_device *adev)
301
302
302
303
rdev = en_info -> rdev ;
303
304
ib_unregister_device (& rdev -> ibdev );
304
- bnxt_re_dev_uninit (rdev );
305
+ bnxt_re_dev_uninit (rdev , BNXT_RE_COMPLETE_REMOVE );
305
306
}
306
307
307
308
static void bnxt_re_stop_irq (void * handle )
@@ -385,14 +386,9 @@ static struct bnxt_ulp_ops bnxt_re_ulp_ops = {
385
386
static int bnxt_re_register_netdev (struct bnxt_re_dev * rdev )
386
387
{
387
388
struct bnxt_en_dev * en_dev ;
388
- int rc ;
389
389
390
390
en_dev = rdev -> en_dev ;
391
-
392
- rc = bnxt_register_dev (en_dev , & bnxt_re_ulp_ops , rdev -> adev );
393
- if (!rc )
394
- rdev -> qplib_res .pdev = rdev -> en_dev -> pdev ;
395
- return rc ;
391
+ return bnxt_register_dev (en_dev , & bnxt_re_ulp_ops , rdev -> adev );
396
392
}
397
393
398
394
static void bnxt_re_init_hwrm_hdr (struct input * hdr , u16 opcd )
@@ -1593,7 +1589,7 @@ static int bnxt_re_ib_init(struct bnxt_re_dev *rdev)
1593
1589
return rc ;
1594
1590
}
1595
1591
1596
- static void bnxt_re_dev_uninit (struct bnxt_re_dev * rdev )
1592
+ static void bnxt_re_dev_uninit (struct bnxt_re_dev * rdev , u8 op_type )
1597
1593
{
1598
1594
u8 type ;
1599
1595
int rc ;
@@ -1626,8 +1622,10 @@ static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev)
1626
1622
bnxt_re_deinitialize_dbr_pacing (rdev );
1627
1623
1628
1624
bnxt_re_destroy_chip_ctx (rdev );
1629
- if (test_and_clear_bit (BNXT_RE_FLAG_NETDEV_REGISTERED , & rdev -> flags ))
1630
- bnxt_unregister_dev (rdev -> en_dev );
1625
+ if (op_type == BNXT_RE_COMPLETE_REMOVE ) {
1626
+ if (test_and_clear_bit (BNXT_RE_FLAG_NETDEV_REGISTERED , & rdev -> flags ))
1627
+ bnxt_unregister_dev (rdev -> en_dev );
1628
+ }
1631
1629
}
1632
1630
1633
1631
/* worker thread for polling periodic events. Now used for QoS programming*/
@@ -1640,7 +1638,7 @@ static void bnxt_re_worker(struct work_struct *work)
1640
1638
schedule_delayed_work (& rdev -> worker , msecs_to_jiffies (30000 ));
1641
1639
}
1642
1640
1643
- static int bnxt_re_dev_init (struct bnxt_re_dev * rdev )
1641
+ static int bnxt_re_dev_init (struct bnxt_re_dev * rdev , u8 op_type )
1644
1642
{
1645
1643
struct bnxt_re_ring_attr rattr = {};
1646
1644
struct bnxt_qplib_creq_ctx * creq ;
@@ -1649,12 +1647,14 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev)
1649
1647
u8 type ;
1650
1648
int rc ;
1651
1649
1652
- /* Registered a new RoCE device instance to netdev */
1653
- rc = bnxt_re_register_netdev (rdev );
1654
- if (rc ) {
1655
- ibdev_err (& rdev -> ibdev ,
1656
- "Failed to register with netedev: %#x\n" , rc );
1657
- return - EINVAL ;
1650
+ if (op_type == BNXT_RE_COMPLETE_INIT ) {
1651
+ /* Registered a new RoCE device instance to netdev */
1652
+ rc = bnxt_re_register_netdev (rdev );
1653
+ if (rc ) {
1654
+ ibdev_err (& rdev -> ibdev ,
1655
+ "Failed to register with netedev: %#x\n" , rc );
1656
+ return - EINVAL ;
1657
+ }
1658
1658
}
1659
1659
set_bit (BNXT_RE_FLAG_NETDEV_REGISTERED , & rdev -> flags );
1660
1660
@@ -1807,7 +1807,7 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev)
1807
1807
free_rcfw :
1808
1808
bnxt_qplib_free_rcfw_channel (& rdev -> rcfw );
1809
1809
fail :
1810
- bnxt_re_dev_uninit (rdev );
1810
+ bnxt_re_dev_uninit (rdev , BNXT_RE_COMPLETE_REMOVE );
1811
1811
1812
1812
return rc ;
1813
1813
}
@@ -1827,7 +1827,7 @@ static void bnxt_re_update_en_info_rdev(struct bnxt_re_dev *rdev,
1827
1827
rtnl_unlock ();
1828
1828
}
1829
1829
1830
- static int bnxt_re_add_device (struct auxiliary_device * adev )
1830
+ static int bnxt_re_add_device (struct auxiliary_device * adev , u8 op_type )
1831
1831
{
1832
1832
struct bnxt_aux_priv * aux_priv =
1833
1833
container_of (adev , struct bnxt_aux_priv , aux_dev );
@@ -1839,8 +1839,6 @@ static int bnxt_re_add_device(struct auxiliary_device *adev)
1839
1839
en_info = auxiliary_get_drvdata (adev );
1840
1840
en_dev = en_info -> en_dev ;
1841
1841
1842
- /* en_dev should never be NULL as long as adev and aux_dev are valid. */
1843
- en_dev = aux_priv -> edev ;
1844
1842
1845
1843
rdev = bnxt_re_dev_add (aux_priv , en_dev );
1846
1844
if (!rdev || !rdev_to_dev (rdev )) {
@@ -1850,7 +1848,7 @@ static int bnxt_re_add_device(struct auxiliary_device *adev)
1850
1848
1851
1849
bnxt_re_update_en_info_rdev (rdev , en_info , adev );
1852
1850
1853
- rc = bnxt_re_dev_init (rdev );
1851
+ rc = bnxt_re_dev_init (rdev , op_type );
1854
1852
if (rc )
1855
1853
goto re_dev_dealloc ;
1856
1854
@@ -1875,7 +1873,7 @@ static int bnxt_re_add_device(struct auxiliary_device *adev)
1875
1873
1876
1874
re_dev_uninit :
1877
1875
bnxt_re_update_en_info_rdev (NULL , en_info , adev );
1878
- bnxt_re_dev_uninit (rdev );
1876
+ bnxt_re_dev_uninit (rdev , BNXT_RE_COMPLETE_REMOVE );
1879
1877
re_dev_dealloc :
1880
1878
ib_dealloc_device (& rdev -> ibdev );
1881
1879
exit :
@@ -1958,7 +1956,7 @@ static int bnxt_re_netdev_event(struct notifier_block *notifier,
1958
1956
1959
1957
#define BNXT_ADEV_NAME "bnxt_en"
1960
1958
1961
- static void bnxt_re_remove_device (struct bnxt_re_dev * rdev ,
1959
+ static void bnxt_re_remove_device (struct bnxt_re_dev * rdev , u8 op_type ,
1962
1960
struct auxiliary_device * aux_dev )
1963
1961
{
1964
1962
if (rdev -> nb .notifier_call ) {
@@ -1972,7 +1970,7 @@ static void bnxt_re_remove_device(struct bnxt_re_dev *rdev,
1972
1970
}
1973
1971
bnxt_re_setup_cc (rdev , false);
1974
1972
ib_unregister_device (& rdev -> ibdev );
1975
- bnxt_re_dev_uninit (rdev );
1973
+ bnxt_re_dev_uninit (rdev , op_type );
1976
1974
ib_dealloc_device (& rdev -> ibdev );
1977
1975
}
1978
1976
@@ -1991,7 +1989,7 @@ static void bnxt_re_remove(struct auxiliary_device *adev)
1991
1989
rdev = en_info -> rdev ;
1992
1990
1993
1991
if (rdev )
1994
- bnxt_re_remove_device (rdev , adev );
1992
+ bnxt_re_remove_device (rdev , BNXT_RE_COMPLETE_REMOVE , adev );
1995
1993
kfree (en_info );
1996
1994
mutex_unlock (& bnxt_re_mutex );
1997
1995
}
@@ -2017,7 +2015,7 @@ static int bnxt_re_probe(struct auxiliary_device *adev,
2017
2015
2018
2016
auxiliary_set_drvdata (adev , en_info );
2019
2017
2020
- rc = bnxt_re_add_device (adev );
2018
+ rc = bnxt_re_add_device (adev , BNXT_RE_COMPLETE_INIT );
2021
2019
if (rc )
2022
2020
goto err ;
2023
2021
mutex_unlock (& bnxt_re_mutex );
@@ -2033,12 +2031,14 @@ static int bnxt_re_probe(struct auxiliary_device *adev,
2033
2031
static int bnxt_re_suspend (struct auxiliary_device * adev , pm_message_t state )
2034
2032
{
2035
2033
struct bnxt_re_en_dev_info * en_info = auxiliary_get_drvdata (adev );
2034
+ struct bnxt_en_dev * en_dev ;
2036
2035
struct bnxt_re_dev * rdev ;
2037
2036
2038
2037
if (!en_info )
2039
2038
return 0 ;
2040
2039
2041
2040
rdev = en_info -> rdev ;
2041
+ en_dev = en_info -> en_dev ;
2042
2042
mutex_lock (& bnxt_re_mutex );
2043
2043
/* L2 driver may invoke this callback during device error/crash or device
2044
2044
* reset. Current RoCE driver doesn't recover the device in case of
@@ -2057,13 +2057,20 @@ static int bnxt_re_suspend(struct auxiliary_device *adev, pm_message_t state)
2057
2057
set_bit (ERR_DEVICE_DETACHED , & rdev -> rcfw .cmdq .flags );
2058
2058
2059
2059
bnxt_re_dev_stop (rdev );
2060
- bnxt_re_stop_irq (rdev );
2060
+ bnxt_re_stop_irq (adev );
2061
2061
/* Move the device states to detached and avoid sending any more
2062
2062
* commands to HW
2063
2063
*/
2064
2064
set_bit (BNXT_RE_FLAG_ERR_DEVICE_DETACHED , & rdev -> flags );
2065
2065
set_bit (ERR_DEVICE_DETACHED , & rdev -> rcfw .cmdq .flags );
2066
2066
wake_up_all (& rdev -> rcfw .cmdq .waitq );
2067
+
2068
+ if (rdev -> pacing .dbr_pacing )
2069
+ bnxt_re_set_pacing_dev_state (rdev );
2070
+
2071
+ ibdev_info (& rdev -> ibdev , "%s: L2 driver notified to stop en_state 0x%lx" ,
2072
+ __func__ , en_dev -> en_state );
2073
+ bnxt_re_remove_device (rdev , BNXT_RE_PRE_RECOVERY_REMOVE , adev );
2067
2074
mutex_unlock (& bnxt_re_mutex );
2068
2075
2069
2076
return 0 ;
@@ -2077,7 +2084,6 @@ static int bnxt_re_resume(struct auxiliary_device *adev)
2077
2084
if (!en_info )
2078
2085
return 0 ;
2079
2086
2080
- rdev = en_info -> rdev ;
2081
2087
mutex_lock (& bnxt_re_mutex );
2082
2088
/* L2 driver may invoke this callback during device recovery, resume.
2083
2089
* reset. Current RoCE driver doesn't recover the device in case of
@@ -2086,7 +2092,9 @@ static int bnxt_re_resume(struct auxiliary_device *adev)
2086
2092
* L2 driver want to modify the MSIx table.
2087
2093
*/
2088
2094
2089
- ibdev_info (& rdev -> ibdev , "Handle device resume call" );
2095
+ bnxt_re_add_device (adev , BNXT_RE_POST_RECOVERY_INIT );
2096
+ rdev = en_info -> rdev ;
2097
+ ibdev_info (& rdev -> ibdev , "Device resume completed" );
2090
2098
mutex_unlock (& bnxt_re_mutex );
2091
2099
2092
2100
return 0 ;
0 commit comments