@@ -1601,16 +1601,11 @@ nfp_net_tx_ring_set_prepare(struct nfp_net *nn, struct nfp_net_ring_set *s)
1601
1601
static void
1602
1602
nfp_net_tx_ring_set_swap (struct nfp_net * nn , struct nfp_net_ring_set * s )
1603
1603
{
1604
- struct nfp_net_tx_ring * rings = s -> rings ;
1605
1604
struct nfp_net_ring_set new = * s ;
1606
- unsigned int r ;
1607
1605
1608
1606
s -> dcnt = nn -> txd_cnt ;
1609
1607
s -> rings = nn -> tx_rings ;
1610
1608
1611
- for (r = 0 ; r < nn -> num_tx_rings ; r ++ )
1612
- nn -> tx_rings [r ].r_vec -> tx_ring = & rings [r ];
1613
-
1614
1609
nn -> txd_cnt = new .dcnt ;
1615
1610
nn -> tx_rings = new .rings ;
1616
1611
}
@@ -1728,17 +1723,12 @@ nfp_net_rx_ring_set_prepare(struct nfp_net *nn, struct nfp_net_ring_set *s)
1728
1723
static void
1729
1724
nfp_net_rx_ring_set_swap (struct nfp_net * nn , struct nfp_net_ring_set * s )
1730
1725
{
1731
- struct nfp_net_rx_ring * rings = s -> rings ;
1732
1726
struct nfp_net_ring_set new = * s ;
1733
- unsigned int r ;
1734
1727
1735
1728
s -> mtu = nn -> netdev -> mtu ;
1736
1729
s -> dcnt = nn -> rxd_cnt ;
1737
1730
s -> rings = nn -> rx_rings ;
1738
1731
1739
- for (r = 0 ; r < nn -> num_rx_rings ; r ++ )
1740
- nn -> rx_rings [r ].r_vec -> rx_ring = & rings [r ];
1741
-
1742
1732
nn -> netdev -> mtu = new .mtu ;
1743
1733
nn -> fl_bufsz = nfp_net_calc_fl_bufsz (nn , new .mtu );
1744
1734
nn -> rxd_cnt = new .dcnt ;
@@ -1759,27 +1749,21 @@ nfp_net_rx_ring_set_free(struct nfp_net *nn, struct nfp_net_ring_set *s)
1759
1749
kfree (rings );
1760
1750
}
1761
1751
1752
+ static void
1753
+ nfp_net_vector_assign_rings (struct nfp_net * nn , struct nfp_net_r_vector * r_vec ,
1754
+ int idx )
1755
+ {
1756
+ r_vec -> rx_ring = idx < nn -> num_rx_rings ? & nn -> rx_rings [idx ] : NULL ;
1757
+ r_vec -> tx_ring = idx < nn -> num_tx_rings ? & nn -> tx_rings [idx ] : NULL ;
1758
+ }
1759
+
1762
1760
static int
1763
1761
nfp_net_prepare_vector (struct nfp_net * nn , struct nfp_net_r_vector * r_vec ,
1764
1762
int idx )
1765
1763
{
1766
1764
struct msix_entry * entry = & nn -> irq_entries [r_vec -> irq_idx ];
1767
1765
int err ;
1768
1766
1769
- if (idx < nn -> num_tx_rings ) {
1770
- r_vec -> tx_ring = & nn -> tx_rings [idx ];
1771
- nfp_net_tx_ring_init (r_vec -> tx_ring , r_vec , idx );
1772
- } else {
1773
- r_vec -> tx_ring = NULL ;
1774
- }
1775
-
1776
- if (idx < nn -> num_rx_rings ) {
1777
- r_vec -> rx_ring = & nn -> rx_rings [idx ];
1778
- nfp_net_rx_ring_init (r_vec -> rx_ring , r_vec , idx );
1779
- } else {
1780
- r_vec -> rx_ring = NULL ;
1781
- }
1782
-
1783
1767
snprintf (r_vec -> name , sizeof (r_vec -> name ),
1784
1768
"%s-rxtx-%d" , nn -> netdev -> name , idx );
1785
1769
err = request_irq (entry -> vector , r_vec -> handler , 0 , r_vec -> name , r_vec );
@@ -2100,6 +2084,9 @@ static int nfp_net_netdev_open(struct net_device *netdev)
2100
2084
goto err_free_rx_rings ;
2101
2085
}
2102
2086
2087
+ for (r = 0 ; r < nn -> max_r_vecs ; r ++ )
2088
+ nfp_net_vector_assign_rings (nn , & nn -> r_vecs [r ], r );
2089
+
2103
2090
err = netif_set_real_num_tx_queues (netdev , nn -> num_tx_rings );
2104
2091
if (err )
2105
2092
goto err_free_rings ;
@@ -2247,11 +2234,16 @@ nfp_net_ring_swap_enable(struct nfp_net *nn,
2247
2234
struct nfp_net_ring_set * rx ,
2248
2235
struct nfp_net_ring_set * tx )
2249
2236
{
2237
+ unsigned int r ;
2238
+
2250
2239
if (rx )
2251
2240
nfp_net_rx_ring_set_swap (nn , rx );
2252
2241
if (tx )
2253
2242
nfp_net_tx_ring_set_swap (nn , tx );
2254
2243
2244
+ for (r = 0 ; r < nn -> max_r_vecs ; r ++ )
2245
+ nfp_net_vector_assign_rings (nn , & nn -> r_vecs [r ], r );
2246
+
2255
2247
return __nfp_net_set_config_and_enable (nn );
2256
2248
}
2257
2249
0 commit comments