@@ -36,6 +36,8 @@ void bnx2x_add_tlv(struct bnx2x *bp, void *tlvs_list, u16 offset, u16 type,
36
36
void bnx2x_vfpf_prep (struct bnx2x * bp , struct vfpf_first_tlv * first_tlv ,
37
37
u16 type , u16 length )
38
38
{
39
+ mutex_lock (& bp -> vf2pf_mutex );
40
+
39
41
DP (BNX2X_MSG_IOV , "preparing to send %d tlv over vf pf channel\n" ,
40
42
type );
41
43
@@ -49,6 +51,15 @@ void bnx2x_vfpf_prep(struct bnx2x *bp, struct vfpf_first_tlv *first_tlv,
49
51
first_tlv -> resp_msg_offset = sizeof (bp -> vf2pf_mbox -> req );
50
52
}
51
53
54
+ /* releases the mailbox */
55
+ void bnx2x_vfpf_finalize (struct bnx2x * bp , struct vfpf_first_tlv * first_tlv )
56
+ {
57
+ DP (BNX2X_MSG_IOV , "done sending [%d] tlv over vf pf channel\n" ,
58
+ first_tlv -> tl .type );
59
+
60
+ mutex_unlock (& bp -> vf2pf_mutex );
61
+ }
62
+
52
63
/* list the types and lengths of the tlvs on the buffer */
53
64
void bnx2x_dp_tlv_list (struct bnx2x * bp , void * tlvs_list )
54
65
{
@@ -181,8 +192,10 @@ int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count)
181
192
/* clear mailbox and prep first tlv */
182
193
bnx2x_vfpf_prep (bp , & req -> first_tlv , CHANNEL_TLV_ACQUIRE , sizeof (* req ));
183
194
184
- if (bnx2x_get_vf_id (bp , & vf_id ))
185
- return - EAGAIN ;
195
+ if (bnx2x_get_vf_id (bp , & vf_id )) {
196
+ rc = - EAGAIN ;
197
+ goto out ;
198
+ }
186
199
187
200
req -> vfdev_info .vf_id = vf_id ;
188
201
req -> vfdev_info .vf_os = 0 ;
@@ -213,7 +226,7 @@ int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count)
213
226
214
227
/* PF timeout */
215
228
if (rc )
216
- return rc ;
229
+ goto out ;
217
230
218
231
/* copy acquire response from buffer to bp */
219
232
memcpy (& bp -> acquire_resp , resp , sizeof (bp -> acquire_resp ));
@@ -253,7 +266,8 @@ int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count)
253
266
/* PF reports error */
254
267
BNX2X_ERR ("Failed to get the requested amount of resources: %d. Breaking...\n" ,
255
268
bp -> acquire_resp .hdr .status );
256
- return - EAGAIN ;
269
+ rc = - EAGAIN ;
270
+ goto out ;
257
271
}
258
272
}
259
273
@@ -279,20 +293,24 @@ int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count)
279
293
bp -> acquire_resp .resc .current_mac_addr ,
280
294
ETH_ALEN );
281
295
282
- return 0 ;
296
+ out :
297
+ bnx2x_vfpf_finalize (bp , & req -> first_tlv );
298
+ return rc ;
283
299
}
284
300
285
301
int bnx2x_vfpf_release (struct bnx2x * bp )
286
302
{
287
303
struct vfpf_release_tlv * req = & bp -> vf2pf_mbox -> req .release ;
288
304
struct pfvf_general_resp_tlv * resp = & bp -> vf2pf_mbox -> resp .general_resp ;
289
- u32 rc = 0 , vf_id ;
305
+ u32 rc , vf_id ;
290
306
291
307
/* clear mailbox and prep first tlv */
292
308
bnx2x_vfpf_prep (bp , & req -> first_tlv , CHANNEL_TLV_RELEASE , sizeof (* req ));
293
309
294
- if (bnx2x_get_vf_id (bp , & vf_id ))
295
- return - EAGAIN ;
310
+ if (bnx2x_get_vf_id (bp , & vf_id )) {
311
+ rc = - EAGAIN ;
312
+ goto out ;
313
+ }
296
314
297
315
req -> vf_id = vf_id ;
298
316
@@ -308,18 +326,22 @@ int bnx2x_vfpf_release(struct bnx2x *bp)
308
326
309
327
if (rc )
310
328
/* PF timeout */
311
- return rc ;
329
+ goto out ;
330
+
312
331
if (resp -> hdr .status == PFVF_STATUS_SUCCESS ) {
313
332
/* PF released us */
314
333
DP (BNX2X_MSG_SP , "vf released\n" );
315
334
} else {
316
335
/* PF reports error */
317
336
BNX2X_ERR ("PF failed our release request - are we out of sync? response status: %d\n" ,
318
337
resp -> hdr .status );
319
- return - EAGAIN ;
338
+ rc = - EAGAIN ;
339
+ goto out ;
320
340
}
341
+ out :
342
+ bnx2x_vfpf_finalize (bp , & req -> first_tlv );
321
343
322
- return 0 ;
344
+ return rc ;
323
345
}
324
346
325
347
/* Tell PF about SB addresses */
@@ -350,16 +372,20 @@ int bnx2x_vfpf_init(struct bnx2x *bp)
350
372
351
373
rc = bnx2x_send_msg2pf (bp , & resp -> hdr .status , bp -> vf2pf_mbox_mapping );
352
374
if (rc )
353
- return rc ;
375
+ goto out ;
354
376
355
377
if (resp -> hdr .status != PFVF_STATUS_SUCCESS ) {
356
378
BNX2X_ERR ("INIT VF failed: %d. Breaking...\n" ,
357
379
resp -> hdr .status );
358
- return - EAGAIN ;
380
+ rc = - EAGAIN ;
381
+ goto out ;
359
382
}
360
383
361
384
DP (BNX2X_MSG_SP , "INIT VF Succeeded\n" );
362
- return 0 ;
385
+ out :
386
+ bnx2x_vfpf_finalize (bp , & req -> first_tlv );
387
+
388
+ return rc ;
363
389
}
364
390
365
391
/* CLOSE VF - opposite to INIT_VF */
@@ -401,6 +427,8 @@ void bnx2x_vfpf_close_vf(struct bnx2x *bp)
401
427
BNX2X_ERR ("Sending CLOSE failed: pf response was %d\n" ,
402
428
resp -> hdr .status );
403
429
430
+ bnx2x_vfpf_finalize (bp , & req -> first_tlv );
431
+
404
432
free_irq :
405
433
/* Disable HW interrupts, NAPI */
406
434
bnx2x_netif_stop (bp , 0 );
@@ -485,8 +513,11 @@ int bnx2x_vfpf_setup_q(struct bnx2x *bp, int fp_idx)
485
513
if (resp -> hdr .status != PFVF_STATUS_SUCCESS ) {
486
514
BNX2X_ERR ("Status of SETUP_Q for queue[%d] is %d\n" ,
487
515
fp_idx , resp -> hdr .status );
488
- return - EINVAL ;
516
+ rc = - EINVAL ;
489
517
}
518
+
519
+ bnx2x_vfpf_finalize (bp , & req -> first_tlv );
520
+
490
521
return rc ;
491
522
}
492
523
@@ -514,25 +545,27 @@ int bnx2x_vfpf_teardown_queue(struct bnx2x *bp, int qidx)
514
545
if (rc ) {
515
546
BNX2X_ERR ("Sending TEARDOWN for queue %d failed: %d\n" , qidx ,
516
547
rc );
517
- return rc ;
548
+ goto out ;
518
549
}
519
550
520
551
/* PF failed the transaction */
521
552
if (resp -> hdr .status != PFVF_STATUS_SUCCESS ) {
522
553
BNX2X_ERR ("TEARDOWN for queue %d failed: %d\n" , qidx ,
523
554
resp -> hdr .status );
524
- return - EINVAL ;
555
+ rc = - EINVAL ;
525
556
}
526
557
527
- return 0 ;
558
+ out :
559
+ bnx2x_vfpf_finalize (bp , & req -> first_tlv );
560
+ return rc ;
528
561
}
529
562
530
563
/* request pf to add a mac for the vf */
531
564
int bnx2x_vfpf_set_mac (struct bnx2x * bp )
532
565
{
533
566
struct vfpf_set_q_filters_tlv * req = & bp -> vf2pf_mbox -> req .set_q_filters ;
534
567
struct pfvf_general_resp_tlv * resp = & bp -> vf2pf_mbox -> resp .general_resp ;
535
- int rc ;
568
+ int rc = 0 ;
536
569
537
570
/* clear mailbox and prep first tlv */
538
571
bnx2x_vfpf_prep (bp , & req -> first_tlv , CHANNEL_TLV_SET_Q_FILTERS ,
@@ -561,7 +594,7 @@ int bnx2x_vfpf_set_mac(struct bnx2x *bp)
561
594
rc = bnx2x_send_msg2pf (bp , & resp -> hdr .status , bp -> vf2pf_mbox_mapping );
562
595
if (rc ) {
563
596
BNX2X_ERR ("failed to send message to pf. rc was %d\n" , rc );
564
- return rc ;
597
+ goto out ;
565
598
}
566
599
567
600
/* failure may mean PF was configured with a new mac for us */
@@ -586,8 +619,10 @@ int bnx2x_vfpf_set_mac(struct bnx2x *bp)
586
619
587
620
if (resp -> hdr .status != PFVF_STATUS_SUCCESS ) {
588
621
BNX2X_ERR ("vfpf SET MAC failed: %d\n" , resp -> hdr .status );
589
- return - EINVAL ;
622
+ rc = - EINVAL ;
590
623
}
624
+ out :
625
+ bnx2x_vfpf_finalize (bp , & req -> first_tlv );
591
626
592
627
return 0 ;
593
628
}
@@ -642,14 +677,16 @@ int bnx2x_vfpf_set_mcast(struct net_device *dev)
642
677
rc = bnx2x_send_msg2pf (bp , & resp -> hdr .status , bp -> vf2pf_mbox_mapping );
643
678
if (rc ) {
644
679
BNX2X_ERR ("Sending a message failed: %d\n" , rc );
645
- return rc ;
680
+ goto out ;
646
681
}
647
682
648
683
if (resp -> hdr .status != PFVF_STATUS_SUCCESS ) {
649
684
BNX2X_ERR ("Set Rx mode/multicast failed: %d\n" ,
650
685
resp -> hdr .status );
651
- return - EINVAL ;
686
+ rc = - EINVAL ;
652
687
}
688
+ out :
689
+ bnx2x_vfpf_finalize (bp , & req -> first_tlv );
653
690
654
691
return 0 ;
655
692
}
@@ -688,7 +725,8 @@ int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp)
688
725
break ;
689
726
default :
690
727
BNX2X_ERR ("BAD rx mode (%d)\n" , mode );
691
- return - EINVAL ;
728
+ rc = - EINVAL ;
729
+ goto out ;
692
730
}
693
731
694
732
req -> flags |= VFPF_SET_Q_FILTERS_RX_MASK_CHANGED ;
@@ -707,8 +745,10 @@ int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp)
707
745
708
746
if (resp -> hdr .status != PFVF_STATUS_SUCCESS ) {
709
747
BNX2X_ERR ("Set Rx mode failed: %d\n" , resp -> hdr .status );
710
- return - EINVAL ;
748
+ rc = - EINVAL ;
711
749
}
750
+ out :
751
+ bnx2x_vfpf_finalize (bp , & req -> first_tlv );
712
752
713
753
return rc ;
714
754
}
0 commit comments