@@ -326,8 +326,8 @@ static void bnxt_re_stop_irq(void *handle)
326
326
rdev = en_info -> rdev ;
327
327
rcfw = & rdev -> rcfw ;
328
328
329
- for (indx = BNXT_RE_NQ_IDX ; indx < rdev -> num_msix ; indx ++ ) {
330
- nq = & rdev -> nq [indx - 1 ];
329
+ for (indx = BNXT_RE_NQ_IDX ; indx < rdev -> nqr -> num_msix ; indx ++ ) {
330
+ nq = & rdev -> nqr -> nq [indx - 1 ];
331
331
bnxt_qplib_nq_stop_irq (nq , false);
332
332
}
333
333
@@ -362,7 +362,7 @@ static void bnxt_re_start_irq(void *handle, struct bnxt_msix_entry *ent)
362
362
/* Vectors may change after restart, so update with new vectors
363
363
* in device sctructure.
364
364
*/
365
- for (indx = 0 ; indx < rdev -> num_msix ; indx ++ )
365
+ for (indx = 0 ; indx < rdev -> nqr -> num_msix ; indx ++ )
366
366
rdev -> en_dev -> msix_entries [indx ].vector = ent [indx ].vector ;
367
367
368
368
rc = bnxt_qplib_rcfw_start_irq (rcfw , msix_ent [BNXT_RE_AEQ_IDX ].vector ,
@@ -371,8 +371,8 @@ static void bnxt_re_start_irq(void *handle, struct bnxt_msix_entry *ent)
371
371
ibdev_warn (& rdev -> ibdev , "Failed to reinit CREQ\n" );
372
372
return ;
373
373
}
374
- for (indx = BNXT_RE_NQ_IDX ; indx < rdev -> num_msix ; indx ++ ) {
375
- nq = & rdev -> nq [indx - 1 ];
374
+ for (indx = BNXT_RE_NQ_IDX ; indx < rdev -> nqr -> num_msix ; indx ++ ) {
375
+ nq = & rdev -> nqr -> nq [indx - 1 ];
376
376
rc = bnxt_qplib_nq_start_irq (nq , indx - 1 ,
377
377
msix_ent [indx ].vector , false);
378
378
if (rc ) {
@@ -1206,7 +1206,7 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev)
1206
1206
1207
1207
addrconf_addr_eui48 ((u8 * )& ibdev -> node_guid , rdev -> netdev -> dev_addr );
1208
1208
1209
- ibdev -> num_comp_vectors = rdev -> num_msix - 1 ;
1209
+ ibdev -> num_comp_vectors = rdev -> nqr -> num_msix - 1 ;
1210
1210
ibdev -> dev .parent = & rdev -> en_dev -> pdev -> dev ;
1211
1211
ibdev -> local_dma_lkey = BNXT_QPLIB_RSVD_LKEY ;
1212
1212
@@ -1551,8 +1551,8 @@ static void bnxt_re_cleanup_res(struct bnxt_re_dev *rdev)
1551
1551
{
1552
1552
int i ;
1553
1553
1554
- for (i = 1 ; i < rdev -> num_msix ; i ++ )
1555
- bnxt_qplib_disable_nq (& rdev -> nq [i - 1 ]);
1554
+ for (i = 1 ; i < rdev -> nqr -> num_msix ; i ++ )
1555
+ bnxt_qplib_disable_nq (& rdev -> nqr -> nq [i - 1 ]);
1556
1556
1557
1557
if (rdev -> qplib_res .rcfw )
1558
1558
bnxt_qplib_cleanup_res (& rdev -> qplib_res );
@@ -1566,9 +1566,9 @@ static int bnxt_re_init_res(struct bnxt_re_dev *rdev)
1566
1566
1567
1567
bnxt_qplib_init_res (& rdev -> qplib_res );
1568
1568
1569
- for (i = 1 ; i < rdev -> num_msix ; i ++ ) {
1569
+ for (i = 1 ; i < rdev -> nqr -> num_msix ; i ++ ) {
1570
1570
db_offt = rdev -> en_dev -> msix_entries [i ].db_offset ;
1571
- rc = bnxt_qplib_enable_nq (rdev -> en_dev -> pdev , & rdev -> nq [i - 1 ],
1571
+ rc = bnxt_qplib_enable_nq (rdev -> en_dev -> pdev , & rdev -> nqr -> nq [i - 1 ],
1572
1572
i - 1 , rdev -> en_dev -> msix_entries [i ].vector ,
1573
1573
db_offt , & bnxt_re_cqn_handler ,
1574
1574
& bnxt_re_srqn_handler );
@@ -1582,20 +1582,22 @@ static int bnxt_re_init_res(struct bnxt_re_dev *rdev)
1582
1582
return 0 ;
1583
1583
fail :
1584
1584
for (i = num_vec_enabled ; i >= 0 ; i -- )
1585
- bnxt_qplib_disable_nq (& rdev -> nq [i ]);
1585
+ bnxt_qplib_disable_nq (& rdev -> nqr -> nq [i ]);
1586
1586
return rc ;
1587
1587
}
1588
1588
1589
1589
static void bnxt_re_free_nq_res (struct bnxt_re_dev * rdev )
1590
1590
{
1591
+ struct bnxt_qplib_nq * nq ;
1591
1592
u8 type ;
1592
1593
int i ;
1593
1594
1594
- for (i = 0 ; i < rdev -> num_msix - 1 ; i ++ ) {
1595
+ for (i = 0 ; i < rdev -> nqr -> num_msix - 1 ; i ++ ) {
1595
1596
type = bnxt_qplib_get_ring_type (rdev -> chip_ctx );
1596
- bnxt_re_net_ring_free (rdev , rdev -> nq [i ].ring_id , type );
1597
- bnxt_qplib_free_nq (& rdev -> nq [i ]);
1598
- rdev -> nq [i ].res = NULL ;
1597
+ nq = & rdev -> nqr -> nq [i ];
1598
+ bnxt_re_net_ring_free (rdev , nq -> ring_id , type );
1599
+ bnxt_qplib_free_nq (nq );
1600
+ nq -> res = NULL ;
1599
1601
}
1600
1602
}
1601
1603
@@ -1637,20 +1639,20 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
1637
1639
if (rc )
1638
1640
goto dealloc_res ;
1639
1641
1640
- for (i = 0 ; i < rdev -> num_msix - 1 ; i ++ ) {
1642
+ for (i = 0 ; i < rdev -> nqr -> num_msix - 1 ; i ++ ) {
1641
1643
struct bnxt_qplib_nq * nq ;
1642
1644
1643
- nq = & rdev -> nq [i ];
1645
+ nq = & rdev -> nqr -> nq [i ];
1644
1646
nq -> hwq .max_elements = BNXT_QPLIB_NQE_MAX_CNT ;
1645
- rc = bnxt_qplib_alloc_nq (& rdev -> qplib_res , & rdev -> nq [ i ] );
1647
+ rc = bnxt_qplib_alloc_nq (& rdev -> qplib_res , nq );
1646
1648
if (rc ) {
1647
1649
ibdev_err (& rdev -> ibdev , "Alloc Failed NQ%d rc:%#x" ,
1648
1650
i , rc );
1649
1651
goto free_nq ;
1650
1652
}
1651
1653
type = bnxt_qplib_get_ring_type (rdev -> chip_ctx );
1652
1654
rattr .dma_arr = nq -> hwq .pbl [PBL_LVL_0 ].pg_map_arr ;
1653
- rattr .pages = nq -> hwq .pbl [rdev -> nq [i ].hwq .level ].pg_count ;
1655
+ rattr .pages = nq -> hwq .pbl [rdev -> nqr -> nq [i ].hwq .level ].pg_count ;
1654
1656
rattr .type = type ;
1655
1657
rattr .mode = RING_ALLOC_REQ_INT_MODE_MSIX ;
1656
1658
rattr .depth = BNXT_QPLIB_NQE_MAX_CNT - 1 ;
@@ -1660,7 +1662,7 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
1660
1662
ibdev_err (& rdev -> ibdev ,
1661
1663
"Failed to allocate NQ fw id with rc = 0x%x" ,
1662
1664
rc );
1663
- bnxt_qplib_free_nq (& rdev -> nq [ i ] );
1665
+ bnxt_qplib_free_nq (nq );
1664
1666
goto free_nq ;
1665
1667
}
1666
1668
num_vec_created ++ ;
@@ -1669,8 +1671,8 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
1669
1671
free_nq :
1670
1672
for (i = num_vec_created - 1 ; i >= 0 ; i -- ) {
1671
1673
type = bnxt_qplib_get_ring_type (rdev -> chip_ctx );
1672
- bnxt_re_net_ring_free (rdev , rdev -> nq [i ].ring_id , type );
1673
- bnxt_qplib_free_nq (& rdev -> nq [i ]);
1674
+ bnxt_re_net_ring_free (rdev , rdev -> nqr -> nq [i ].ring_id , type );
1675
+ bnxt_qplib_free_nq (& rdev -> nqr -> nq [i ]);
1674
1676
}
1675
1677
bnxt_qplib_dealloc_dpi (& rdev -> qplib_res ,
1676
1678
& rdev -> dpi_privileged );
@@ -1865,6 +1867,21 @@ static int bnxt_re_ib_init(struct bnxt_re_dev *rdev)
1865
1867
return rc ;
1866
1868
}
1867
1869
1870
+ static int bnxt_re_alloc_nqr_mem (struct bnxt_re_dev * rdev )
1871
+ {
1872
+ rdev -> nqr = kzalloc (sizeof (* rdev -> nqr ), GFP_KERNEL );
1873
+ if (!rdev -> nqr )
1874
+ return - ENOMEM ;
1875
+
1876
+ return 0 ;
1877
+ }
1878
+
1879
+ static void bnxt_re_free_nqr_mem (struct bnxt_re_dev * rdev )
1880
+ {
1881
+ kfree (rdev -> nqr );
1882
+ rdev -> nqr = NULL ;
1883
+ }
1884
+
1868
1885
static void bnxt_re_dev_uninit (struct bnxt_re_dev * rdev , u8 op_type )
1869
1886
{
1870
1887
u8 type ;
@@ -1894,11 +1911,12 @@ static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev, u8 op_type)
1894
1911
bnxt_qplib_free_rcfw_channel (& rdev -> rcfw );
1895
1912
}
1896
1913
1897
- rdev -> num_msix = 0 ;
1914
+ rdev -> nqr -> num_msix = 0 ;
1898
1915
1899
1916
if (rdev -> pacing .dbr_pacing )
1900
1917
bnxt_re_deinitialize_dbr_pacing (rdev );
1901
1918
1919
+ bnxt_re_free_nqr_mem (rdev );
1902
1920
bnxt_re_destroy_chip_ctx (rdev );
1903
1921
if (op_type == BNXT_RE_COMPLETE_REMOVE ) {
1904
1922
if (test_and_clear_bit (BNXT_RE_FLAG_NETDEV_REGISTERED , & rdev -> flags ))
@@ -1946,7 +1964,6 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)
1946
1964
}
1947
1965
ibdev_dbg (& rdev -> ibdev , "Got %d MSI-X vectors\n" ,
1948
1966
rdev -> en_dev -> ulp_tbl -> msix_requested );
1949
- rdev -> num_msix = rdev -> en_dev -> ulp_tbl -> msix_requested ;
1950
1967
1951
1968
rc = bnxt_re_setup_chip_ctx (rdev );
1952
1969
if (rc ) {
@@ -1956,6 +1973,15 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)
1956
1973
return - EINVAL ;
1957
1974
}
1958
1975
1976
+ rc = bnxt_re_alloc_nqr_mem (rdev );
1977
+ if (rc ) {
1978
+ bnxt_re_destroy_chip_ctx (rdev );
1979
+ bnxt_unregister_dev (rdev -> en_dev );
1980
+ clear_bit (BNXT_RE_FLAG_NETDEV_REGISTERED , & rdev -> flags );
1981
+ return rc ;
1982
+ }
1983
+ rdev -> nqr -> num_msix = rdev -> en_dev -> ulp_tbl -> msix_requested ;
1984
+
1959
1985
/* Check whether VF or PF */
1960
1986
bnxt_re_get_sriov_func_type (rdev );
1961
1987
0 commit comments