X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Focteontx2%2Fotx2_flow.c;h=6df0732189eb9ffc60681e2d1cef66b1a535c09a;hb=83680d371592fcf1b66cbbfecb0fb8b3aa4ccc8d;hp=13a76e441251ef7102e97606c88b2bb7d4cf7419;hpb=fb9f56f3e35f4ce8a7d702396bb4a65dc57fe2f4;p=dpdk.git diff --git a/drivers/net/octeontx2/otx2_flow.c b/drivers/net/octeontx2/otx2_flow.c index 13a76e4412..6df0732189 100644 --- a/drivers/net/octeontx2/otx2_flow.c +++ b/drivers/net/octeontx2/otx2_flow.c @@ -6,6 +6,8 @@ #include "otx2_ethdev_sec.h" #include "otx2_flow.h" +enum flow_vtag_cfg_dir { VTAG_TX, VTAG_RX }; + int otx2_flow_free_all_resources(struct otx2_eth_dev *hw) { @@ -270,6 +272,8 @@ flow_program_rss_action(struct rte_eth_dev *eth_dev, if (rc) return rc; + flow->npc_action &= (~(0xfULL)); + flow->npc_action |= NIX_RX_ACTIONOP_RSS; flow->npc_action |= ((uint64_t)(alg_idx & NIX_RSS_ACT_ALG_MASK) << NIX_RSS_ACT_ALG_OFFSET) | @@ -460,6 +464,109 @@ otx2_flow_validate(struct rte_eth_dev *dev, &parse_state); } +static int +flow_program_vtag_action(struct rte_eth_dev *eth_dev, + const struct rte_flow_action actions[], + struct rte_flow *flow) +{ + uint16_t vlan_id = 0, vlan_ethtype = RTE_ETHER_TYPE_VLAN; + struct otx2_eth_dev *dev = eth_dev->data->dev_private; + union { + uint64_t reg; + struct nix_tx_vtag_action_s act; + } tx_vtag_action; + struct otx2_mbox *mbox = dev->mbox; + struct nix_vtag_config *vtag_cfg; + struct nix_vtag_config_rsp *rsp; + bool vlan_insert_action = false; + uint64_t rx_vtag_action = 0; + uint8_t vlan_pcp = 0; + int rc; + + for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { + if (actions->type == RTE_FLOW_ACTION_TYPE_OF_POP_VLAN) { + if (dev->npc_flow.vtag_actions == 1) { + vtag_cfg = + otx2_mbox_alloc_msg_nix_vtag_cfg(mbox); + vtag_cfg->cfg_type = VTAG_RX; + vtag_cfg->rx.strip_vtag = 1; + /* Always capture */ + vtag_cfg->rx.capture_vtag = 1; + vtag_cfg->vtag_size = NIX_VTAGSIZE_T4; + vtag_cfg->rx.vtag_type = 0; + + rc = otx2_mbox_process(mbox); + if (rc) + return rc; + } + + rx_vtag_action |= (NIX_RX_VTAGACTION_VTAG_VALID << 15); + rx_vtag_action |= (NPC_LID_LB << 8); + rx_vtag_action |= NIX_RX_VTAGACTION_VTAG0_RELPTR; + flow->vtag_action = rx_vtag_action; + } else if (actions->type == + RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID) { + const struct rte_flow_action_of_set_vlan_vid *vtag = + (const struct rte_flow_action_of_set_vlan_vid *) + actions->conf; + vlan_id = rte_be_to_cpu_16(vtag->vlan_vid); + if (vlan_id > 0xfff) { + otx2_err("Invalid vlan_id for set vlan action"); + return -EINVAL; + } + vlan_insert_action = true; + } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) { + const struct rte_flow_action_of_push_vlan *ethtype = + (const struct rte_flow_action_of_push_vlan *) + actions->conf; + vlan_ethtype = rte_be_to_cpu_16(ethtype->ethertype); + if (vlan_ethtype != RTE_ETHER_TYPE_VLAN && + vlan_ethtype != RTE_ETHER_TYPE_QINQ) { + otx2_err("Invalid ethtype specified for push" + " vlan action"); + return -EINVAL; + } + vlan_insert_action = true; + } else if (actions->type == + RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP) { + const struct rte_flow_action_of_set_vlan_pcp *pcp = + (const struct rte_flow_action_of_set_vlan_pcp *) + actions->conf; + vlan_pcp = pcp->vlan_pcp; + if (vlan_pcp > 0x7) { + otx2_err("Invalid PCP value for pcp action"); + return -EINVAL; + } + vlan_insert_action = true; + } + } + + if (vlan_insert_action) { + vtag_cfg = otx2_mbox_alloc_msg_nix_vtag_cfg(mbox); + vtag_cfg->cfg_type = VTAG_TX; + vtag_cfg->vtag_size = NIX_VTAGSIZE_T4; + vtag_cfg->tx.vtag0 = + ((vlan_ethtype << 16) | (vlan_pcp << 13) | vlan_id); + vtag_cfg->tx.cfg_vtag0 = 1; + rc = otx2_mbox_process_msg(mbox, (void *)&rsp); + if (rc) + return rc; + + tx_vtag_action.reg = 0; + tx_vtag_action.act.vtag0_def = rsp->vtag0_idx; + if (tx_vtag_action.act.vtag0_def < 0) { + otx2_err("Failed to config TX VTAG action"); + return -EINVAL; + } + tx_vtag_action.act.vtag0_lid = NPC_LID_LA; + tx_vtag_action.act.vtag0_op = NIX_TX_VTAGOP_INSERT; + tx_vtag_action.act.vtag0_relptr = + NIX_TX_VTAGACTION_VTAG0_RELPTR; + flow->vtag_action = tx_vtag_action.reg; + } + return 0; +} + static struct rte_flow * otx2_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, @@ -489,6 +596,17 @@ otx2_flow_create(struct rte_eth_dev *dev, if (rc != 0) goto err_exit; + rc = flow_program_vtag_action(dev, actions, flow); + if (rc != 0) { + rte_flow_error_set(error, EIO, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Failed to program vlan action"); + goto err_exit; + } + + parse_state.is_vf = otx2_dev_is_vf(hw); + rc = flow_program_npc(&parse_state, mbox, &hw->npc_flow); if (rc != 0) { rte_flow_error_set(error, EIO, @@ -561,6 +679,17 @@ otx2_flow_destroy(struct rte_eth_dev *dev, } } + if (flow->nix_intf == OTX2_INTF_RX && flow->vtag_action) { + npc->vtag_actions--; + if (npc->vtag_actions == 0) { + if (hw->vlan_info.strip_on == 0) { + hw->rx_offload_flags &= + ~NIX_RX_OFFLOAD_VLAN_STRIP_F; + otx2_eth_set_rx_function(dev); + } + } + } + rc = flow_free_rss_action(dev, flow); if (rc != 0) { rte_flow_error_set(error, EIO, @@ -676,6 +805,45 @@ err_exit: return -rte_errno; } +static int +otx2_flow_dev_dump(struct rte_eth_dev *dev, + struct rte_flow *flow, FILE *file, + struct rte_flow_error *error) +{ + struct otx2_eth_dev *hw = dev->data->dev_private; + struct otx2_flow_list *list; + struct rte_flow *flow_iter; + uint32_t max_prio, i; + + if (file == NULL) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Invalid file"); + return -EINVAL; + } + if (flow != NULL) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_HANDLE, + NULL, + "Invalid argument"); + return -EINVAL; + } + + max_prio = hw->npc_flow.flow_max_priority; + + for (i = 0; i < max_prio; i++) { + list = &hw->npc_flow.flow_list[i]; + + /* List in ascending order of mcam entries */ + TAILQ_FOREACH(flow_iter, list, next) { + otx2_flow_dump(file, hw, flow_iter); + } + } + + return 0; +} + const struct rte_flow_ops otx2_flow_ops = { .validate = otx2_flow_validate, .create = otx2_flow_create, @@ -683,6 +851,7 @@ const struct rte_flow_ops otx2_flow_ops = { .flush = otx2_flow_flush, .query = otx2_flow_query, .isolate = otx2_flow_isolate, + .dev_dump = otx2_flow_dev_dump, }; static int @@ -834,12 +1003,23 @@ done: return rc; } +#define OTX2_MCAM_TOT_ENTRIES_96XX (4096) +#define OTX2_MCAM_TOT_ENTRIES_98XX (16384) + +static int otx2_mcam_tot_entries(struct otx2_eth_dev *dev) +{ + if (otx2_dev_is_98xx(dev)) + return OTX2_MCAM_TOT_ENTRIES_98XX; + else + return OTX2_MCAM_TOT_ENTRIES_96XX; +} + int otx2_flow_init(struct otx2_eth_dev *hw) { uint8_t *mem = NULL, *nix_mem = NULL, *npc_mem = NULL; struct otx2_npc_flow_info *npc = &hw->npc_flow; - uint32_t bmap_sz; + uint32_t bmap_sz, tot_mcam_entries = 0; int rc = 0, idx; rc = flow_fetch_kex_cfg(hw); @@ -849,8 +1029,10 @@ otx2_flow_init(struct otx2_eth_dev *hw) } rte_atomic32_init(&npc->mark_actions); + npc->vtag_actions = 0; - npc->mcam_entries = NPC_MCAM_TOT_ENTRIES >> npc->keyw[NPC_MCAM_RX]; + tot_mcam_entries = otx2_mcam_tot_entries(hw); + npc->mcam_entries = tot_mcam_entries >> npc->keyw[NPC_MCAM_RX]; /* Free, free_rev, live and live_rev entries */ bmap_sz = rte_bitmap_get_memory_footprint(npc->mcam_entries); mem = rte_zmalloc(NULL, 4 * bmap_sz * npc->flow_max_priority,