Skip to content

Commit c3d5e56

Browse files
committed
Merge branch 'octeontx2-af-Cleanup-changes'
Sunil Goutham says: ==================== octeontx2-af: Cleanup changes These patches cleanup AF driver by removing unnecessary function exports and cleanup repititive logic. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents d631f96 + 52ccbda commit c3d5e56

File tree

4 files changed

+74
-132
lines changed

4 files changed

+74
-132
lines changed

drivers/net/ethernet/marvell/octeontx2/af/cgx.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ int cgx_get_cgxcnt_max(void)
113113

114114
return idmax + 1;
115115
}
116-
EXPORT_SYMBOL(cgx_get_cgxcnt_max);
117116

118117
int cgx_get_lmac_cnt(void *cgxd)
119118
{
@@ -124,7 +123,6 @@ int cgx_get_lmac_cnt(void *cgxd)
124123

125124
return cgx->lmac_count;
126125
}
127-
EXPORT_SYMBOL(cgx_get_lmac_cnt);
128126

129127
void *cgx_get_pdata(int cgx_id)
130128
{
@@ -136,7 +134,6 @@ void *cgx_get_pdata(int cgx_id)
136134
}
137135
return NULL;
138136
}
139-
EXPORT_SYMBOL(cgx_get_pdata);
140137

141138
int cgx_get_cgxid(void *cgxd)
142139
{
@@ -164,7 +161,6 @@ int cgx_get_link_info(void *cgxd, int lmac_id,
164161
*linfo = lmac->link_info;
165162
return 0;
166163
}
167-
EXPORT_SYMBOL(cgx_get_link_info);
168164

169165
static u64 mac2u64 (u8 *mac_addr)
170166
{
@@ -195,7 +191,6 @@ int cgx_lmac_addr_set(u8 cgx_id, u8 lmac_id, u8 *mac_addr)
195191

196192
return 0;
197193
}
198-
EXPORT_SYMBOL(cgx_lmac_addr_set);
199194

200195
u64 cgx_lmac_addr_get(u8 cgx_id, u8 lmac_id)
201196
{
@@ -205,7 +200,6 @@ u64 cgx_lmac_addr_get(u8 cgx_id, u8 lmac_id)
205200
cfg = cgx_read(cgx_dev, 0, CGXX_CMRX_RX_DMAC_CAM0 + lmac_id * 0x8);
206201
return cfg & CGX_RX_DMAC_ADR_MASK;
207202
}
208-
EXPORT_SYMBOL(cgx_lmac_addr_get);
209203

210204
int cgx_set_pkind(void *cgxd, u8 lmac_id, int pkind)
211205
{
@@ -217,7 +211,6 @@ int cgx_set_pkind(void *cgxd, u8 lmac_id, int pkind)
217211
cgx_write(cgx, lmac_id, CGXX_CMRX_RX_ID_MAP, (pkind & 0x3F));
218212
return 0;
219213
}
220-
EXPORT_SYMBOL(cgx_set_pkind);
221214

222215
static inline u8 cgx_get_lmac_type(struct cgx *cgx, int lmac_id)
223216
{
@@ -255,7 +248,6 @@ int cgx_lmac_internal_loopback(void *cgxd, int lmac_id, bool enable)
255248
}
256249
return 0;
257250
}
258-
EXPORT_SYMBOL(cgx_lmac_internal_loopback);
259251

260252
void cgx_lmac_promisc_config(int cgx_id, int lmac_id, bool enable)
261253
{
@@ -289,7 +281,6 @@ void cgx_lmac_promisc_config(int cgx_id, int lmac_id, bool enable)
289281
(CGXX_CMRX_RX_DMAC_CAM0 + lmac_id * 0x8), cfg);
290282
}
291283
}
292-
EXPORT_SYMBOL(cgx_lmac_promisc_config);
293284

294285
/* Enable or disable forwarding received pause frames to Tx block */
295286
void cgx_lmac_enadis_rx_pause_fwding(void *cgxd, int lmac_id, bool enable)
@@ -318,7 +309,6 @@ void cgx_lmac_enadis_rx_pause_fwding(void *cgxd, int lmac_id, bool enable)
318309
cgx_write(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL, cfg);
319310
}
320311
}
321-
EXPORT_SYMBOL(cgx_lmac_enadis_rx_pause_fwding);
322312

323313
int cgx_get_rx_stats(void *cgxd, int lmac_id, int idx, u64 *rx_stat)
324314
{
@@ -329,7 +319,6 @@ int cgx_get_rx_stats(void *cgxd, int lmac_id, int idx, u64 *rx_stat)
329319
*rx_stat = cgx_read(cgx, lmac_id, CGXX_CMRX_RX_STAT0 + (idx * 8));
330320
return 0;
331321
}
332-
EXPORT_SYMBOL(cgx_get_rx_stats);
333322

334323
int cgx_get_tx_stats(void *cgxd, int lmac_id, int idx, u64 *tx_stat)
335324
{
@@ -340,7 +329,6 @@ int cgx_get_tx_stats(void *cgxd, int lmac_id, int idx, u64 *tx_stat)
340329
*tx_stat = cgx_read(cgx, lmac_id, CGXX_CMRX_TX_STAT0 + (idx * 8));
341330
return 0;
342331
}
343-
EXPORT_SYMBOL(cgx_get_tx_stats);
344332

