Skip to content

Commit

Permalink
Merge branch 'octeonx2-mcam-management-rework'
Browse files Browse the repository at this point in the history
Subbaraya Sundeep says:

====================
octeontx2: Rework MCAM flows management for VFs

From Octeontx2 hardware point of view there is no
difference between PFs and VFs. Hence with refactoring
in driver the packet classification features or offloads
can be supported by VFs also. This patchset unifies the
mcam flows management so that VFs can also support
ntuple filters. Since there are MCAM allocations by
all PFs and VFs in the system it is required to have
the ability to modify number of mcam rules count
for a PF/VF in runtime. This is achieved by using devlink.
Below is the summary of patches:

Patch 1,2,3 are trivial patches which helps in debugging
in case of errors by using custom error codes and
displaying proper error messages.

Patches 4,5 brings rx-all and ntuple support
for CGX mapped VFs and LBK VFs.

Patches 6,7,8 brings devlink support to
PF netdev driver so that mcam entries count
can be changed at runtime.
To change mcam rule count at runtime where multiple rule
allocations are done sorting is required.
Also both ntuple and TC rules needs to be unified.

Patch 9 is related to AF NPC where a PF
allocated entries are allocated at bottom(low priority).

On CN10K there is slight change in reading
NPC counters which is handled by patch 10.

Patch 11 is to allow packets from CPT for
NPC parsing on CN10K.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Aug 17, 2021
2 parents 354e1f9 + aee5122 commit 2cb5942
Show file tree
Hide file tree
Showing 16 changed files with 585 additions and 173 deletions.
16 changes: 16 additions & 0 deletions drivers/net/ethernet/marvell/octeontx2/af/mbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,13 @@ enum npc_af_status {
NPC_MCAM_ALLOC_DENIED = -702,
NPC_MCAM_ALLOC_FAILED = -703,
NPC_MCAM_PERM_DENIED = -704,
NPC_FLOW_INTF_INVALID = -707,
NPC_FLOW_CHAN_INVALID = -708,
NPC_FLOW_NO_NIXLF = -709,
NPC_FLOW_NOT_SUPPORTED = -710,
NPC_FLOW_VF_PERM_DENIED = -711,
NPC_FLOW_VF_NOT_INIT = -712,
NPC_FLOW_VF_OVERLAP = -713,
};

