49
49
50
50
static int mlx4_en_moderation_update (struct mlx4_en_priv * priv )
51
51
{
52
- int i ;
52
+ int i , t ;
53
53
int err = 0 ;
54
54
55
- for (i = 0 ; i < priv -> tx_ring_num ; i ++ ) {
56
- priv -> tx_cq [i ]-> moder_cnt = priv -> tx_frames ;
57
- priv -> tx_cq [i ]-> moder_time = priv -> tx_usecs ;
58
- if (priv -> port_up ) {
59
- err = mlx4_en_set_cq_moder (priv , priv -> tx_cq [i ]);
60
- if (err )
61
- return err ;
55
+ for (t = 0 ; t < MLX4_EN_NUM_TX_TYPES ; t ++ ) {
56
+ for (i = 0 ; i < priv -> tx_ring_num [t ]; i ++ ) {
57
+ priv -> tx_cq [t ][i ]-> moder_cnt = priv -> tx_frames ;
58
+ priv -> tx_cq [t ][i ]-> moder_time = priv -> tx_usecs ;
59
+ if (priv -> port_up ) {
60
+ err = mlx4_en_set_cq_moder (priv ,
61
+ priv -> tx_cq [t ][i ]);
62
+ if (err )
63
+ return err ;
64
+ }
62
65
}
63
66
}
64
67
@@ -336,7 +339,7 @@ static int mlx4_en_get_sset_count(struct net_device *dev, int sset)
336
339
switch (sset ) {
337
340
case ETH_SS_STATS :
338
341
return bitmap_iterator_count (& it ) +
339
- (priv -> tx_ring_num * 2 ) +
342
+ (priv -> tx_ring_num [ TX ] * 2 ) +
340
343
(priv -> rx_ring_num * 3 );
341
344
case ETH_SS_TEST :
342
345
return MLX4_EN_NUM_SELF_TEST - !(priv -> mdev -> dev -> caps .flags
@@ -397,9 +400,9 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
397
400
if (bitmap_iterator_test (& it ))
398
401
data [index ++ ] = ((unsigned long * )& priv -> pkstats )[i ];
399
402
400
- for (i = 0 ; i < priv -> tx_ring_num ; i ++ ) {
401
- data [index ++ ] = priv -> tx_ring [i ]-> packets ;
402
- data [index ++ ] = priv -> tx_ring [i ]-> bytes ;
403
+ for (i = 0 ; i < priv -> tx_ring_num [ TX ] ; i ++ ) {
404
+ data [index ++ ] = priv -> tx_ring [TX ][ i ]-> packets ;
405
+ data [index ++ ] = priv -> tx_ring [TX ][ i ]-> bytes ;
403
406
}
404
407
for (i = 0 ; i < priv -> rx_ring_num ; i ++ ) {
405
408
data [index ++ ] = priv -> rx_ring [i ]-> packets ;
@@ -467,7 +470,7 @@ static void mlx4_en_get_strings(struct net_device *dev,
467
470
strcpy (data + (index ++ ) * ETH_GSTRING_LEN ,
468
471
main_strings [strings ]);
469
472
470
- for (i = 0 ; i < priv -> tx_ring_num ; i ++ ) {
473
+ for (i = 0 ; i < priv -> tx_ring_num [ TX ] ; i ++ ) {
471
474
sprintf (data + (index ++ ) * ETH_GSTRING_LEN ,
472
475
"tx%d_packets" , i );
473
476
sprintf (data + (index ++ ) * ETH_GSTRING_LEN ,
@@ -1060,7 +1063,7 @@ static int mlx4_en_set_ringparam(struct net_device *dev,
1060
1063
1061
1064
if (rx_size == (priv -> port_up ? priv -> rx_ring [0 ]-> actual_size :
1062
1065
priv -> rx_ring [0 ]-> size ) &&
1063
- tx_size == priv -> tx_ring [0 ]-> size )
1066
+ tx_size == priv -> tx_ring [TX ][ 0 ]-> size )
1064
1067
return 0 ;
1065
1068
1066
1069
tmp = kzalloc (sizeof (* tmp ), GFP_KERNEL );
@@ -1105,7 +1108,7 @@ static void mlx4_en_get_ringparam(struct net_device *dev,
1105
1108
param -> tx_max_pending = MLX4_EN_MAX_TX_SIZE ;
1106
1109
param -> rx_pending = priv -> port_up ?
1107
1110
priv -> rx_ring [0 ]-> actual_size : priv -> rx_ring [0 ]-> size ;
1108
- param -> tx_pending = priv -> tx_ring [0 ]-> size ;
1111
+ param -> tx_pending = priv -> tx_ring [TX ][ 0 ]-> size ;
1109
1112
}
1110
1113
1111
1114
static u32 mlx4_en_get_rxfh_indir_size (struct net_device * dev )
@@ -1710,7 +1713,7 @@ static void mlx4_en_get_channels(struct net_device *dev,
1710
1713
channel -> max_tx = MLX4_EN_MAX_TX_RING_P_UP ;
1711
1714
1712
1715
channel -> rx_count = priv -> rx_ring_num ;
1713
- channel -> tx_count = priv -> tx_ring_num / MLX4_EN_NUM_UP ;
1716
+ channel -> tx_count = priv -> tx_ring_num [ TX ] / MLX4_EN_NUM_UP ;
1714
1717
}
1715
1718
1716
1719
static int mlx4_en_set_channels (struct net_device * dev ,
@@ -1721,6 +1724,7 @@ static int mlx4_en_set_channels(struct net_device *dev,
1721
1724
struct mlx4_en_port_profile new_prof ;
1722
1725
struct mlx4_en_priv * tmp ;
1723
1726
int port_up = 0 ;
1727
+ int xdp_count ;
1724
1728
int err = 0 ;
1725
1729
1726
1730
if (channel -> other_count || channel -> combined_count ||
@@ -1729,20 +1733,25 @@ static int mlx4_en_set_channels(struct net_device *dev,
1729
1733
!channel -> tx_count || !channel -> rx_count )
1730
1734
return - EINVAL ;
1731
1735
1732
- if (channel -> tx_count * MLX4_EN_NUM_UP <= priv -> xdp_ring_num ) {
1733
- en_err (priv , "Minimum %d tx channels required with XDP on\n" ,
1734
- priv -> xdp_ring_num / MLX4_EN_NUM_UP + 1 );
1735
- return - EINVAL ;
1736
- }
1737
-
1738
1736
tmp = kzalloc (sizeof (* tmp ), GFP_KERNEL );
1739
1737
if (!tmp )
1740
1738
return - ENOMEM ;
1741
1739
1742
1740
mutex_lock (& mdev -> state_lock );
1741
+ xdp_count = priv -> tx_ring_num [TX_XDP ] ? channel -> rx_count : 0 ;
1742
+ if (channel -> tx_count * MLX4_EN_NUM_UP + xdp_count > MAX_TX_RINGS ) {
1743
+ err = - EINVAL ;
1744
+ en_err (priv ,
1745
+ "Total number of TX and XDP rings (%d) exceeds the maximum supported (%d)\n" ,
1746
+ channel -> tx_count * MLX4_EN_NUM_UP + xdp_count ,
1747
+ MAX_TX_RINGS );
1748
+ goto out ;
1749
+ }
1750
+
1743
1751
memcpy (& new_prof , priv -> prof , sizeof (struct mlx4_en_port_profile ));
1744
1752
new_prof .num_tx_rings_p_up = channel -> tx_count ;
1745
- new_prof .tx_ring_num = channel -> tx_count * MLX4_EN_NUM_UP ;
1753
+ new_prof .tx_ring_num [TX ] = channel -> tx_count * MLX4_EN_NUM_UP ;
1754
+ new_prof .tx_ring_num [TX_XDP ] = xdp_count ;
1746
1755
new_prof .rx_ring_num = channel -> rx_count ;
1747
1756
1748
1757
err = mlx4_en_try_alloc_resources (priv , tmp , & new_prof );
@@ -1756,14 +1765,13 @@ static int mlx4_en_set_channels(struct net_device *dev,
1756
1765
1757
1766
mlx4_en_safe_replace_resources (priv , tmp );
1758
1767
1759
- netif_set_real_num_tx_queues (dev , priv -> tx_ring_num -
1760
- priv -> xdp_ring_num );
1768
+ netif_set_real_num_tx_queues (dev , priv -> tx_ring_num [TX ]);
1761
1769
netif_set_real_num_rx_queues (dev , priv -> rx_ring_num );
1762
1770
1763
1771
if (dev -> num_tc )
1764
1772
mlx4_en_setup_tc (dev , MLX4_EN_NUM_UP );
1765
1773
1766
- en_warn (priv , "Using %d TX rings\n" , priv -> tx_ring_num );
1774
+ en_warn (priv , "Using %d TX rings\n" , priv -> tx_ring_num [ TX ] );
1767
1775
en_warn (priv , "Using %d RX rings\n" , priv -> rx_ring_num );
1768
1776
1769
1777
if (port_up ) {
@@ -1774,8 +1782,8 @@ static int mlx4_en_set_channels(struct net_device *dev,
1774
1782
1775
1783
err = mlx4_en_moderation_update (priv );
1776
1784
out :
1777
- kfree (tmp );
1778
1785
mutex_unlock (& mdev -> state_lock );
1786
+ kfree (tmp );
1779
1787
return err ;
1780
1788
}
1781
1789
@@ -1823,11 +1831,15 @@ static int mlx4_en_set_priv_flags(struct net_device *dev, u32 flags)
1823
1831
int ret = 0 ;
1824
1832
1825
1833
if (bf_enabled_new != bf_enabled_old ) {
1834
+ int t ;
1835
+
1826
1836
if (bf_enabled_new ) {
1827
1837
bool bf_supported = true;
1828
1838
1829
- for (i = 0 ; i < priv -> tx_ring_num ; i ++ )
1830
- bf_supported &= priv -> tx_ring [i ]-> bf_alloced ;
1839
+ for (t = 0 ; t < MLX4_EN_NUM_TX_TYPES ; t ++ )
1840
+ for (i = 0 ; i < priv -> tx_ring_num [t ]; i ++ )
1841
+ bf_supported &=
1842
+ priv -> tx_ring [t ][i ]-> bf_alloced ;
1831
1843
1832
1844
if (!bf_supported ) {
1833
1845
en_err (priv , "BlueFlame is not supported\n" );
@@ -1839,8 +1851,10 @@ static int mlx4_en_set_priv_flags(struct net_device *dev, u32 flags)
1839
1851
priv -> pflags &= ~MLX4_EN_PRIV_FLAGS_BLUEFLAME ;
1840
1852
}
1841
1853
1842
- for (i = 0 ; i < priv -> tx_ring_num ; i ++ )
1843
- priv -> tx_ring [i ]-> bf_enabled = bf_enabled_new ;
1854
+ for (t = 0 ; t < MLX4_EN_NUM_TX_TYPES ; t ++ )
1855
+ for (i = 0 ; i < priv -> tx_ring_num [t ]; i ++ )
1856
+ priv -> tx_ring [t ][i ]-> bf_enabled =
1857
+ bf_enabled_new ;
1844
1858
1845
1859
en_info (priv , "BlueFlame %s\n" ,
1846
1860
bf_enabled_new ? "Enabled" : "Disabled" );
0 commit comments