Commit cb7a6b3b authored by Subbaraya Sundeep's avatar Subbaraya Sundeep Committed by David S. Miller

octeontx2-af: Prepare for allocating MCAM rules for AF

AF till now only manages the allocation and freeing of
MCAM rules for other PF/VFs in system. To implement
L2 switching between all CGX mapped PF and VFs, AF
requires MCAM entries for DMAC rules for each PF and VF.
This patch modifies AF driver such that AF can also
allocate MCAM rules and install rules for other
PFs and VFs. All the checks like channel verification
for RX rules and PF_FUNC verification for TX rules are
relaxed in case AF is allocating or installing rules.
Also all the entry and counter to owner mappings are
set to NPC_MCAM_INVALID_MAP when they are free indicating
those are not allocated to AF nor PF/VFs.
This patch also ensures that AF allocated and installed
entries are displayed in debugfs.
Signed-off-by: default avatarSubbaraya Sundeep <sbhatta@marvell.com>
Signed-off-by: default avatarSunil Kovvuri Goutham <sgoutham@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fa2bf6ba
...@@ -2113,9 +2113,6 @@ static void rvu_print_npc_mcam_info(struct seq_file *s, ...@@ -2113,9 +2113,6 @@ static void rvu_print_npc_mcam_info(struct seq_file *s,
int entry_acnt, entry_ecnt; int entry_acnt, entry_ecnt;
int cntr_acnt, cntr_ecnt; int cntr_acnt, cntr_ecnt;
/* Skip PF0 */
if (!pcifunc)
return;
rvu_npc_get_mcam_entry_alloc_info(rvu, pcifunc, blkaddr, rvu_npc_get_mcam_entry_alloc_info(rvu, pcifunc, blkaddr,
&entry_acnt, &entry_ecnt); &entry_acnt, &entry_ecnt);
rvu_npc_get_mcam_counter_alloc_info(rvu, pcifunc, blkaddr, rvu_npc_get_mcam_counter_alloc_info(rvu, pcifunc, blkaddr,
...@@ -2298,7 +2295,7 @@ static void rvu_dbg_npc_mcam_show_flows(struct seq_file *s, ...@@ -2298,7 +2295,7 @@ static void rvu_dbg_npc_mcam_show_flows(struct seq_file *s,
static void rvu_dbg_npc_mcam_show_action(struct seq_file *s, static void rvu_dbg_npc_mcam_show_action(struct seq_file *s,
struct rvu_npc_mcam_rule *rule) struct rvu_npc_mcam_rule *rule)
{ {
if (rule->intf == NIX_INTF_TX) { if (is_npc_intf_tx(rule->intf)) {
switch (rule->tx_action.op) { switch (rule->tx_action.op) {
case NIX_TX_ACTIONOP_DROP: case NIX_TX_ACTIONOP_DROP:
seq_puts(s, "\taction: Drop\n"); seq_puts(s, "\taction: Drop\n");
......
...@@ -442,7 +442,8 @@ static void npc_fixup_vf_rule(struct rvu *rvu, struct npc_mcam *mcam, ...@@ -442,7 +442,8 @@ static void npc_fixup_vf_rule(struct rvu *rvu, struct npc_mcam *mcam,
owner = mcam->entry2pfvf_map[index]; owner = mcam->entry2pfvf_map[index];
target_func = (entry->action >> 4) & 0xffff; target_func = (entry->action >> 4) & 0xffff;
/* do nothing when target is LBK/PF or owner is not PF */ /* do nothing when target is LBK/PF or owner is not PF */
if (is_afvf(target_func) || (owner & RVU_PFVF_FUNC_MASK) || if (is_pffunc_af(owner) || is_afvf(target_func) ||
(owner & RVU_PFVF_FUNC_MASK) ||
!(target_func & RVU_PFVF_FUNC_MASK)) !(target_func & RVU_PFVF_FUNC_MASK))
return; return;
...@@ -661,6 +662,7 @@ void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc, ...@@ -661,6 +662,7 @@ void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc,
eth_broadcast_addr((u8 *)&req.mask.dmac); eth_broadcast_addr((u8 *)&req.mask.dmac);
req.features = BIT_ULL(NPC_DMAC); req.features = BIT_ULL(NPC_DMAC);
req.channel = chan; req.channel = chan;
req.chan_mask = 0xFFFU;
req.intf = pfvf->nix_rx_intf; req.intf = pfvf->nix_rx_intf;
req.op = action.op; req.op = action.op;
req.hdr.pcifunc = 0; /* AF is requester */ req.hdr.pcifunc = 0; /* AF is requester */
...@@ -810,6 +812,7 @@ void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 pcifunc, ...@@ -810,6 +812,7 @@ void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 pcifunc,
eth_broadcast_addr((u8 *)&req.mask.dmac); eth_broadcast_addr((u8 *)&req.mask.dmac);
req.features = BIT_ULL(NPC_DMAC); req.features = BIT_ULL(NPC_DMAC);
req.channel = chan; req.channel = chan;
req.chan_mask = 0xFFFU;
req.intf = pfvf->nix_rx_intf; req.intf = pfvf->nix_rx_intf;
req.entry = index; req.entry = index;
req.hdr.pcifunc = 0; /* AF is requester */ req.hdr.pcifunc = 0; /* AF is requester */
...@@ -1756,6 +1759,8 @@ static int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr) ...@@ -1756,6 +1759,8 @@ static int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr)
int nixlf_count = rvu_get_nixlf_count(rvu); int nixlf_count = rvu_get_nixlf_count(rvu);
struct npc_mcam *mcam = &rvu->hw->mcam; struct npc_mcam *mcam = &rvu->hw->mcam;
int rsvd, err; int rsvd, err;
u16 index;
int cntr;
u64 cfg; u64 cfg;
/* Actual number of MCAM entries vary by entry size */ /* Actual number of MCAM entries vary by entry size */
...@@ -1856,6 +1861,14 @@ static int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr) ...@@ -1856,6 +1861,14 @@ static int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr)
if (!mcam->entry2target_pffunc) if (!mcam->entry2target_pffunc)
goto free_mem; goto free_mem;
for (index = 0; index < mcam->bmap_entries; index++) {
mcam->entry2pfvf_map[index] = NPC_MCAM_INVALID_MAP;
mcam->entry2cntr_map[index] = NPC_MCAM_INVALID_MAP;
}
for (cntr = 0; cntr < mcam->counters.max; cntr++)
mcam->cntr2pfvf_map[cntr] = NPC_MCAM_INVALID_MAP;
mutex_init(&mcam->lock); mutex_init(&mcam->lock);
return 0; return 0;
...@@ -2573,7 +2586,7 @@ int rvu_mbox_handler_npc_mcam_alloc_entry(struct rvu *rvu, ...@@ -2573,7 +2586,7 @@ int rvu_mbox_handler_npc_mcam_alloc_entry(struct rvu *rvu,
} }
/* Alloc request from PFFUNC with no NIXLF attached should be denied */ /* Alloc request from PFFUNC with no NIXLF attached should be denied */
if (!is_nixlf_attached(rvu, pcifunc)) if (!is_pffunc_af(pcifunc) && !is_nixlf_attached(rvu, pcifunc))
return NPC_MCAM_ALLOC_DENIED; return NPC_MCAM_ALLOC_DENIED;
return npc_mcam_alloc_entries(mcam, pcifunc, req, rsp); return npc_mcam_alloc_entries(mcam, pcifunc, req, rsp);
...@@ -2593,7 +2606,7 @@ int rvu_mbox_handler_npc_mcam_free_entry(struct rvu *rvu, ...@@ -2593,7 +2606,7 @@ int rvu_mbox_handler_npc_mcam_free_entry(struct rvu *rvu,
return NPC_MCAM_INVALID_REQ; return NPC_MCAM_INVALID_REQ;
/* Free request from PFFUNC with no NIXLF attached, ignore */ /* Free request from PFFUNC with no NIXLF attached, ignore */
if (!is_nixlf_attached(rvu, pcifunc)) if (!is_pffunc_af(pcifunc) && !is_nixlf_attached(rvu, pcifunc))
return NPC_MCAM_INVALID_REQ; return NPC_MCAM_INVALID_REQ;
mutex_lock(&mcam->lock); mutex_lock(&mcam->lock);
...@@ -2605,7 +2618,7 @@ int rvu_mbox_handler_npc_mcam_free_entry(struct rvu *rvu, ...@@ -2605,7 +2618,7 @@ int rvu_mbox_handler_npc_mcam_free_entry(struct rvu *rvu,
if (rc) if (rc)
goto exit; goto exit;
mcam->entry2pfvf_map[req->entry] = 0; mcam->entry2pfvf_map[req->entry] = NPC_MCAM_INVALID_MAP;
mcam->entry2target_pffunc[req->entry] = 0x0; mcam->entry2target_pffunc[req->entry] = 0x0;
npc_mcam_clear_bit(mcam, req->entry); npc_mcam_clear_bit(mcam, req->entry);
npc_enable_mcam_entry(rvu, mcam, blkaddr, req->entry, false); npc_enable_mcam_entry(rvu, mcam, blkaddr, req->entry, false);
...@@ -2690,13 +2703,14 @@ int rvu_mbox_handler_npc_mcam_write_entry(struct rvu *rvu, ...@@ -2690,13 +2703,14 @@ int rvu_mbox_handler_npc_mcam_write_entry(struct rvu *rvu,
else else
nix_intf = pfvf->nix_rx_intf; nix_intf = pfvf->nix_rx_intf;
if (npc_mcam_verify_channel(rvu, pcifunc, req->intf, channel)) { if (!is_pffunc_af(pcifunc) &&
npc_mcam_verify_channel(rvu, pcifunc, req->intf, channel)) {
rc = NPC_MCAM_INVALID_REQ; rc = NPC_MCAM_INVALID_REQ;
goto exit; goto exit;
} }
if (npc_mcam_verify_pf_func(rvu, &req->entry_data, req->intf, if (!is_pffunc_af(pcifunc) &&
pcifunc)) { npc_mcam_verify_pf_func(rvu, &req->entry_data, req->intf, pcifunc)) {
rc = NPC_MCAM_INVALID_REQ; rc = NPC_MCAM_INVALID_REQ;
goto exit; goto exit;
} }
...@@ -2847,7 +2861,7 @@ int rvu_mbox_handler_npc_mcam_alloc_counter(struct rvu *rvu, ...@@ -2847,7 +2861,7 @@ int rvu_mbox_handler_npc_mcam_alloc_counter(struct rvu *rvu,
return NPC_MCAM_INVALID_REQ; return NPC_MCAM_INVALID_REQ;
/* If the request is from a PFFUNC with no NIXLF attached, ignore */ /* If the request is from a PFFUNC with no NIXLF attached, ignore */
if (!is_nixlf_attached(rvu, pcifunc)) if (!is_pffunc_af(pcifunc) && !is_nixlf_attached(rvu, pcifunc))
return NPC_MCAM_INVALID_REQ; return NPC_MCAM_INVALID_REQ;
/* Since list of allocated counter IDs needs to be sent to requester, /* Since list of allocated counter IDs needs to be sent to requester,
...@@ -3092,7 +3106,7 @@ int rvu_mbox_handler_npc_mcam_alloc_and_write_entry(struct rvu *rvu, ...@@ -3092,7 +3106,7 @@ int rvu_mbox_handler_npc_mcam_alloc_and_write_entry(struct rvu *rvu,
if (rc) { if (rc) {
/* Free allocated MCAM entry */ /* Free allocated MCAM entry */
mutex_lock(&mcam->lock); mutex_lock(&mcam->lock);
mcam->entry2pfvf_map[entry] = 0; mcam->entry2pfvf_map[entry] = NPC_MCAM_INVALID_MAP;
npc_mcam_clear_bit(mcam, entry); npc_mcam_clear_bit(mcam, entry);
mutex_unlock(&mcam->lock); mutex_unlock(&mcam->lock);
return rc; return rc;
......
...@@ -913,11 +913,9 @@ static void npc_update_rx_entry(struct rvu *rvu, struct rvu_pfvf *pfvf, ...@@ -913,11 +913,9 @@ static void npc_update_rx_entry(struct rvu *rvu, struct rvu_pfvf *pfvf,
struct npc_install_flow_req *req, u16 target) struct npc_install_flow_req *req, u16 target)
{ {
struct nix_rx_action action; struct nix_rx_action action;
u64 chan_mask;
chan_mask = req->chan_mask ? req->chan_mask : ~0ULL; npc_update_entry(rvu, NPC_CHAN, entry, req->channel, 0, req->chan_mask,
npc_update_entry(rvu, NPC_CHAN, entry, req->channel, 0, chan_mask, 0, 0, NIX_INTF_RX);
NIX_INTF_RX);
*(u64 *)&action = 0x00; *(u64 *)&action = 0x00;
action.pf_func = target; action.pf_func = target;
...@@ -1171,7 +1169,9 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu, ...@@ -1171,7 +1169,9 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,
if (err) if (err)
return err; return err;
if (npc_mcam_verify_channel(rvu, target, req->intf, req->channel)) /* Skip channel validation if AF is installing */
if (!is_pffunc_af(req->hdr.pcifunc) &&
npc_mcam_verify_channel(rvu, target, req->intf, req->channel))
return -EINVAL; return -EINVAL;
pfvf = rvu_get_pfvf(rvu, target); pfvf = rvu_get_pfvf(rvu, target);
...@@ -1187,6 +1187,7 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu, ...@@ -1187,6 +1187,7 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,
eth_broadcast_addr((u8 *)&req->mask.dmac); eth_broadcast_addr((u8 *)&req->mask.dmac);
} }
/* Proceed if NIXLF is attached or not for TX rules */
err = nix_get_nixlf(rvu, target, &nixlf, NULL); err = nix_get_nixlf(rvu, target, &nixlf, NULL);
if (err && is_npc_intf_rx(req->intf) && !pf_set_vfs_mac) if (err && is_npc_intf_rx(req->intf) && !pf_set_vfs_mac)
return -EINVAL; return -EINVAL;
......
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