struct npc_mcam_alloc_entry_req {
Expand Down Expand Up @@ -1426,4 +1433,13 @@ struct cpt_rxc_time_cfg_req {
u16 active_limit;
};

/* CGX mailbox error codes
* Range 1101 - 1200.
*/
enum cgx_af_status {
LMAC_AF_ERR_INVALID_PARAM = -1101,
LMAC_AF_ERR_PF_NOT_MAPPED = -1102,
LMAC_AF_ERR_PERM_DENIED = -1103,
};

#endif /* MBOX_H */
92 changes: 73 additions & 19 deletions drivers/net/ethernet/marvell/octeontx2/af/rvu.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,16 +924,26 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
block->lfreset_reg = NPA_AF_LF_RST;
sprintf(block->name, "NPA");
err = rvu_alloc_bitmap(&block->lf);
if (err)
if (err) {
dev_err(rvu->dev,
"%s: Failed to allocate NPA LF bitmap\n", __func__);
return err;
}

nix:
err = rvu_setup_nix_hw_resource(rvu, BLKADDR_NIX0);
if (err)
if (err) {
dev_err(rvu->dev,
"%s: Failed to allocate NIX0 LFs bitmap\n", __func__);
return err;
}

err = rvu_setup_nix_hw_resource(rvu, BLKADDR_NIX1);
if (err)
if (err) {
dev_err(rvu->dev,
"%s: Failed to allocate NIX1 LFs bitmap\n", __func__);
return err;
}

/* Init SSO group's bitmap */
block = &hw->block[BLKADDR_SSO];
Expand All @@ -953,8 +963,11 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
block->lfreset_reg = SSO_AF_LF_HWGRP_RST;
sprintf(block->name, "SSO GROUP");
err = rvu_alloc_bitmap(&block->lf);
if (err)
if (err) {
dev_err(rvu->dev,
"%s: Failed to allocate SSO LF bitmap\n", __func__);
return err;
}

ssow:
/* Init SSO workslot's bitmap */
Expand All @@ -974,8 +987,11 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
block->lfreset_reg = SSOW_AF_LF_HWS_RST;
sprintf(block->name, "SSOWS");
err = rvu_alloc_bitmap(&block->lf);
if (err)
if (err) {
dev_err(rvu->dev,
"%s: Failed to allocate SSOW LF bitmap\n", __func__);
return err;
}

tim:
/* Init TIM LF's bitmap */
Expand All @@ -996,35 +1012,55 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
block->lfreset_reg = TIM_AF_LF_RST;
sprintf(block->name, "TIM");
err = rvu_alloc_bitmap(&block->lf);
if (err)
if (err) {
dev_err(rvu->dev,
"%s: Failed to allocate TIM LF bitmap\n", __func__);
return err;
}

cpt:
err = rvu_setup_cpt_hw_resource(rvu, BLKADDR_CPT0);
if (err)
if (err) {
dev_err(rvu->dev,
"%s: Failed to allocate CPT0 LF bitmap\n", __func__);
return err;
}
err = rvu_setup_cpt_hw_resource(rvu, BLKADDR_CPT1);
if (err) {
dev_err(rvu->dev,
"%s: Failed to allocate CPT1 LF bitmap\n", __func__);
return err;
}
if (err)
return err;

/* Allocate memory for PFVF data */
rvu->pf = devm_kcalloc(rvu->dev, hw->total_pfs,
sizeof(struct rvu_pfvf), GFP_KERNEL);
if (!rvu->pf)
if (!rvu->pf) {
dev_err(rvu->dev,
"%s: Failed to allocate memory for PF's rvu_pfvf struct\n", __func__);
return -ENOMEM;
}

rvu->hwvf = devm_kcalloc(rvu->dev, hw->total_vfs,
sizeof(struct rvu_pfvf), GFP_KERNEL);
if (!rvu->hwvf)
if (!rvu->hwvf) {
dev_err(rvu->dev,
"%s: Failed to allocate memory for VF's rvu_pfvf struct\n", __func__);
return -ENOMEM;
}

mutex_init(&rvu->rsrc_lock);

rvu_fwdata_init(rvu);

err = rvu_setup_msix_resources(rvu);
if (err)
if (err) {
dev_err(rvu->dev,
"%s: Failed to setup MSIX resources\n", __func__);
return err;
}

for (blkid = 0; blkid < BLK_COUNT; blkid++) {
block = &hw->block[blkid];
Expand All @@ -1050,25 +1086,33 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
goto msix_err;

err = rvu_npc_init(rvu);
if (err)
if (err) {
dev_err(rvu->dev, "%s: Failed to initialize npc\n", __func__);
goto npc_err;
}

err = rvu_cgx_init(rvu);
if (err)
if (err) {
dev_err(rvu->dev, "%s: Failed to initialize cgx\n", __func__);
goto cgx_err;
}

/* Assign MACs for CGX mapped functions */
rvu_setup_pfvf_macaddress(rvu);

err = rvu_npa_init(rvu);
if (err)
if (err) {
dev_err(rvu->dev, "%s: Failed to initialize npa\n", __func__);
goto npa_err;
}

rvu_get_lbk_bufsize(rvu);

err = rvu_nix_init(rvu);
if (err)
if (err) {
dev_err(rvu->dev, "%s: Failed to initialize nix\n", __func__);
goto nix_err;
}

rvu_program_channels(rvu);

Expand Down Expand Up @@ -2984,27 +3028,37 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
err = rvu_mbox_init(rvu, &rvu->afpf_wq_info, TYPE_AFPF,
rvu->hw->total_pfs, rvu_afpf_mbox_handler,
rvu_afpf_mbox_up_handler);
if (err)
if (err) {
dev_err(dev, "%s: Failed to initialize mbox\n", __func__);
goto err_hwsetup;
}

err = rvu_flr_init(rvu);
if (err)
if (err) {
dev_err(dev, "%s: Failed to initialize flr\n", __func__);
goto err_mbox;
}

err = rvu_register_interrupts(rvu);
if (err)
if (err) {
dev_err(dev, "%s: Failed to register interrupts\n", __func__);
goto err_flr;
}

err = rvu_register_dl(rvu);
if (err)
if (err) {
dev_err(dev, "%s: Failed to register devlink\n", __func__);
goto err_irq;
}

rvu_setup_rvum_blk_revid(rvu);

/* Enable AF's VFs (if any) */
err = rvu_enable_sriov(rvu);
if (err)
if (err) {
dev_err(dev, "%s: Failed to enable sriov\n", __func__);
goto err_dl;
}

/* Initialize debugfs */
rvu_dbg_init(rvu);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/marvell/octeontx2/af/rvu.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ struct rvu_hwinfo {
u16 npc_counters; /* No of match stats counters */
u32 lbk_bufsize; /* FIFO size supported by LBK */
bool npc_ext_set; /* Extended register set */
u64 npc_stat_ena; /* Match stats enable bit */

struct hw_cap cap;
struct rvu_block block[BLK_COUNT]; /* Block info */
Expand Down
12 changes: 6 additions & 6 deletions drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ int rvu_cgx_config_rxtx(struct rvu *rvu, u16 pcifunc, bool start)
u8 cgx_id, lmac_id;

if (!is_cgx_config_permitted(rvu, pcifunc))
return -EPERM;
return LMAC_AF_ERR_PERM_DENIED;

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

Expand Down Expand Up @@ -507,7 +507,7 @@ static int rvu_lmac_get_stats(struct rvu *rvu, struct msg_req *req,
void *cgxd;

if (!is_cgx_config_permitted(rvu, req->hdr.pcifunc))
return -ENODEV;
return LMAC_AF_ERR_PERM_DENIED;

rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_idx, &lmac);
cgxd = rvu_cgx_pdata(cgx_idx, rvu);
Expand Down Expand Up @@ -561,7 +561,7 @@ int rvu_mbox_handler_cgx_fec_stats(struct rvu *rvu,
void *cgxd;

if (!is_cgx_config_permitted(rvu, req->hdr.pcifunc))
return -EPERM;
return LMAC_AF_ERR_PERM_DENIED;
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_idx, &lmac);

cgxd = rvu_cgx_pdata(cgx_idx, rvu);
Expand Down Expand Up @@ -888,7 +888,7 @@ int rvu_mbox_handler_cgx_get_phy_fec_stats(struct rvu *rvu, struct msg_req *req,
u8 cgx_id, lmac_id;

if (!is_pf_cgxmapped(rvu, pf))
return -EPERM;
return LMAC_AF_ERR_PF_NOT_MAPPED;

rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
return cgx_get_phy_fec_stats(rvu_cgx_pdata(cgx_id, rvu), lmac_id);
Expand Down Expand Up @@ -1046,7 +1046,7 @@ int rvu_mbox_handler_cgx_mac_addr_reset(struct rvu *rvu, struct msg_req *req,
u8 cgx_id, lmac_id;

if (!is_cgx_config_permitted(rvu, req->hdr.pcifunc))
return -EPERM;
return LMAC_AF_ERR_PERM_DENIED;

rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
return cgx_lmac_addr_reset(cgx_id, lmac_id);
Expand All @@ -1060,7 +1060,7 @@ int rvu_mbox_handler_cgx_mac_addr_update(struct rvu *rvu,
u8 cgx_id, lmac_id;

if (!is_cgx_config_permitted(rvu, req->hdr.pcifunc))
return -EPERM;
return LMAC_AF_ERR_PERM_DENIED;

rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
return cgx_lmac_addr_update(cgx_id, lmac_id, req->mac_addr, req->index);
Expand Down
Loading

0 comments on commit 2cb5942

Please sign in to comment.