@@ -350,6 +350,18 @@ int rvu_cgx_exit(struct rvu *rvu)
350
350
return 0 ;
351
351
}
352
352
353
+ /* Most of the CGX configuration is restricted to the mapped PF only,
354
+ * VF's of mapped PF and other PFs are not allowed. This fn() checks
355
+ * whether a PFFUNC is permitted to do the config or not.
356
+ */
357
+ static bool is_cgx_config_permitted (struct rvu * rvu , u16 pcifunc )
358
+ {
359
+ if ((pcifunc & RVU_PFVF_FUNC_MASK ) ||
360
+ !is_pf_cgxmapped (rvu , rvu_get_pf (pcifunc )))
361
+ return false;
362
+ return true;
363
+ }
364
+
353
365
void rvu_cgx_enadis_rx_bp (struct rvu * rvu , int pf , bool enable )
354
366
{
355
367
u8 cgx_id , lmac_id ;
@@ -373,11 +385,8 @@ int rvu_cgx_config_rxtx(struct rvu *rvu, u16 pcifunc, bool start)
373
385
int pf = rvu_get_pf (pcifunc );
374
386
u8 cgx_id , lmac_id ;
375
387
376
- /* This msg is expected only from PFs that are mapped to CGX LMACs,
377
- * if received from other PF/VF simply ACK, nothing to do.
378
- */
379
- if ((pcifunc & RVU_PFVF_FUNC_MASK ) || !is_pf_cgxmapped (rvu , pf ))
380
- return - ENODEV ;
388
+ if (!is_cgx_config_permitted (rvu , pcifunc ))
389
+ return - EPERM ;
381
390
382
391
rvu_get_cgx_lmac_id (rvu -> pf2cgxlmac_map [pf ], & cgx_id , & lmac_id );
383
392
@@ -409,8 +418,7 @@ int rvu_mbox_handler_cgx_stats(struct rvu *rvu, struct msg_req *req,
409
418
u8 cgx_idx , lmac ;
410
419
void * cgxd ;
411
420
412
- if ((req -> hdr .pcifunc & RVU_PFVF_FUNC_MASK ) ||
413
- !is_pf_cgxmapped (rvu , pf ))
421
+ if (!is_cgx_config_permitted (rvu , req -> hdr .pcifunc ))
414
422
return - ENODEV ;
415
423
416
424
rvu_get_cgx_lmac_id (rvu -> pf2cgxlmac_map [pf ], & cgx_idx , & lmac );
@@ -477,12 +485,8 @@ int rvu_mbox_handler_cgx_promisc_enable(struct rvu *rvu, struct msg_req *req,
477
485
int pf = rvu_get_pf (pcifunc );
478
486
u8 cgx_id , lmac_id ;
479
487
480
- /* This msg is expected only from PFs that are mapped to CGX LMACs,
481
- * if received from other PF/VF simply ACK, nothing to do.
482
- */
483
- if ((req -> hdr .pcifunc & RVU_PFVF_FUNC_MASK ) ||
484
- !is_pf_cgxmapped (rvu , pf ))
485
- return - ENODEV ;
488
+ if (!is_cgx_config_permitted (rvu , req -> hdr .pcifunc ))
489
+ return - EPERM ;
486
490
487
491
rvu_get_cgx_lmac_id (rvu -> pf2cgxlmac_map [pf ], & cgx_id , & lmac_id );
488
492
@@ -493,16 +497,11 @@ int rvu_mbox_handler_cgx_promisc_enable(struct rvu *rvu, struct msg_req *req,
493
497
int rvu_mbox_handler_cgx_promisc_disable (struct rvu * rvu , struct msg_req * req ,
494
498
struct msg_rsp * rsp )
495
499
{
496
- u16 pcifunc = req -> hdr .pcifunc ;
497
- int pf = rvu_get_pf (pcifunc );
500
+ int pf = rvu_get_pf (req -> hdr .pcifunc );
498
501
u8 cgx_id , lmac_id ;
499
502
500
- /* This msg is expected only from PFs that are mapped to CGX LMACs,
501
- * if received from other PF/VF simply ACK, nothing to do.
502
- */
503
- if ((req -> hdr .pcifunc & RVU_PFVF_FUNC_MASK ) ||
504
- !is_pf_cgxmapped (rvu , pf ))
505
- return - ENODEV ;
503
+ if (!is_cgx_config_permitted (rvu , req -> hdr .pcifunc ))
504
+ return - EPERM ;
506
505
507
506
rvu_get_cgx_lmac_id (rvu -> pf2cgxlmac_map [pf ], & cgx_id , & lmac_id );
508
507
@@ -515,11 +514,8 @@ static int rvu_cgx_config_linkevents(struct rvu *rvu, u16 pcifunc, bool en)
515
514
int pf = rvu_get_pf (pcifunc );
516
515
u8 cgx_id , lmac_id ;
517
516
518
- /* This msg is expected only from PFs that are mapped to CGX LMACs,
519
- * if received from other PF/VF simply ACK, nothing to do.
520
- */
521
- if ((pcifunc & RVU_PFVF_FUNC_MASK ) || !is_pf_cgxmapped (rvu , pf ))
522
- return - ENODEV ;
517
+ if (!is_cgx_config_permitted (rvu , pcifunc ))
518
+ return - EPERM ;
523
519
524
520
rvu_get_cgx_lmac_id (rvu -> pf2cgxlmac_map [pf ], & cgx_id , & lmac_id );
525
521
@@ -571,11 +567,8 @@ static int rvu_cgx_config_intlbk(struct rvu *rvu, u16 pcifunc, bool en)
571
567
int pf = rvu_get_pf (pcifunc );
572
568
u8 cgx_id , lmac_id ;
573
569
574
- /* This msg is expected only from PFs that are mapped to CGX LMACs,
575
- * if received from other PF/VF simply ACK, nothing to do.
576
- */
577
- if ((pcifunc & RVU_PFVF_FUNC_MASK ) || !is_pf_cgxmapped (rvu , pf ))
578
- return - ENODEV ;
570
+ if (!is_cgx_config_permitted (rvu , pcifunc ))
571
+ return - EPERM ;
579
572
580
573
rvu_get_cgx_lmac_id (rvu -> pf2cgxlmac_map [pf ], & cgx_id , & lmac_id );
581
574
0 commit comments