345333
int cgx_lmac_rx_tx_enable(void *cgxd, int lmac_id, bool enable)
346334
{
@@ -358,7 +346,6 @@ int cgx_lmac_rx_tx_enable(void *cgxd, int lmac_id, bool enable)
358346
cgx_write(cgx, lmac_id, CGXX_CMRX_CFG, cfg);
359347
return 0;
360348
}
361-
EXPORT_SYMBOL(cgx_lmac_rx_tx_enable);
362349

363350
int cgx_lmac_tx_enable(void *cgxd, int lmac_id, bool enable)
364351
{
@@ -379,7 +366,6 @@ int cgx_lmac_tx_enable(void *cgxd, int lmac_id, bool enable)
379366
cgx_write(cgx, lmac_id, CGXX_CMRX_CFG, cfg);
380367
return !!(last & DATA_PKT_TX_EN);
381368
}
382-
EXPORT_SYMBOL(cgx_lmac_tx_enable);
383369

384370
/* CGX Firmware interface low level support */
385371
static int cgx_fwi_cmd_send(u64 req, u64 *resp, struct lmac *lmac)
@@ -610,7 +596,6 @@ int cgx_get_mkex_prfl_info(u64 *addr, u64 *size)
610596

611597
return 0;
612598
}
613-
EXPORT_SYMBOL(cgx_get_mkex_prfl_info);
614599

615600
static irqreturn_t cgx_fwi_event_handler(int irq, void *data)
616601
{
@@ -676,7 +661,6 @@ int cgx_lmac_evh_register(struct cgx_event_cb *cb, void *cgxd, int lmac_id)
676661

677662
return 0;
678663
}
679-
EXPORT_SYMBOL(cgx_lmac_evh_register);
680664

681665
int cgx_lmac_evh_unregister(void *cgxd, int lmac_id)
682666
{
@@ -695,7 +679,6 @@ int cgx_lmac_evh_unregister(void *cgxd, int lmac_id)
695679

696680
return 0;
697681
}
698-
EXPORT_SYMBOL(cgx_lmac_evh_unregister);
699682

700683
static int cgx_fwi_link_change(struct cgx *cgx, int lmac_id, bool enable)
701684
{
@@ -769,7 +752,6 @@ int cgx_lmac_linkup_start(void *cgxd)
769752

770753
return 0;
771754
}
772-
EXPORT_SYMBOL(cgx_lmac_linkup_start);
773755

774756
static int cgx_lmac_init(struct cgx *cgx)
775757
{

drivers/net/ethernet/marvell/octeontx2/af/rvu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ int rvu_nix_reserve_mark_format(struct rvu *rvu, struct nix_hw *nix_hw,
432432
void rvu_nix_freemem(struct rvu *rvu);
433433
int rvu_get_nixlf_count(struct rvu *rvu);
434434
void rvu_nix_lf_teardown(struct rvu *rvu, u16 pcifunc, int blkaddr, int npalf);
435-
int nix_get_nixlf(struct rvu *rvu, u16 pcifunc, int *nixlf);
435+
int nix_get_nixlf(struct rvu *rvu, u16 pcifunc, int *nixlf, int *nix_blkaddr);
436436

437437
/* NPC APIs */
438438
int rvu_npc_init(struct rvu *rvu);

drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,18 @@ int rvu_cgx_exit(struct rvu *rvu)
350350
return 0;
351351
}
352352

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+
353365
void rvu_cgx_enadis_rx_bp(struct rvu *rvu, int pf, bool enable)
354366
{
355367
u8 cgx_id, lmac_id;
@@ -373,11 +385,8 @@ int rvu_cgx_config_rxtx(struct rvu *rvu, u16 pcifunc, bool start)
373385
int pf = rvu_get_pf(pcifunc);
374386
u8 cgx_id, lmac_id;
375387

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;
381390

382391
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
383392

@@ -409,8 +418,7 @@ int rvu_mbox_handler_cgx_stats(struct rvu *rvu, struct msg_req *req,
409418
u8 cgx_idx, lmac;
410419
void *cgxd;
411420

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))
414422
return -ENODEV;
415423

416424
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,
477485
int pf = rvu_get_pf(pcifunc);
478486
u8 cgx_id, lmac_id;
479487

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;
486490

487491
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
488492

@@ -493,16 +497,11 @@ int rvu_mbox_handler_cgx_promisc_enable(struct rvu *rvu, struct msg_req *req,
493497
int rvu_mbox_handler_cgx_promisc_disable(struct rvu *rvu, struct msg_req *req,
494498
struct msg_rsp *rsp)
495499
{
496-
u16 pcifunc = req->hdr.pcifunc;
497-
int pf = rvu_get_pf(pcifunc);
500+
int pf = rvu_get_pf(req->hdr.pcifunc);
498501
u8 cgx_id, lmac_id;
499502

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;
506505

507506
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
508507

@@ -515,11 +514,8 @@ static int rvu_cgx_config_linkevents(struct rvu *rvu, u16 pcifunc, bool en)
515514
int pf = rvu_get_pf(pcifunc);
516515
u8 cgx_id, lmac_id;
517516

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;
523519

524520
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
525521

@@ -571,11 +567,8 @@ static int rvu_cgx_config_intlbk(struct rvu *rvu, u16 pcifunc, bool en)
571567
int pf = rvu_get_pf(pcifunc);
572568
u8 cgx_id, lmac_id;
573569

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;
579572

580573
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
581574

0 commit comments

Comments
 (0)