@@ -273,6 +273,10 @@ static int be_mac_addr_set(struct net_device *netdev, void *p)
273
273
if (ether_addr_equal (addr -> sa_data , netdev -> dev_addr ))
274
274
return 0 ;
275
275
276
+ /* if device is not running, copy MAC to netdev->dev_addr */
277
+ if (!netif_running (netdev ))
278
+ goto done ;
279
+
276
280
/* The PMAC_ADD cmd may fail if the VF doesn't have FILTMGMT
277
281
* privilege or if PF did not provision the new MAC address.
278
282
* On BE3, this cmd will always fail if the VF doesn't have the
@@ -307,9 +311,9 @@ static int be_mac_addr_set(struct net_device *netdev, void *p)
307
311
status = - EPERM ;
308
312
goto err ;
309
313
}
310
-
311
- memcpy (netdev -> dev_addr , addr -> sa_data , netdev -> addr_len );
312
- dev_info (dev , "MAC address changed to %pM\n" , mac );
314
+ done :
315
+ ether_addr_copy (netdev -> dev_addr , addr -> sa_data );
316
+ dev_info (dev , "MAC address changed to %pM\n" , addr -> sa_data );
313
317
return 0 ;
314
318
err :
315
319
dev_warn (dev , "MAC address change to %pM failed\n" , addr -> sa_data );
@@ -2447,10 +2451,24 @@ static void be_eq_clean(struct be_eq_obj *eqo)
2447
2451
be_eq_notify (eqo -> adapter , eqo -> q .id , false, true, num , 0 );
2448
2452
}
2449
2453
2450
- static void be_rx_cq_clean (struct be_rx_obj * rxo )
2454
+ /* Free posted rx buffers that were not used */
2455
+ static void be_rxq_clean (struct be_rx_obj * rxo )
2451
2456
{
2452
- struct be_rx_page_info * page_info ;
2453
2457
struct be_queue_info * rxq = & rxo -> q ;
2458
+ struct be_rx_page_info * page_info ;
2459
+
2460
+ while (atomic_read (& rxq -> used ) > 0 ) {
2461
+ page_info = get_rx_page_info (rxo );
2462
+ put_page (page_info -> page );
2463
+ memset (page_info , 0 , sizeof (* page_info ));
2464
+ }
2465
+ BUG_ON (atomic_read (& rxq -> used ));
2466
+ rxq -> tail = 0 ;
2467
+ rxq -> head = 0 ;
2468
+ }
2469
+
2470
+ static void be_rx_cq_clean (struct be_rx_obj * rxo )
2471
+ {
2454
2472
struct be_queue_info * rx_cq = & rxo -> cq ;
2455
2473
struct be_rx_compl_info * rxcp ;
2456
2474
struct be_adapter * adapter = rxo -> adapter ;
@@ -2487,16 +2505,6 @@ static void be_rx_cq_clean(struct be_rx_obj *rxo)
2487
2505
2488
2506
/* After cleanup, leave the CQ in unarmed state */
2489
2507
be_cq_notify (adapter , rx_cq -> id , false, 0 );
2490
-
2491
- /* Then free posted rx buffers that were not used */
2492
- while (atomic_read (& rxq -> used ) > 0 ) {
2493
- page_info = get_rx_page_info (rxo );
2494
- put_page (page_info -> page );
2495
- memset (page_info , 0 , sizeof (* page_info ));
2496
- }
2497
- BUG_ON (atomic_read (& rxq -> used ));
2498
- rxq -> tail = 0 ;
2499
- rxq -> head = 0 ;
2500
2508
}
2501
2509
2502
2510
static void be_tx_compl_clean (struct be_adapter * adapter )
@@ -2576,8 +2584,8 @@ static void be_evt_queues_destroy(struct be_adapter *adapter)
2576
2584
be_cmd_q_destroy (adapter , & eqo -> q , QTYPE_EQ );
2577
2585
napi_hash_del (& eqo -> napi );
2578
2586
netif_napi_del (& eqo -> napi );
2587
+ free_cpumask_var (eqo -> affinity_mask );
2579
2588
}
2580
- free_cpumask_var (eqo -> affinity_mask );
2581
2589
be_queue_free (adapter , & eqo -> q );
2582
2590
}
2583
2591
}
@@ -2594,13 +2602,7 @@ static int be_evt_queues_create(struct be_adapter *adapter)
2594
2602
2595
2603
for_all_evt_queues (adapter , eqo , i ) {
2596
2604
int numa_node = dev_to_node (& adapter -> pdev -> dev );
2597
- if (!zalloc_cpumask_var (& eqo -> affinity_mask , GFP_KERNEL ))
2598
- return - ENOMEM ;
2599
- cpumask_set_cpu (cpumask_local_spread (i , numa_node ),
2600
- eqo -> affinity_mask );
2601
- netif_napi_add (adapter -> netdev , & eqo -> napi , be_poll ,
2602
- BE_NAPI_WEIGHT );
2603
- napi_hash_add (& eqo -> napi );
2605
+
2604
2606
aic = & adapter -> aic_obj [i ];
2605
2607
eqo -> adapter = adapter ;
2606
2608
eqo -> idx = i ;
@@ -2616,6 +2618,14 @@ static int be_evt_queues_create(struct be_adapter *adapter)
2616
2618
rc = be_cmd_eq_create (adapter , eqo );
2617
2619
if (rc )
2618
2620
return rc ;
2621
+
2622
+ if (!zalloc_cpumask_var (& eqo -> affinity_mask , GFP_KERNEL ))
2623
+ return - ENOMEM ;
2624
+ cpumask_set_cpu (cpumask_local_spread (i , numa_node ),
2625
+ eqo -> affinity_mask );
2626
+ netif_napi_add (adapter -> netdev , & eqo -> napi , be_poll ,
2627
+ BE_NAPI_WEIGHT );
2628
+ napi_hash_add (& eqo -> napi );
2619
2629
}
2620
2630
return 0 ;
2621
2631
}
@@ -3354,13 +3364,54 @@ static void be_rx_qs_destroy(struct be_adapter *adapter)
3354
3364
for_all_rx_queues (adapter , rxo , i ) {
3355
3365
q = & rxo -> q ;
3356
3366
if (q -> created ) {
3367
+ /* If RXQs are destroyed while in an "out of buffer"
3368
+ * state, there is a possibility of an HW stall on
3369
+ * Lancer. So, post 64 buffers to each queue to relieve
3370
+ * the "out of buffer" condition.
3371
+ * Make sure there's space in the RXQ before posting.
3372
+ */
3373
+ if (lancer_chip (adapter )) {
3374
+ be_rx_cq_clean (rxo );
3375
+ if (atomic_read (& q -> used ) == 0 )
3376
+ be_post_rx_frags (rxo , GFP_KERNEL ,
3377
+ MAX_RX_POST );
3378
+ }
3379
+
3357
3380
be_cmd_rxq_destroy (adapter , q );
3358
3381
be_rx_cq_clean (rxo );
3382
+ be_rxq_clean (rxo );
3359
3383
}
3360
3384
be_queue_free (adapter , q );
3361
3385
}
3362
3386
}
3363
3387
3388
+ static void be_disable_if_filters (struct be_adapter * adapter )
3389
+ {
3390
+ be_cmd_pmac_del (adapter , adapter -> if_handle ,
3391
+ adapter -> pmac_id [0 ], 0 );
3392
+
3393
+ be_clear_uc_list (adapter );
3394
+
3395
+ /* The IFACE flags are enabled in the open path and cleared
3396
+ * in the close path. When a VF gets detached from the host and
3397
+ * assigned to a VM the following happens:
3398
+ * - VF's IFACE flags get cleared in the detach path
3399
+ * - IFACE create is issued by the VF in the attach path
3400
+ * Due to a bug in the BE3/Skyhawk-R FW
3401
+ * (Lancer FW doesn't have the bug), the IFACE capability flags
3402
+ * specified along with the IFACE create cmd issued by a VF are not
3403
+ * honoured by FW. As a consequence, if a *new* driver
3404
+ * (that enables/disables IFACE flags in open/close)
3405
+ * is loaded in the host and an *old* driver is * used by a VM/VF,
3406
+ * the IFACE gets created *without* the needed flags.
3407
+ * To avoid this, disable RX-filter flags only for Lancer.
3408
+ */
3409
+ if (lancer_chip (adapter )) {
3410
+ be_cmd_rx_filter (adapter , BE_IF_ALL_FILT_FLAGS , OFF );
3411
+ adapter -> if_flags &= ~BE_IF_ALL_FILT_FLAGS ;
3412
+ }
3413
+ }
3414
+
3364
3415
static int be_close (struct net_device * netdev )
3365
3416
{
3366
3417
struct be_adapter * adapter = netdev_priv (netdev );
@@ -3373,6 +3424,8 @@ static int be_close(struct net_device *netdev)
3373
3424
if (!(adapter -> flags & BE_FLAGS_SETUP_DONE ))
3374
3425
return 0 ;
3375
3426
3427
+ be_disable_if_filters (adapter );
3428
+
3376
3429
be_roce_dev_close (adapter );
3377
3430
3378
3431
if (adapter -> flags & BE_FLAGS_NAPI_ENABLED ) {
@@ -3392,7 +3445,6 @@ static int be_close(struct net_device *netdev)
3392
3445
be_tx_compl_clean (adapter );
3393
3446
3394
3447
be_rx_qs_destroy (adapter );
3395
- be_clear_uc_list (adapter );
3396
3448
3397
3449
for_all_evt_queues (adapter , eqo , i ) {
3398
3450
if (msix_enabled (adapter ))
@@ -3477,6 +3529,31 @@ static int be_rx_qs_create(struct be_adapter *adapter)
3477
3529
return 0 ;
3478
3530
}
3479
3531
3532
+ static int be_enable_if_filters (struct be_adapter * adapter )
3533
+ {
3534
+ int status ;
3535
+
3536
+ status = be_cmd_rx_filter (adapter , BE_IF_EN_FLAGS , ON );
3537
+ if (status )
3538
+ return status ;
3539
+
3540
+ /* For BE3 VFs, the PF programs the initial MAC address */
3541
+ if (!(BEx_chip (adapter ) && be_virtfn (adapter ))) {
3542
+ status = be_cmd_pmac_add (adapter , adapter -> netdev -> dev_addr ,
3543
+ adapter -> if_handle ,
3544
+ & adapter -> pmac_id [0 ], 0 );
3545
+ if (status )
3546
+ return status ;
3547
+ }
3548
+
3549
+ if (adapter -> vlans_added )
3550
+ be_vid_config (adapter );
3551
+
3552
+ be_set_rx_mode (adapter -> netdev );
3553
+
3554
+ return 0 ;
3555
+ }
3556
+
3480
3557
static int be_open (struct net_device * netdev )
3481
3558
{
3482
3559
struct be_adapter * adapter = netdev_priv (netdev );
@@ -3490,6 +3567,10 @@ static int be_open(struct net_device *netdev)
3490
3567
if (status )
3491
3568
goto err ;
3492
3569
3570
+ status = be_enable_if_filters (adapter );
3571
+ if (status )
3572
+ goto err ;
3573
+
3493
3574
status = be_irq_register (adapter );
3494
3575
if (status )
3495
3576
goto err ;
@@ -3686,16 +3767,6 @@ static void be_cancel_err_detection(struct be_adapter *adapter)
3686
3767
}
3687
3768
}
3688
3769
3689
- static void be_mac_clear (struct be_adapter * adapter )
3690
- {
3691
- if (adapter -> pmac_id ) {
3692
- be_cmd_pmac_del (adapter , adapter -> if_handle ,
3693
- adapter -> pmac_id [0 ], 0 );
3694
- kfree (adapter -> pmac_id );
3695
- adapter -> pmac_id = NULL ;
3696
- }
3697
- }
3698
-
3699
3770
#ifdef CONFIG_BE2NET_VXLAN
3700
3771
static void be_disable_vxlan_offloads (struct be_adapter * adapter )
3701
3772
{
@@ -3770,8 +3841,8 @@ static int be_clear(struct be_adapter *adapter)
3770
3841
#ifdef CONFIG_BE2NET_VXLAN
3771
3842
be_disable_vxlan_offloads (adapter );
3772
3843
#endif
3773
- /* delete the primary mac along with the uc-mac list */
3774
- be_mac_clear ( adapter ) ;
3844
+ kfree ( adapter -> pmac_id );
3845
+ adapter -> pmac_id = NULL ;
3775
3846
3776
3847
be_cmd_if_destroy (adapter , adapter -> if_handle , 0 );
3777
3848
@@ -3782,25 +3853,11 @@ static int be_clear(struct be_adapter *adapter)
3782
3853
return 0 ;
3783
3854
}
3784
3855
3785
- static int be_if_create (struct be_adapter * adapter , u32 * if_handle ,
3786
- u32 cap_flags , u32 vf )
3787
- {
3788
- u32 en_flags ;
3789
-
3790
- en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
3791
- BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS |
3792
- BE_IF_FLAGS_RSS | BE_IF_FLAGS_DEFQ_RSS ;
3793
-
3794
- en_flags &= cap_flags ;
3795
-
3796
- return be_cmd_if_create (adapter , cap_flags , en_flags , if_handle , vf );
3797
- }
3798
-
3799
3856
static int be_vfs_if_create (struct be_adapter * adapter )
3800
3857
{
3801
3858
struct be_resources res = {0 };
3859
+ u32 cap_flags , en_flags , vf ;
3802
3860
struct be_vf_cfg * vf_cfg ;
3803
- u32 cap_flags , vf ;
3804
3861
int status ;
3805
3862
3806
3863
/* If a FW profile exists, then cap_flags are updated */
@@ -3821,8 +3878,12 @@ static int be_vfs_if_create(struct be_adapter *adapter)
3821
3878
}
3822
3879
}
3823
3880
3824
- status = be_if_create (adapter , & vf_cfg -> if_handle ,
3825
- cap_flags , vf + 1 );
3881
+ en_flags = cap_flags & (BE_IF_FLAGS_UNTAGGED |
3882
+ BE_IF_FLAGS_BROADCAST |
3883
+ BE_IF_FLAGS_MULTICAST |
3884
+ BE_IF_FLAGS_PASS_L3L4_ERRORS );
3885
+ status = be_cmd_if_create (adapter , cap_flags , en_flags ,
3886
+ & vf_cfg -> if_handle , vf + 1 );
3826
3887
if (status )
3827
3888
return status ;
3828
3889
}
@@ -4194,15 +4255,8 @@ static int be_mac_setup(struct be_adapter *adapter)
4194
4255
4195
4256
memcpy (adapter -> netdev -> dev_addr , mac , ETH_ALEN );
4196
4257
memcpy (adapter -> netdev -> perm_addr , mac , ETH_ALEN );
4197
- } else {
4198
- /* Maybe the HW was reset; dev_addr must be re-programmed */
4199
- memcpy (mac , adapter -> netdev -> dev_addr , ETH_ALEN );
4200
4258
}
4201
4259
4202
- /* For BE3-R VFs, the PF programs the initial MAC address */
4203
- if (!(BEx_chip (adapter ) && be_virtfn (adapter )))
4204
- be_cmd_pmac_add (adapter , mac , adapter -> if_handle ,
4205
- & adapter -> pmac_id [0 ], 0 );
4206
4260
return 0 ;
4207
4261
}
4208
4262
@@ -4342,6 +4396,7 @@ static int be_func_init(struct be_adapter *adapter)
4342
4396
static int be_setup (struct be_adapter * adapter )
4343
4397
{
4344
4398
struct device * dev = & adapter -> pdev -> dev ;
4399
+ u32 en_flags ;
4345
4400
int status ;
4346
4401
4347
4402
status = be_func_init (adapter );
@@ -4364,8 +4419,11 @@ static int be_setup(struct be_adapter *adapter)
4364
4419
if (status )
4365
4420
goto err ;
4366
4421
4367
- status = be_if_create (adapter , & adapter -> if_handle ,
4368
- be_if_cap_flags (adapter ), 0 );
4422
+ /* will enable all the needed filter flags in be_open() */
4423
+ en_flags = BE_IF_FLAGS_RSS | BE_IF_FLAGS_DEFQ_RSS ;
4424
+ en_flags = en_flags & be_if_cap_flags (adapter );
4425
+ status = be_cmd_if_create (adapter , be_if_cap_flags (adapter ), en_flags ,
4426
+ & adapter -> if_handle , 0 );
4369
4427
if (status )
4370
4428
goto err ;
4371
4429
@@ -4391,11 +4449,6 @@ static int be_setup(struct be_adapter *adapter)
4391
4449
dev_err (dev , "Please upgrade firmware to version >= 4.0\n" );
4392
4450
}
4393
4451
4394
- if (adapter -> vlans_added )
4395
- be_vid_config (adapter );
4396
-
4397
- be_set_rx_mode (adapter -> netdev );
4398
-
4399
4452
status = be_cmd_set_flow_control (adapter , adapter -> tx_fc ,
4400
4453
adapter -> rx_fc );
4401
4454
if (status )
0 commit comments