octeontx2-af: Cleanup changes
cover octeontx2-af: Cleanup changes
From: Sunil Goutham <[email protected]>
These patches cleanup AF driver by removing unnecessary function exports and cleanup repititive logic.
Sunil Goutham (3):
octeontx2-af: Remove unnecessary export symbols in CGX driver
octeontx2-af: Cleanup CGX config permission checks
octeontx2-af: Cleanup nixlf and blkaddr retrieval logic
drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 18 --- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 2 +- .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 55 ++++----- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 131 ++++++++------------- 4 files changed, 74 insertions(+), 132 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/3 octeontx2-af: Remove unnecessary export symbols in CGX driver
From: Sunil Goutham <[email protected]>
Since CGX driver and AF driver are built into a single module the export symbols in CGX driver are not needed. This patch gets rid of them.
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 18 ------------------ 1 file changed, 18 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0 -18
@@ -113,7 +113,6 @@ int cgx_get_cgxcnt_max(void)return idmax +1 ; } -EXPORT_SYMBOL (cgx_get_cgxcnt_max);int cgx_get_lmac_cnt (void *cgxd) {
@@ -124,7 +123,6 @@ int cgx_get_lmac_cnt(void *cgxd)return cgx->lmac_count; } -EXPORT_SYMBOL (cgx_get_lmac_cnt);void *cgx_get_pdata (int cgx_id) {
@@ -136,7 +134,6 @@ void *cgx_get_pdata(int cgx_id) }return NULL ; } -EXPORT_SYMBOL (cgx_get_pdata);int cgx_get_cgxid (void *cgxd) {
@@ -164,7 +161,6 @@ int cgx_get_link_info(void *cgxd, int lmac_id, *linfo = lmac->link_info;return 0 ; } -EXPORT_SYMBOL (cgx_get_link_info);static u64 mac2u64 (u8 *mac_addr) {
@@ -195,7 +191,6 @@ int cgx_lmac_addr_set(u8 cgx_id, u8 lmac_id, u8 *mac_addr)return 0 ; } -EXPORT_SYMBOL (cgx_lmac_addr_set);u64 cgx_lmac_addr_get (u8 cgx_id,u8 lmac_id) {
@@ -205,7 +200,6 @@ u64 cgx_lmac_addr_get(u8 cgx_id, u8 lmac_id) cfg =cgx_read (cgx_dev,0 ,CGXX_CMRX_RX_DMAC_CAM0 + lmac_id *0x8 );return cfg &CGX_RX_DMAC_ADR_MASK ; } -EXPORT_SYMBOL (cgx_lmac_addr_get);int cgx_set_pkind (void *cgxd,u8 lmac_id,int pkind) {
@@ -217,7 +211,6 @@ int cgx_set_pkind(void *cgxd, u8 lmac_id, int pkind)cgx_write (cgx, lmac_id,CGXX_CMRX_RX_ID_MAP , (pkind &0x3F ));return 0 ; } -EXPORT_SYMBOL (cgx_set_pkind);static inline u8 cgx_get_lmac_type (struct cgx *cgx,int lmac_id) {
@@ -255,7 +248,6 @@ int cgx_lmac_internal_loopback(void *cgxd, int lmac_id, bool enable) }return 0 ; } -EXPORT_SYMBOL (cgx_lmac_internal_loopback);void cgx_lmac_promisc_config (int cgx_id,int lmac_id,bool enable) {
@@ -289,7 +281,6 @@ void cgx_lmac_promisc_config(int cgx_id, int lmac_id, bool enable) (CGXX_CMRX_RX_DMAC_CAM0 + lmac_id * 0x8), cfg); } } -EXPORT_SYMBOL (cgx_lmac_promisc_config);/* Enable or disable forwarding received pause frames to Tx block */ 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)cgx_write (cgx, lmac_id,CGXX_SMUX_RX_FRM_CTL , cfg); } } -EXPORT_SYMBOL (cgx_lmac_enadis_rx_pause_fwding);int cgx_get_rx_stats (void *cgxd,int lmac_id,int idx,u64 *rx_stat) {
@@ -329,7 +319,6 @@ int cgx_get_rx_stats(void *cgxd, int lmac_id, int idx, u64 *rx_stat) *rx_stat =cgx_read (cgx, lmac_id,CGXX_CMRX_RX_STAT0 + (idx *8 ));return 0 ; } -EXPORT_SYMBOL (cgx_get_rx_stats);int cgx_get_tx_stats (void *cgxd,int lmac_id,int idx,u64 *tx_stat) {
@@ -340,7 +329,6 @@ int cgx_get_tx_stats(void *cgxd, int lmac_id, int idx, u64 *tx_stat) *tx_stat =cgx_read (cgx, lmac_id,CGXX_CMRX_TX_STAT0 + (idx *8 ));return 0 ; } -EXPORT_SYMBOL (cgx_get_tx_stats);int cgx_lmac_rx_tx_enable (void *cgxd,int lmac_id,bool enable) {
@@ -358,7 +346,6 @@ int cgx_lmac_rx_tx_enable(void *cgxd, int lmac_id, bool enable)cgx_write (cgx, lmac_id,CGXX_CMRX_CFG , cfg);return 0 ; } -EXPORT_SYMBOL (cgx_lmac_rx_tx_enable);int cgx_lmac_tx_enable (void *cgxd,int lmac_id,bool enable) {
@@ -379,7 +366,6 @@ int cgx_lmac_tx_enable(void *cgxd, int lmac_id, bool enable)cgx_write (cgx, lmac_id,CGXX_CMRX_CFG , cfg);return !!(last &DATA_PKT_TX_EN ); } -EXPORT_SYMBOL (cgx_lmac_tx_enable);/* CGX Firmware interface low level support */ 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)return 0 ; } -EXPORT_SYMBOL (cgx_get_mkex_prfl_info);static irqreturn_t cgx_fwi_event_handler (int irq,void *data) {
@@ -676,7 +661,6 @@ int cgx_lmac_evh_register(struct cgx_event_cb *cb, void *cgxd, int lmac_id)return 0 ; } -EXPORT_SYMBOL (cgx_lmac_evh_register);int cgx_lmac_evh_unregister (void *cgxd,int lmac_id) {
@@ -695,7 +679,6 @@ int cgx_lmac_evh_unregister(void *cgxd, int lmac_id)return 0 ; } -EXPORT_SYMBOL (cgx_lmac_evh_unregister);static int cgx_fwi_link_change (struct cgx *cgx,int lmac_id,bool enable) {
@@ -769,7 +752,6 @@ int cgx_lmac_linkup_start(void *cgxd)return 0 ; } -EXPORT_SYMBOL (cgx_lmac_linkup_start);static int cgx_lmac_init (struct cgx *cgx) {
Signature · 1 line
2.7.4
PATCH 2/3 octeontx2-af: Cleanup CGX config permission checks
In reply to [email protected]From: Sunil Goutham <[email protected]>
Most of the CGX register config is restricted to mapped RVU PFs, this patch cleans up these permission checks spread across the rvu_cgx.c file by moving the checks to a common fn().
--- .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 55 ++++++++++------------ 1 file changed, 24 insertions(+), 31 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +24 -31
@@ -350,6 +350,18 @@ int rvu_cgx_exit(struct rvu *rvu)return 0 ; } +/* Most of the CGX configuration is restricted to the mapped PF only, +* VF's of mapped PF and other PFs are not allowed. This fn() checks +* whether a PFFUNC is permitted to do the config or not. +*/ +static bool is_cgx_config_permitted (struct rvu *rvu,u16 pcifunc) +{ +if ((pcifunc &RVU_PFVF_FUNC_MASK ) || + !is_pf_cgxmapped (rvu,rvu_get_pf (pcifunc))) +return false; +return true; +} +void rvu_cgx_enadis_rx_bp (struct rvu *rvu,int pf,bool enable) {u8 cgx_id, lmac_id;
@@ -373,11 +385,8 @@ int rvu_cgx_config_rxtx(struct rvu *rvu, u16 pcifunc, bool start)int pf =rvu_get_pf (pcifunc);u8 cgx_id, lmac_id; -/* This msg is expected only from PFs that are mapped to CGX LMACs, -* if received from other PF/VF simply ACK, nothing to do. -*/ -if ((pcifunc &RVU_PFVF_FUNC_MASK ) || !is_pf_cgxmapped (rvu, pf)) -return -ENODEV ; +if (!is_cgx_config_permitted (rvu, pcifunc)) +return -EPERM ;rvu_get_cgx_lmac_id (rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
@@ -409,8 +418,7 @@ int rvu_mbox_handler_cgx_stats(struct rvu *rvu, struct msg_req *req,u8 cgx_idx, lmac;void *cgxd; -if ((req->hdr.pcifunc &RVU_PFVF_FUNC_MASK ) || - !is_pf_cgxmapped (rvu, pf)) +if (!is_cgx_config_permitted (rvu, req->hdr.pcifunc))return -ENODEV ;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,int pf =rvu_get_pf (pcifunc);u8 cgx_id, lmac_id; -/* This msg is expected only from PFs that are mapped to CGX LMACs, -* if received from other PF/VF simply ACK, nothing to do. -*/ -if ((req->hdr.pcifunc &RVU_PFVF_FUNC_MASK ) || - !is_pf_cgxmapped (rvu, pf)) -return -ENODEV ; +if (!is_cgx_config_permitted (rvu, req->hdr.pcifunc)) +return -EPERM ;rvu_get_cgx_lmac_id (rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
@@ -493,16 +497,11 @@ int rvu_mbox_handler_cgx_promisc_enable(struct rvu *rvu, struct msg_req *req,int rvu_mbox_handler_cgx_promisc_disable (struct rvu *rvu,struct msg_req *req,struct msg_rsp *rsp) { -u16 pcifunc = req->hdr.pcifunc; -int pf =rvu_get_pf (pcifunc); +int pf =rvu_get_pf (req->hdr.pcifunc);u8 cgx_id, lmac_id; -/* This msg is expected only from PFs that are mapped to CGX LMACs, -* if received from other PF/VF simply ACK, nothing to do. -*/ -if ((req->hdr.pcifunc &RVU_PFVF_FUNC_MASK ) || - !is_pf_cgxmapped (rvu, pf)) -return -ENODEV ; +if (!is_cgx_config_permitted (rvu, req->hdr.pcifunc)) +return -EPERM ;rvu_get_cgx_lmac_id (rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
@@ -515,11 +514,8 @@ static int rvu_cgx_config_linkevents(struct rvu *rvu, u16 pcifunc, bool en)int pf =rvu_get_pf (pcifunc);u8 cgx_id, lmac_id; -/* This msg is expected only from PFs that are mapped to CGX LMACs, -* if received from other PF/VF simply ACK, nothing to do. -*/ -if ((pcifunc &RVU_PFVF_FUNC_MASK ) || !is_pf_cgxmapped (rvu, pf)) -return -ENODEV ; +if (!is_cgx_config_permitted (rvu, pcifunc)) +return -EPERM ;rvu_get_cgx_lmac_id (rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
@@ -571,11 +567,8 @@ static int rvu_cgx_config_intlbk(struct rvu *rvu, u16 pcifunc, bool en)int pf =rvu_get_pf (pcifunc);u8 cgx_id, lmac_id; -/* This msg is expected only from PFs that are mapped to CGX LMACs, -* if received from other PF/VF simply ACK, nothing to do. -*/ -if ((pcifunc &RVU_PFVF_FUNC_MASK ) || !is_pf_cgxmapped (rvu, pf)) -return -ENODEV ; +if (!is_cgx_config_permitted (rvu, pcifunc)) +return -EPERM ;rvu_get_cgx_lmac_id (rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
Signature · 1 line
2.7.4
PATCH 3/3 octeontx2-af: Cleanup nixlf and blkaddr retrieval logic
In reply to [email protected]From: Sunil Goutham <[email protected]>
Cleanedup repititive nixlf and blkaddr retrieving logic is various mailbox handlers throughout the rvu_nix.c file.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 2 +- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 131 ++++++++------------- 2 files changed, 50 insertions(+), 83 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +1 -1
@@ -432,7 +432,7 @@ int rvu_nix_reserve_mark_format(struct rvu *rvu, struct nix_hw *nix_hw,void rvu_nix_freemem (struct rvu *rvu);int rvu_get_nixlf_count (struct rvu *rvu);void rvu_nix_lf_teardown (struct rvu *rvu,u16 pcifunc,int blkaddr,int npalf); -int nix_get_nixlf (struct rvu *rvu,u16 pcifunc,int *nixlf); +int nix_get_nixlf (struct rvu *rvu,u16 pcifunc,int *nixlf,int *nix_blkaddr);/* NPC APIs */ int rvu_npc_init (struct rvu *rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +49 -82
218 lines not on this page · raw message
Signature · 1 line
2.7.4
David Miller
maintainerFrom: [email protected]
Date: Wed, 19 Feb 2020 15:21:05 +0530
Quoted 4 lines
From: Sunil Goutham <[email protected]>
These patches cleanup AF driver by removing unnecessary function exports and cleanup repititive logic.
Series applied, thanks.