Commit 52ccbdac authored by Sunil Goutham's avatar Sunil Goutham Committed by David S. Miller

octeontx2-af: Cleanup nixlf and blkaddr retrieval logic

Cleanedup repititive nixlf and blkaddr retrieving logic
is various mailbox handlers throughout the rvu_nix.c file.
Signed-off-by: default avatarSunil Goutham <sgoutham@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6fd2a71b
...@@ -432,7 +432,7 @@ int rvu_nix_reserve_mark_format(struct rvu *rvu, struct nix_hw *nix_hw, ...@@ -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); void rvu_nix_freemem(struct rvu *rvu);
int rvu_get_nixlf_count(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); 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 */ /* NPC APIs */
int rvu_npc_init(struct rvu *rvu); int rvu_npc_init(struct rvu *rvu);
......
...@@ -90,6 +90,26 @@ int rvu_get_nixlf_count(struct rvu *rvu) ...@@ -90,6 +90,26 @@ int rvu_get_nixlf_count(struct rvu *rvu)
return block->lf.max; return block->lf.max;
} }
int nix_get_nixlf(struct rvu *rvu, u16 pcifunc, int *nixlf, int *nix_blkaddr)
{
struct rvu_pfvf *pfvf = rvu_get_pfvf(rvu, pcifunc);
struct rvu_hwinfo *hw = rvu->hw;
int blkaddr;
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc);
if (!pfvf->nixlf || blkaddr < 0)
return NIX_AF_ERR_AF_LF_INVALID;
*nixlf = rvu_get_lf(rvu, &hw->block[blkaddr], pcifunc, 0);
if (*nixlf < 0)
return NIX_AF_ERR_AF_LF_INVALID;
if (nix_blkaddr)
*nix_blkaddr = blkaddr;
return 0;
}
static void nix_mce_list_init(struct nix_mce_list *list, int max) static void nix_mce_list_init(struct nix_mce_list *list, int max)
{ {
INIT_HLIST_HEAD(&list->head); INIT_HLIST_HEAD(&list->head);
...@@ -1667,13 +1687,9 @@ int rvu_mbox_handler_nix_txschq_cfg(struct rvu *rvu, ...@@ -1667,13 +1687,9 @@ int rvu_mbox_handler_nix_txschq_cfg(struct rvu *rvu,
req->num_regs > MAX_REGS_PER_MBOX_MSG) req->num_regs > MAX_REGS_PER_MBOX_MSG)
return NIX_AF_INVAL_TXSCHQ_CFG; return NIX_AF_INVAL_TXSCHQ_CFG;
err = nix_get_nixlf(rvu, pcifunc, &nixlf); err = nix_get_nixlf(rvu, pcifunc, &nixlf, &blkaddr);
if (err) if (err)
return NIX_AF_ERR_AF_LF_INVALID; return err;
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc);
if (blkaddr < 0)
return NIX_AF_ERR_AF_LF_INVALID;
nix_hw = get_nix_hw(rvu->hw, blkaddr); nix_hw = get_nix_hw(rvu->hw, blkaddr);
if (!nix_hw) if (!nix_hw)
...@@ -1767,17 +1783,12 @@ int rvu_mbox_handler_nix_vtag_cfg(struct rvu *rvu, ...@@ -1767,17 +1783,12 @@ int rvu_mbox_handler_nix_vtag_cfg(struct rvu *rvu,
struct nix_vtag_config *req, struct nix_vtag_config *req,
struct msg_rsp *rsp) struct msg_rsp *rsp)
{ {
struct rvu_hwinfo *hw = rvu->hw;
u16 pcifunc = req->hdr.pcifunc; u16 pcifunc = req->hdr.pcifunc;
int blkaddr, nixlf, err; int blkaddr, nixlf, err;
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc); err = nix_get_nixlf(rvu, pcifunc, &nixlf, &blkaddr);
if (blkaddr < 0) if (err)
return NIX_AF_ERR_AF_LF_INVALID; return err;
nixlf = rvu_get_lf(rvu, &hw->block[blkaddr], pcifunc, 0);
if (nixlf < 0)
return NIX_AF_ERR_AF_LF_INVALID;
if (req->cfg_type) { if (req->cfg_type) {
err = nix_rx_vtag_cfg(rvu, nixlf, blkaddr, req); err = nix_rx_vtag_cfg(rvu, nixlf, blkaddr, req);
...@@ -2119,18 +2130,13 @@ static int nix_af_mark_format_setup(struct rvu *rvu, struct nix_hw *nix_hw, ...@@ -2119,18 +2130,13 @@ static int nix_af_mark_format_setup(struct rvu *rvu, struct nix_hw *nix_hw,
int rvu_mbox_handler_nix_stats_rst(struct rvu *rvu, struct msg_req *req, int rvu_mbox_handler_nix_stats_rst(struct rvu *rvu, struct msg_req *req,
struct msg_rsp *rsp) struct msg_rsp *rsp)
{ {
struct rvu_hwinfo *hw = rvu->hw;
u16 pcifunc = req->hdr.pcifunc; u16 pcifunc = req->hdr.pcifunc;
int i, nixlf, blkaddr; int i, nixlf, blkaddr, err;
u64 stats; u64 stats;
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc); err = nix_get_nixlf(rvu, pcifunc, &nixlf, &blkaddr);
if (blkaddr < 0) if (err)
return NIX_AF_ERR_AF_LF_INVALID; return err;
nixlf = rvu_get_lf(rvu, &hw->block[blkaddr], pcifunc, 0);
if (nixlf < 0)
return NIX_AF_ERR_AF_LF_INVALID;
/* Get stats count supported by HW */ /* Get stats count supported by HW */
stats = rvu_read64(rvu, blkaddr, NIX_AF_CONST1); stats = rvu_read64(rvu, blkaddr, NIX_AF_CONST1);
...@@ -2418,18 +2424,14 @@ int rvu_mbox_handler_nix_rss_flowkey_cfg(struct rvu *rvu, ...@@ -2418,18 +2424,14 @@ int rvu_mbox_handler_nix_rss_flowkey_cfg(struct rvu *rvu,
struct nix_rss_flowkey_cfg *req, struct nix_rss_flowkey_cfg *req,
struct nix_rss_flowkey_cfg_rsp *rsp) struct nix_rss_flowkey_cfg_rsp *rsp)
{ {
struct rvu_hwinfo *hw = rvu->hw;
u16 pcifunc = req->hdr.pcifunc; u16 pcifunc = req->hdr.pcifunc;
int alg_idx, nixlf, blkaddr; int alg_idx, nixlf, blkaddr;
struct nix_hw *nix_hw; struct nix_hw *nix_hw;
int err;
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc); err = nix_get_nixlf(rvu, pcifunc, &nixlf, &blkaddr);
if (blkaddr < 0) if (err)
return NIX_AF_ERR_AF_LF_INVALID; return err;
nixlf = rvu_get_lf(rvu, &hw->block[blkaddr], pcifunc, 0);
if (nixlf < 0)
return NIX_AF_ERR_AF_LF_INVALID;
nix_hw = get_nix_hw(rvu->hw, blkaddr); nix_hw = get_nix_hw(rvu->hw, blkaddr);
if (!nix_hw) if (!nix_hw)
...@@ -2522,19 +2524,15 @@ int rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu, ...@@ -2522,19 +2524,15 @@ int rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu,
struct nix_set_mac_addr *req, struct nix_set_mac_addr *req,
struct msg_rsp *rsp) struct msg_rsp *rsp)
{ {
struct rvu_hwinfo *hw = rvu->hw;
u16 pcifunc = req->hdr.pcifunc; u16 pcifunc = req->hdr.pcifunc;
int blkaddr, nixlf, err;
struct rvu_pfvf *pfvf; struct rvu_pfvf *pfvf;
int blkaddr, nixlf;
pfvf = rvu_get_pfvf(rvu, pcifunc); err = nix_get_nixlf(rvu, pcifunc, &nixlf, &blkaddr);
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc); if (err)
if (!pfvf->nixlf || blkaddr < 0) return err;
return NIX_AF_ERR_AF_LF_INVALID;
nixlf = rvu_get_lf(rvu, &hw->block[blkaddr], pcifunc, 0); pfvf = rvu_get_pfvf(rvu, pcifunc);
if (nixlf < 0)
return NIX_AF_ERR_AF_LF_INVALID;
ether_addr_copy(pfvf->mac_addr, req->mac_addr); ether_addr_copy(pfvf->mac_addr, req->mac_addr);
...@@ -2567,19 +2565,15 @@ int rvu_mbox_handler_nix_set_rx_mode(struct rvu *rvu, struct nix_rx_mode *req, ...@@ -2567,19 +2565,15 @@ int rvu_mbox_handler_nix_set_rx_mode(struct rvu *rvu, struct nix_rx_mode *req,
struct msg_rsp *rsp) struct msg_rsp *rsp)
{ {
bool allmulti = false, disable_promisc = false; bool allmulti = false, disable_promisc = false;
struct rvu_hwinfo *hw = rvu->hw;
u16 pcifunc = req->hdr.pcifunc; u16 pcifunc = req->hdr.pcifunc;
int blkaddr, nixlf, err;
struct rvu_pfvf *pfvf; struct rvu_pfvf *pfvf;
int blkaddr, nixlf;
pfvf = rvu_get_pfvf(rvu, pcifunc); err = nix_get_nixlf(rvu, pcifunc, &nixlf, &blkaddr);
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc); if (err)
if (!pfvf->nixlf || blkaddr < 0) return err;
return NIX_AF_ERR_AF_LF_INVALID;
nixlf = rvu_get_lf(rvu, &hw->block[blkaddr], pcifunc, 0); pfvf = rvu_get_pfvf(rvu, pcifunc);
if (nixlf < 0)
return NIX_AF_ERR_AF_LF_INVALID;
if (req->mode & NIX_RX_MODE_PROMISC) if (req->mode & NIX_RX_MODE_PROMISC)
allmulti = false; allmulti = false;
...@@ -2794,22 +2788,12 @@ int rvu_mbox_handler_nix_rxvlan_alloc(struct rvu *rvu, struct msg_req *req, ...@@ -2794,22 +2788,12 @@ int rvu_mbox_handler_nix_rxvlan_alloc(struct rvu *rvu, struct msg_req *req,
int rvu_mbox_handler_nix_set_rx_cfg(struct rvu *rvu, struct nix_rx_cfg *req, int rvu_mbox_handler_nix_set_rx_cfg(struct rvu *rvu, struct nix_rx_cfg *req,
struct msg_rsp *rsp) struct msg_rsp *rsp)
{ {
struct rvu_hwinfo *hw = rvu->hw; int nixlf, blkaddr, err;
u16 pcifunc = req->hdr.pcifunc;
struct rvu_block *block;
struct rvu_pfvf *pfvf;
int nixlf, blkaddr;
u64 cfg; u64 cfg;
pfvf = rvu_get_pfvf(rvu, pcifunc); err = nix_get_nixlf(rvu, req->hdr.pcifunc, &nixlf, &blkaddr);
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc); if (err)
if (!pfvf->nixlf || blkaddr < 0) return err;
return NIX_AF_ERR_AF_LF_INVALID;
block = &hw->block[blkaddr];
nixlf = rvu_get_lf(rvu, block, pcifunc, 0);
if (nixlf < 0)
return NIX_AF_ERR_AF_LF_INVALID;
cfg = rvu_read64(rvu, blkaddr, NIX_AF_LFX_RX_CFG(nixlf)); cfg = rvu_read64(rvu, blkaddr, NIX_AF_LFX_RX_CFG(nixlf));
/* Set the interface configuration */ /* Set the interface configuration */
...@@ -3114,30 +3098,13 @@ void rvu_nix_freemem(struct rvu *rvu) ...@@ -3114,30 +3098,13 @@ void rvu_nix_freemem(struct rvu *rvu)
} }
} }
int nix_get_nixlf(struct rvu *rvu, u16 pcifunc, int *nixlf)
{
struct rvu_pfvf *pfvf = rvu_get_pfvf(rvu, pcifunc);
struct rvu_hwinfo *hw = rvu->hw;
int blkaddr;
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc);
if (!pfvf->nixlf || blkaddr < 0)
return NIX_AF_ERR_AF_LF_INVALID;
*nixlf = rvu_get_lf(rvu, &hw->block[blkaddr], pcifunc, 0);
if (*nixlf < 0)
return NIX_AF_ERR_AF_LF_INVALID;
return 0;
}
int rvu_mbox_handler_nix_lf_start_rx(struct rvu *rvu, struct msg_req *req, int rvu_mbox_handler_nix_lf_start_rx(struct rvu *rvu, struct msg_req *req,
struct msg_rsp *rsp) struct msg_rsp *rsp)
{ {
u16 pcifunc = req->hdr.pcifunc; u16 pcifunc = req->hdr.pcifunc;
int nixlf, err; int nixlf, err;
err = nix_get_nixlf(rvu, pcifunc, &nixlf); err = nix_get_nixlf(rvu, pcifunc, &nixlf, NULL);
if (err) if (err)
return err; return err;
...@@ -3152,7 +3119,7 @@ int rvu_mbox_handler_nix_lf_stop_rx(struct rvu *rvu, struct msg_req *req, ...@@ -3152,7 +3119,7 @@ int rvu_mbox_handler_nix_lf_stop_rx(struct rvu *rvu, struct msg_req *req,
u16 pcifunc = req->hdr.pcifunc; u16 pcifunc = req->hdr.pcifunc;
int nixlf, err; int nixlf, err;
err = nix_get_nixlf(rvu, pcifunc, &nixlf); err = nix_get_nixlf(rvu, pcifunc, &nixlf, NULL);
if (err) if (err)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment