@@ -4093,6 +4093,7 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev,
4093
4093
if (!params -> vlan_strip_disable )
4094
4094
netdev_warn (netdev , "Dropping C-tag vlan stripping offload due to S-tag vlan\n" );
4095
4095
}
4096
+
4096
4097
if (!MLX5E_GET_PFLAG (params , MLX5E_PFLAG_RX_STRIDING_RQ )) {
4097
4098
if (features & NETIF_F_LRO ) {
4098
4099
netdev_warn (netdev , "Disabling LRO, not supported in legacy RQ\n" );
@@ -4928,15 +4929,15 @@ void mlx5e_build_rss_params(struct mlx5e_rss_params *rss_params,
4928
4929
tirc_default_config [tt ].rx_hash_fields ;
4929
4930
}
4930
4931
4931
- void mlx5e_build_nic_params (struct mlx5e_priv * priv ,
4932
- struct mlx5e_xsk * xsk ,
4933
- struct mlx5e_rss_params * rss_params ,
4934
- struct mlx5e_params * params ,
4935
- u16 mtu )
4932
+ void mlx5e_build_nic_params (struct mlx5e_priv * priv , struct mlx5e_xsk * xsk , u16 mtu )
4936
4933
{
4934
+ struct mlx5e_rss_params * rss_params = & priv -> rss_params ;
4935
+ struct mlx5e_params * params = & priv -> channels .params ;
4937
4936
struct mlx5_core_dev * mdev = priv -> mdev ;
4938
4937
u8 rx_cq_period_mode ;
4939
4938
4939
+ priv -> max_nch = mlx5e_calc_max_nch (priv );
4940
+
4940
4941
params -> sw_mtu = mtu ;
4941
4942
params -> hard_mtu = MLX5E_ETH_HARD_MTU ;
4942
4943
params -> num_channels = min_t (unsigned int , MLX5E_MAX_NUM_CHANNELS / 2 ,
@@ -4994,6 +4995,11 @@ void mlx5e_build_nic_params(struct mlx5e_priv *priv,
4994
4995
4995
4996
/* AF_XDP */
4996
4997
params -> xsk = xsk ;
4998
+
4999
+ /* Do not update netdev->features directly in here
5000
+ * on mlx5e_attach_netdev() we will call mlx5e_update_features()
5001
+ * To update netdev->features please modify mlx5e_fix_features()
5002
+ */
4997
5003
}
4998
5004
4999
5005
static void mlx5e_set_netdev_dev_addr (struct net_device * netdev )
@@ -5146,18 +5152,12 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
5146
5152
netdev -> hw_features |= NETIF_F_RXFCS ;
5147
5153
5148
5154
netdev -> features = netdev -> hw_features ;
5149
- if (!priv -> channels .params .lro_en )
5150
- netdev -> features &= ~NETIF_F_LRO ;
5151
5155
5156
+ /* Defaults */
5152
5157
if (fcs_enabled )
5153
5158
netdev -> features &= ~NETIF_F_RXALL ;
5154
-
5155
- if (!priv -> channels .params .scatter_fcs_en )
5156
- netdev -> features &= ~NETIF_F_RXFCS ;
5157
-
5158
- /* prefere CQE compression over rxhash */
5159
- if (MLX5E_GET_PFLAG (& priv -> channels .params , MLX5E_PFLAG_RX_CQE_COMPRESS ))
5160
- netdev -> features &= ~NETIF_F_RXHASH ;
5159
+ netdev -> features &= ~NETIF_F_LRO ;
5160
+ netdev -> features &= ~NETIF_F_RXFCS ;
5161
5161
5162
5162
#define FT_CAP (f ) MLX5_CAP_FLOWTABLE(mdev, flow_table_properties_nic_receive.f)
5163
5163
if (FT_CAP (flow_modify_en ) &&
@@ -5223,33 +5223,27 @@ void mlx5e_destroy_q_counters(struct mlx5e_priv *priv)
5223
5223
}
5224
5224
5225
5225
static int mlx5e_nic_init (struct mlx5_core_dev * mdev ,
5226
- struct net_device * netdev ,
5227
- const struct mlx5e_profile * profile ,
5228
- void * ppriv )
5226
+ struct net_device * netdev )
5229
5227
{
5230
5228
struct mlx5e_priv * priv = netdev_priv (netdev );
5231
- struct mlx5e_rss_params * rss = & priv -> rss_params ;
5232
5229
int err ;
5233
5230
5234
- err = mlx5e_netdev_init (netdev , priv , mdev , profile , ppriv );
5235
- if (err )
5236
- return err ;
5237
-
5238
- mlx5e_build_nic_params (priv , & priv -> xsk , rss , & priv -> channels .params ,
5239
- netdev -> mtu );
5231
+ mlx5e_build_nic_params (priv , & priv -> xsk , netdev -> mtu );
5240
5232
5241
5233
mlx5e_timestamp_init (priv );
5242
5234
5243
5235
err = mlx5e_ipsec_init (priv );
5244
5236
if (err )
5245
5237
mlx5_core_err (mdev , "IPSec initialization failed, %d\n" , err );
5238
+
5246
5239
err = mlx5e_tls_init (priv );
5247
5240
if (err )
5248
5241
mlx5_core_err (mdev , "TLS initialization failed, %d\n" , err );
5249
- mlx5e_build_nic_netdev ( netdev );
5242
+
5250
5243
err = mlx5e_devlink_port_register (priv );
5251
5244
if (err )
5252
5245
mlx5_core_err (mdev , "mlx5e_devlink_port_register failed, %d\n" , err );
5246
+
5253
5247
mlx5e_health_create_reporters (priv );
5254
5248
5255
5249
return 0 ;
@@ -5261,7 +5255,6 @@ static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
5261
5255
mlx5e_devlink_port_unregister (priv );
5262
5256
mlx5e_tls_cleanup (priv );
5263
5257
mlx5e_ipsec_cleanup (priv );
5264
- mlx5e_netdev_cleanup (priv -> netdev , priv );
5265
5258
}
5266
5259
5267
5260
static int mlx5e_init_nic_rx (struct mlx5e_priv * priv )
@@ -5464,21 +5457,14 @@ static const struct mlx5e_profile mlx5e_nic_profile = {
5464
5457
};
5465
5458
5466
5459
/* mlx5e generic netdev management API (move to en_common.c) */
5467
-
5468
- /* mlx5e_netdev_init/cleanup must be called from profile->init/cleanup callbacks */
5469
5460
int mlx5e_netdev_init (struct net_device * netdev ,
5470
5461
struct mlx5e_priv * priv ,
5471
- struct mlx5_core_dev * mdev ,
5472
- const struct mlx5e_profile * profile ,
5473
- void * ppriv )
5462
+ struct mlx5_core_dev * mdev )
5474
5463
{
5475
5464
/* priv init */
5476
5465
priv -> mdev = mdev ;
5477
5466
priv -> netdev = netdev ;
5478
- priv -> profile = profile ;
5479
- priv -> ppriv = ppriv ;
5480
5467
priv -> msglevel = MLX5E_MSG_LEVEL ;
5481
- priv -> max_nch = netdev -> num_rx_queues / max_t (u8 , profile -> rq_groups , 1 );
5482
5468
priv -> max_opened_tc = 1 ;
5483
5469
5484
5470
if (!alloc_cpumask_var (& priv -> scratchpad .cpumask , GFP_KERNEL ))
@@ -5518,35 +5504,24 @@ void mlx5e_netdev_cleanup(struct net_device *netdev, struct mlx5e_priv *priv)
5518
5504
kvfree (priv -> htb .qos_sq_stats );
5519
5505
}
5520
5506
5521
- struct net_device * mlx5e_create_netdev (struct mlx5_core_dev * mdev ,
5522
- const struct mlx5e_profile * profile ,
5523
- int nch ,
5524
- void * ppriv )
5507
+ struct net_device *
5508
+ mlx5e_create_netdev (struct mlx5_core_dev * mdev , unsigned int txqs , unsigned int rxqs )
5525
5509
{
5526
5510
struct net_device * netdev ;
5527
- unsigned int ptp_txqs = 0 ;
5528
- int qos_sqs = 0 ;
5529
5511
int err ;
5530
5512
5531
- if (MLX5_CAP_GEN (mdev , ts_cqe_to_dest_cqn ))
5532
- ptp_txqs = profile -> max_tc ;
5533
-
5534
- if (mlx5_qos_is_supported (mdev ))
5535
- qos_sqs = mlx5e_qos_max_leaf_nodes (mdev );
5536
-
5537
- netdev = alloc_etherdev_mqs (sizeof (struct mlx5e_priv ),
5538
- nch * profile -> max_tc + ptp_txqs + qos_sqs ,
5539
- nch * profile -> rq_groups );
5513
+ netdev = alloc_etherdev_mqs (sizeof (struct mlx5e_priv ), txqs , rxqs );
5540
5514
if (!netdev ) {
5541
5515
mlx5_core_err (mdev , "alloc_etherdev_mqs() failed\n" );
5542
5516
return NULL ;
5543
5517
}
5544
5518
5545
- err = profile -> init ( mdev , netdev , profile , ppriv );
5519
+ err = mlx5e_netdev_init ( netdev , netdev_priv ( netdev ), mdev );
5546
5520
if (err ) {
5547
- mlx5_core_err (mdev , "failed to init mlx5e profile %d\n" , err );
5521
+ mlx5_core_err (mdev , "mlx5e_netdev_init failed, err= %d\n" , err );
5548
5522
goto err_free_netdev ;
5549
5523
}
5524
+ dev_net_set (netdev , mlx5_core_net (mdev ));
5550
5525
5551
5526
return netdev ;
5552
5527
@@ -5556,14 +5531,23 @@ struct net_device *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
5556
5531
return NULL ;
5557
5532
}
5558
5533
5534
+ static void mlx5e_update_features (struct net_device * netdev )
5535
+ {
5536
+ if (netdev -> reg_state != NETREG_REGISTERED )
5537
+ return ; /* features will be updated on netdev registration */
5538
+
5539
+ rtnl_lock ();
5540
+ netdev_update_features (netdev );
5541
+ rtnl_unlock ();
5542
+ }
5543
+
5559
5544
int mlx5e_attach_netdev (struct mlx5e_priv * priv )
5560
5545
{
5561
5546
const bool take_rtnl = priv -> netdev -> reg_state == NETREG_REGISTERED ;
5562
- const struct mlx5e_profile * profile ;
5547
+ const struct mlx5e_profile * profile = priv -> profile ;
5563
5548
int max_nch ;
5564
5549
int err ;
5565
5550
5566
- profile = priv -> profile ;
5567
5551
clear_bit (MLX5E_STATE_DESTROYING , & priv -> state );
5568
5552
5569
5553
/* max number of channels may have changed */
@@ -5603,6 +5587,8 @@ int mlx5e_attach_netdev(struct mlx5e_priv *priv)
5603
5587
if (profile -> enable )
5604
5588
profile -> enable (priv );
5605
5589
5590
+ mlx5e_update_features (priv -> netdev );
5591
+
5606
5592
return 0 ;
5607
5593
5608
5594
err_cleanup_tx :
@@ -5631,11 +5617,9 @@ void mlx5e_detach_netdev(struct mlx5e_priv *priv)
5631
5617
5632
5618
void mlx5e_destroy_netdev (struct mlx5e_priv * priv )
5633
5619
{
5634
- const struct mlx5e_profile * profile = priv -> profile ;
5635
5620
struct net_device * netdev = priv -> netdev ;
5636
5621
5637
- if (profile -> cleanup )
5638
- profile -> cleanup (priv );
5622
+ mlx5e_netdev_cleanup (netdev , priv );
5639
5623
free_netdev (netdev );
5640
5624
}
5641
5625
@@ -5681,28 +5665,48 @@ static int mlx5e_probe(struct auxiliary_device *adev,
5681
5665
const struct auxiliary_device_id * id )
5682
5666
{
5683
5667
struct mlx5_adev * edev = container_of (adev , struct mlx5_adev , adev );
5668
+ const struct mlx5e_profile * profile = & mlx5e_nic_profile ;
5684
5669
struct mlx5_core_dev * mdev = edev -> mdev ;
5685
5670
struct net_device * netdev ;
5686
5671
pm_message_t state = {};
5687
- void * priv ;
5672
+ unsigned int txqs , rxqs , ptp_txqs = 0 ;
5673
+ struct mlx5e_priv * priv ;
5674
+ int qos_sqs = 0 ;
5688
5675
int err ;
5689
5676
int nch ;
5690
5677
5678
+ if (MLX5_CAP_GEN (mdev , ts_cqe_to_dest_cqn ))
5679
+ ptp_txqs = profile -> max_tc ;
5680
+
5681
+ if (mlx5_qos_is_supported (mdev ))
5682
+ qos_sqs = mlx5e_qos_max_leaf_nodes (mdev );
5683
+
5691
5684
nch = mlx5e_get_max_num_channels (mdev );
5692
- netdev = mlx5e_create_netdev (mdev , & mlx5e_nic_profile , nch , NULL );
5685
+ txqs = nch * profile -> max_tc + ptp_txqs + qos_sqs ;
5686
+ rxqs = nch * profile -> rq_groups ;
5687
+ netdev = mlx5e_create_netdev (mdev , txqs , rxqs );
5693
5688
if (!netdev ) {
5694
5689
mlx5_core_err (mdev , "mlx5e_create_netdev failed\n" );
5695
5690
return - ENOMEM ;
5696
5691
}
5697
5692
5698
- dev_net_set (netdev , mlx5_core_net (mdev ));
5693
+ mlx5e_build_nic_netdev (netdev );
5694
+
5699
5695
priv = netdev_priv (netdev );
5700
5696
dev_set_drvdata (& adev -> dev , priv );
5701
5697
5698
+ priv -> profile = profile ;
5699
+ priv -> ppriv = NULL ;
5700
+ err = profile -> init (mdev , netdev );
5701
+ if (err ) {
5702
+ mlx5_core_err (mdev , "mlx5e_nic_profile init failed, %d\n" , err );
5703
+ goto err_destroy_netdev ;
5704
+ }
5705
+
5702
5706
err = mlx5e_resume (adev );
5703
5707
if (err ) {
5704
5708
mlx5_core_err (mdev , "mlx5e_resume failed, %d\n" , err );
5705
- goto err_destroy_netdev ;
5709
+ goto err_profile_cleanup ;
5706
5710
}
5707
5711
5708
5712
err = register_netdev (netdev );
@@ -5718,6 +5722,8 @@ static int mlx5e_probe(struct auxiliary_device *adev,
5718
5722
5719
5723
err_resume :
5720
5724
mlx5e_suspend (adev , state );
5725
+ err_profile_cleanup :
5726
+ profile -> cleanup (priv );
5721
5727
err_destroy_netdev :
5722
5728
mlx5e_destroy_netdev (priv );
5723
5729
return err ;
@@ -5731,6 +5737,7 @@ static void mlx5e_remove(struct auxiliary_device *adev)
5731
5737
mlx5e_dcbnl_delete_app (priv );
5732
5738
unregister_netdev (priv -> netdev );
5733
5739
mlx5e_suspend (adev , state );
5740
+ priv -> profile -> cleanup (priv );
5734
5741
mlx5e_destroy_netdev (priv );
5735
5742
}
5736
5743
0 commit comments