@@ -1116,16 +1116,17 @@ static void fbnic_free_napi_vector(struct fbnic_net *fbn,
1116
1116
fbnic_free_irq (fbd , v_idx , nv );
1117
1117
page_pool_destroy (nv -> page_pool );
1118
1118
netif_napi_del (& nv -> napi );
1119
- list_del ( & nv -> napis ) ;
1119
+ fbn -> napi [ fbnic_napi_idx ( nv )] = NULL ;
1120
1120
kfree (nv );
1121
1121
}
1122
1122
1123
1123
void fbnic_free_napi_vectors (struct fbnic_net * fbn )
1124
1124
{
1125
- struct fbnic_napi_vector * nv , * temp ;
1125
+ int i ;
1126
1126
1127
- list_for_each_entry_safe (nv , temp , & fbn -> napis , napis )
1128
- fbnic_free_napi_vector (fbn , nv );
1127
+ for (i = 0 ; i < fbn -> num_napi ; i ++ )
1128
+ if (fbn -> napi [i ])
1129
+ fbnic_free_napi_vector (fbn , fbn -> napi [i ]);
1129
1130
}
1130
1131
1131
1132
static void fbnic_name_napi_vector (struct fbnic_napi_vector * nv )
@@ -1222,7 +1223,7 @@ static int fbnic_alloc_napi_vector(struct fbnic_dev *fbd, struct fbnic_net *fbn,
1222
1223
nv -> v_idx = v_idx ;
1223
1224
1224
1225
/* Tie napi to netdev */
1225
- list_add ( & nv -> napis , & fbn -> napis ) ;
1226
+ fbn -> napi [ fbnic_napi_idx ( nv )] = nv ;
1226
1227
netif_napi_add (fbn -> netdev , & nv -> napi , fbnic_poll );
1227
1228
1228
1229
/* Record IRQ to NAPI struct */
@@ -1307,7 +1308,7 @@ static int fbnic_alloc_napi_vector(struct fbnic_dev *fbd, struct fbnic_net *fbn,
1307
1308
page_pool_destroy (nv -> page_pool );
1308
1309
napi_del :
1309
1310
netif_napi_del (& nv -> napi );
1310
- list_del ( & nv -> napis ) ;
1311
+ fbn -> napi [ fbnic_napi_idx ( nv )] = NULL ;
1311
1312
kfree (nv );
1312
1313
return err ;
1313
1314
}
@@ -1612,28 +1613,27 @@ static int fbnic_alloc_nv_resources(struct fbnic_net *fbn,
1612
1613
1613
1614
void fbnic_free_resources (struct fbnic_net * fbn )
1614
1615
{
1615
- struct fbnic_napi_vector * nv ;
1616
+ int i ;
1616
1617
1617
- list_for_each_entry ( nv , & fbn -> napis , napis )
1618
- fbnic_free_nv_resources (fbn , nv );
1618
+ for ( i = 0 ; i < fbn -> num_napi ; i ++ )
1619
+ fbnic_free_nv_resources (fbn , fbn -> napi [ i ] );
1619
1620
}
1620
1621
1621
1622
int fbnic_alloc_resources (struct fbnic_net * fbn )
1622
1623
{
1623
- struct fbnic_napi_vector * nv ;
1624
- int err = - ENODEV ;
1624
+ int i , err = - ENODEV ;
1625
1625
1626
- list_for_each_entry ( nv , & fbn -> napis , napis ) {
1627
- err = fbnic_alloc_nv_resources (fbn , nv );
1626
+ for ( i = 0 ; i < fbn -> num_napi ; i ++ ) {
1627
+ err = fbnic_alloc_nv_resources (fbn , fbn -> napi [ i ] );
1628
1628
if (err )
1629
1629
goto free_resources ;
1630
1630
}
1631
1631
1632
1632
return 0 ;
1633
1633
1634
1634
free_resources :
1635
- list_for_each_entry_continue_reverse ( nv , & fbn -> napis , napis )
1636
- fbnic_free_nv_resources (fbn , nv );
1635
+ while ( i -- )
1636
+ fbnic_free_nv_resources (fbn , fbn -> napi [ i ] );
1637
1637
1638
1638
return err ;
1639
1639
}
@@ -1670,33 +1670,34 @@ static void fbnic_disable_rcq(struct fbnic_ring *rxr)
1670
1670
1671
1671
void fbnic_napi_disable (struct fbnic_net * fbn )
1672
1672
{
1673
- struct fbnic_napi_vector * nv ;
1673
+ int i ;
1674
1674
1675
- list_for_each_entry ( nv , & fbn -> napis , napis ) {
1676
- napi_disable (& nv -> napi );
1675
+ for ( i = 0 ; i < fbn -> num_napi ; i ++ ) {
1676
+ napi_disable (& fbn -> napi [ i ] -> napi );
1677
1677
1678
- fbnic_nv_irq_disable (nv );
1678
+ fbnic_nv_irq_disable (fbn -> napi [ i ] );
1679
1679
}
1680
1680
}
1681
1681
1682
1682
void fbnic_disable (struct fbnic_net * fbn )
1683
1683
{
1684
1684
struct fbnic_dev * fbd = fbn -> fbd ;
1685
- struct fbnic_napi_vector * nv ;
1686
- int i , j ;
1685
+ int i , j , t ;
1686
+
1687
+ for (i = 0 ; i < fbn -> num_napi ; i ++ ) {
1688
+ struct fbnic_napi_vector * nv = fbn -> napi [i ];
1687
1689
1688
- list_for_each_entry (nv , & fbn -> napis , napis ) {
1689
1690
/* Disable Tx queue triads */
1690
- for (i = 0 ; i < nv -> txt_count ; i ++ ) {
1691
- struct fbnic_q_triad * qt = & nv -> qt [i ];
1691
+ for (t = 0 ; t < nv -> txt_count ; t ++ ) {
1692
+ struct fbnic_q_triad * qt = & nv -> qt [t ];
1692
1693
1693
1694
fbnic_disable_twq0 (& qt -> sub0 );
1694
1695
fbnic_disable_tcq (& qt -> cmpl );
1695
1696
}
1696
1697
1697
1698
/* Disable Rx queue triads */
1698
- for (j = 0 ; j < nv -> rxt_count ; j ++ , i ++ ) {
1699
- struct fbnic_q_triad * qt = & nv -> qt [i ];
1699
+ for (j = 0 ; j < nv -> rxt_count ; j ++ , t ++ ) {
1700
+ struct fbnic_q_triad * qt = & nv -> qt [t ];
1700
1701
1701
1702
fbnic_disable_bdq (& qt -> sub0 , & qt -> sub1 );
1702
1703
fbnic_disable_rcq (& qt -> cmpl );
@@ -1792,14 +1793,15 @@ int fbnic_wait_all_queues_idle(struct fbnic_dev *fbd, bool may_fail)
1792
1793
1793
1794
void fbnic_flush (struct fbnic_net * fbn )
1794
1795
{
1795
- struct fbnic_napi_vector * nv ;
1796
+ int i ;
1796
1797
1797
- list_for_each_entry (nv , & fbn -> napis , napis ) {
1798
- int i , j ;
1798
+ for (i = 0 ; i < fbn -> num_napi ; i ++ ) {
1799
+ struct fbnic_napi_vector * nv = fbn -> napi [i ];
1800
+ int j , t ;
1799
1801
1800
1802
/* Flush any processed Tx Queue Triads and drop the rest */
1801
- for (i = 0 ; i < nv -> txt_count ; i ++ ) {
1802
- struct fbnic_q_triad * qt = & nv -> qt [i ];
1803
+ for (t = 0 ; t < nv -> txt_count ; t ++ ) {
1804
+ struct fbnic_q_triad * qt = & nv -> qt [t ];
1803
1805
struct netdev_queue * tx_queue ;
1804
1806
1805
1807
/* Clean the work queues of unprocessed work */
@@ -1823,8 +1825,8 @@ void fbnic_flush(struct fbnic_net *fbn)
1823
1825
}
1824
1826
1825
1827
/* Flush any processed Rx Queue Triads and drop the rest */
1826
- for (j = 0 ; j < nv -> rxt_count ; j ++ , i ++ ) {
1827
- struct fbnic_q_triad * qt = & nv -> qt [i ];
1828
+ for (j = 0 ; j < nv -> rxt_count ; j ++ , t ++ ) {
1829
+ struct fbnic_q_triad * qt = & nv -> qt [t ];
1828
1830
1829
1831
/* Clean the work queues of unprocessed work */
1830
1832
fbnic_clean_bdq (nv , 0 , & qt -> sub0 , qt -> sub0 .tail );
@@ -1845,14 +1847,15 @@ void fbnic_flush(struct fbnic_net *fbn)
1845
1847
1846
1848
void fbnic_fill (struct fbnic_net * fbn )
1847
1849
{
1848
- struct fbnic_napi_vector * nv ;
1850
+ int i ;
1849
1851
1850
- list_for_each_entry (nv , & fbn -> napis , napis ) {
1851
- int i , j ;
1852
+ for (i = 0 ; i < fbn -> num_napi ; i ++ ) {
1853
+ struct fbnic_napi_vector * nv = fbn -> napi [i ];
1854
+ int j , t ;
1852
1855
1853
1856
/* Configure NAPI mapping for Tx */
1854
- for (i = 0 ; i < nv -> txt_count ; i ++ ) {
1855
- struct fbnic_q_triad * qt = & nv -> qt [i ];
1857
+ for (t = 0 ; t < nv -> txt_count ; t ++ ) {
1858
+ struct fbnic_q_triad * qt = & nv -> qt [t ];
1856
1859
1857
1860
/* Nothing to do if Tx queue is disabled */
1858
1861
if (qt -> sub0 .flags & FBNIC_RING_F_DISABLED )
@@ -1866,8 +1869,8 @@ void fbnic_fill(struct fbnic_net *fbn)
1866
1869
/* Configure NAPI mapping and populate pages
1867
1870
* in the BDQ rings to use for Rx
1868
1871
*/
1869
- for (j = 0 ; j < nv -> rxt_count ; j ++ , i ++ ) {
1870
- struct fbnic_q_triad * qt = & nv -> qt [i ];
1872
+ for (j = 0 ; j < nv -> rxt_count ; j ++ , t ++ ) {
1873
+ struct fbnic_q_triad * qt = & nv -> qt [t ];
1871
1874
1872
1875
/* Associate Rx queue with NAPI */
1873
1876
netif_queue_set_napi (nv -> napi .dev , qt -> cmpl .q_idx ,
@@ -2025,21 +2028,23 @@ static void fbnic_enable_rcq(struct fbnic_napi_vector *nv,
2025
2028
void fbnic_enable (struct fbnic_net * fbn )
2026
2029
{
2027
2030
struct fbnic_dev * fbd = fbn -> fbd ;
2028
- struct fbnic_napi_vector * nv ;
2029
- int i , j ;
2031
+ int i ;
2032
+
2033
+ for (i = 0 ; i < fbn -> num_napi ; i ++ ) {
2034
+ struct fbnic_napi_vector * nv = fbn -> napi [i ];
2035
+ int j , t ;
2030
2036
2031
- list_for_each_entry (nv , & fbn -> napis , napis ) {
2032
2037
/* Setup Tx Queue Triads */
2033
- for (i = 0 ; i < nv -> txt_count ; i ++ ) {
2034
- struct fbnic_q_triad * qt = & nv -> qt [i ];
2038
+ for (t = 0 ; t < nv -> txt_count ; t ++ ) {
2039
+ struct fbnic_q_triad * qt = & nv -> qt [t ];
2035
2040
2036
2041
fbnic_enable_twq0 (& qt -> sub0 );
2037
2042
fbnic_enable_tcq (nv , & qt -> cmpl );
2038
2043
}
2039
2044
2040
2045
/* Setup Rx Queue Triads */
2041
- for (j = 0 ; j < nv -> rxt_count ; j ++ , i ++ ) {
2042
- struct fbnic_q_triad * qt = & nv -> qt [i ];
2046
+ for (j = 0 ; j < nv -> rxt_count ; j ++ , t ++ ) {
2047
+ struct fbnic_q_triad * qt = & nv -> qt [t ];
2043
2048
2044
2049
fbnic_enable_bdq (& qt -> sub0 , & qt -> sub1 );
2045
2050
fbnic_config_drop_mode_rcq (nv , & qt -> cmpl );
@@ -2064,10 +2069,11 @@ void fbnic_napi_enable(struct fbnic_net *fbn)
2064
2069
{
2065
2070
u32 irqs [FBNIC_MAX_MSIX_VECS / 32 ] = {};
2066
2071
struct fbnic_dev * fbd = fbn -> fbd ;
2067
- struct fbnic_napi_vector * nv ;
2068
2072
int i ;
2069
2073
2070
- list_for_each_entry (nv , & fbn -> napis , napis ) {
2074
+ for (i = 0 ; i < fbn -> num_napi ; i ++ ) {
2075
+ struct fbnic_napi_vector * nv = fbn -> napi [i ];
2076
+
2071
2077
napi_enable (& nv -> napi );
2072
2078
2073
2079
fbnic_nv_irq_enable (nv );
@@ -2096,17 +2102,18 @@ void fbnic_napi_depletion_check(struct net_device *netdev)
2096
2102
struct fbnic_net * fbn = netdev_priv (netdev );
2097
2103
u32 irqs [FBNIC_MAX_MSIX_VECS / 32 ] = {};
2098
2104
struct fbnic_dev * fbd = fbn -> fbd ;
2099
- struct fbnic_napi_vector * nv ;
2100
- int i , j ;
2105
+ int i , j , t ;
2106
+
2107
+ for (i = 0 ; i < fbn -> num_napi ; i ++ ) {
2108
+ struct fbnic_napi_vector * nv = fbn -> napi [i ];
2101
2109
2102
- list_for_each_entry (nv , & fbn -> napis , napis ) {
2103
2110
/* Find RQs which are completely out of pages */
2104
- for (i = nv -> txt_count , j = 0 ; j < nv -> rxt_count ; j ++ , i ++ ) {
2111
+ for (t = nv -> txt_count , j = 0 ; j < nv -> rxt_count ; j ++ , t ++ ) {
2105
2112
/* Assume 4 pages is always enough to fit a packet
2106
2113
* and therefore generate a completion and an IRQ.
2107
2114
*/
2108
- if (fbnic_desc_used (& nv -> qt [i ].sub0 ) < 4 ||
2109
- fbnic_desc_used (& nv -> qt [i ].sub1 ) < 4 )
2115
+ if (fbnic_desc_used (& nv -> qt [t ].sub0 ) < 4 ||
2116
+ fbnic_desc_used (& nv -> qt [t ].sub1 ) < 4 )
2110
2117
irqs [nv -> v_idx / 32 ] |= BIT (nv -> v_idx % 32 );
2111
2118
}
2112
2119
}
0 commit comments