From: Jerin Jacob <jerinjacobk@gmail.com>
To: Kiran Kumar K <kirankumark@marvell.com>
Cc: Jerin Jacob <jerinj@marvell.com>,
Nithin Dabilpuram <ndabilpuram@marvell.com>,
John McNamara <john.mcnamara@intel.com>,
Marko Kovacevic <marko.kovacevic@intel.com>,
dpdk-dev <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] net/octeontx2: add support VLAN insert and strip action
Date: Tue, 29 Sep 2020 15:21:40 +0530 [thread overview]
Message-ID: <CALBAE1P=_fWPRsavRL-KNuWPhW2_AGbHGD6xGO12XrwtcDj74Q@mail.gmail.com> (raw)
In-Reply-To: <20200824070424.252040-1-kirankumark@marvell.com>
On Mon, Aug 24, 2020 at 12:34 PM <kirankumark@marvell.com> wrote:
>
> From: Kiran Kumar K <kirankumark@marvell.com>
>
> Adding support for RTE Flow VLAN insert and strip actions for octeontx2
> device.
>
> Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
> ---
> doc/guides/nics/octeontx2.rst | 68 +++++++------
> drivers/net/octeontx2/otx2_flow.c | 126 ++++++++++++++++++++++++
> drivers/net/octeontx2/otx2_flow.h | 6 ++
> drivers/net/octeontx2/otx2_flow_parse.c | 76 ++++++++++++--
> drivers/net/octeontx2/otx2_flow_utils.c | 15 +--
> 5 files changed, 237 insertions(+), 54 deletions(-)
Acked-by: Jerin Jacob <jerinj@marvell.com>
Applied to dpdk-next-net-mrvl/main. Thanks
>
> diff --git a/doc/guides/nics/octeontx2.rst b/doc/guides/nics/octeontx2.rst
> index bb591a8b7..f3be79bbb 100644
> --- a/doc/guides/nics/octeontx2.rst
> +++ b/doc/guides/nics/octeontx2.rst
> @@ -385,38 +385,46 @@ Actions:
>
> .. table:: Ingress action types
>
> - +----+--------------------------------+
> - | # | Action Type |
> - +====+================================+
> - | 1 | RTE_FLOW_ACTION_TYPE_VOID |
> - +----+--------------------------------+
> - | 2 | RTE_FLOW_ACTION_TYPE_MARK |
> - +----+--------------------------------+
> - | 3 | RTE_FLOW_ACTION_TYPE_FLAG |
> - +----+--------------------------------+
> - | 4 | RTE_FLOW_ACTION_TYPE_COUNT |
> - +----+--------------------------------+
> - | 5 | RTE_FLOW_ACTION_TYPE_DROP |
> - +----+--------------------------------+
> - | 6 | RTE_FLOW_ACTION_TYPE_QUEUE |
> - +----+--------------------------------+
> - | 7 | RTE_FLOW_ACTION_TYPE_RSS |
> - +----+--------------------------------+
> - | 8 | RTE_FLOW_ACTION_TYPE_SECURITY |
> - +----+--------------------------------+
> - | 9 | RTE_FLOW_ACTION_TYPE_PF |
> - +----+--------------------------------+
> - | 10 | RTE_FLOW_ACTION_TYPE_VF |
> - +----+--------------------------------+
> + +----+-----------------------------------------+
> + | # | Action Type |
> + +====+=========================================+
> + | 1 | RTE_FLOW_ACTION_TYPE_VOID |
> + +----+-----------------------------------------+
> + | 2 | RTE_FLOW_ACTION_TYPE_MARK |
> + +----+-----------------------------------------+
> + | 3 | RTE_FLOW_ACTION_TYPE_FLAG |
> + +----+-----------------------------------------+
> + | 4 | RTE_FLOW_ACTION_TYPE_COUNT |
> + +----+-----------------------------------------+
> + | 5 | RTE_FLOW_ACTION_TYPE_DROP |
> + +----+-----------------------------------------+
> + | 6 | RTE_FLOW_ACTION_TYPE_QUEUE |
> + +----+-----------------------------------------+
> + | 7 | RTE_FLOW_ACTION_TYPE_RSS |
> + +----+-----------------------------------------+
> + | 8 | RTE_FLOW_ACTION_TYPE_SECURITY |
> + +----+-----------------------------------------+
> + | 9 | RTE_FLOW_ACTION_TYPE_PF |
> + +----+-----------------------------------------+
> + | 10 | RTE_FLOW_ACTION_TYPE_VF |
> + +----+-----------------------------------------+
> + | 11 | RTE_FLOW_ACTION_TYPE_OF_POP_VLAN |
> + +----+-----------------------------------------+
>
> .. _table_octeontx2_supported_egress_action_types:
>
> .. table:: Egress action types
>
> - +----+--------------------------------+
> - | # | Action Type |
> - +====+================================+
> - | 1 | RTE_FLOW_ACTION_TYPE_COUNT |
> - +----+--------------------------------+
> - | 2 | RTE_FLOW_ACTION_TYPE_DROP |
> - +----+--------------------------------+
> + +----+-----------------------------------------+
> + | # | Action Type |
> + +====+=========================================+
> + | 1 | RTE_FLOW_ACTION_TYPE_COUNT |
> + +----+-----------------------------------------+
> + | 2 | RTE_FLOW_ACTION_TYPE_DROP |
> + +----+-----------------------------------------+
> + | 3 | RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN |
> + +----+-----------------------------------------+
> + | 4 | RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID |
> + +----+-----------------------------------------+
> + | 5 | RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP |
> + +----+-----------------------------------------+
> diff --git a/drivers/net/octeontx2/otx2_flow.c b/drivers/net/octeontx2/otx2_flow.c
> index 13a76e441..9b32b2acc 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)
> {
> @@ -460,6 +462,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 +594,15 @@ 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;
> + }
> +
> rc = flow_program_npc(&parse_state, mbox, &hw->npc_flow);
> if (rc != 0) {
> rte_flow_error_set(error, EIO,
> @@ -561,6 +675,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,
> @@ -849,6 +974,7 @@ 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];
> /* Free, free_rev, live and live_rev entries */
> diff --git a/drivers/net/octeontx2/otx2_flow.h b/drivers/net/octeontx2/otx2_flow.h
> index df78f41d3..1f118c408 100644
> --- a/drivers/net/octeontx2/otx2_flow.h
> +++ b/drivers/net/octeontx2/otx2_flow.h
> @@ -55,6 +55,10 @@ enum {
> #define OTX2_FLOW_ACT_COUNT (1 << 7)
> #define OTX2_FLOW_ACT_PF (1 << 8)
> #define OTX2_FLOW_ACT_VF (1 << 9)
> +#define OTX2_FLOW_ACT_VLAN_STRIP (1 << 10)
> +#define OTX2_FLOW_ACT_VLAN_INSERT (1 << 11)
> +#define OTX2_FLOW_ACT_VLAN_ETHTYPE_INSERT (1 << 12)
> +#define OTX2_FLOW_ACT_VLAN_PCP_INSERT (1 << 13)
>
> /* terminating actions */
> #define OTX2_FLOW_ACT_TERM (OTX2_FLOW_ACT_DROP | \
> @@ -154,6 +158,7 @@ struct rte_flow {
> uint64_t mcam_data[OTX2_MAX_MCAM_WIDTH_DWORDS];
> uint64_t mcam_mask[OTX2_MAX_MCAM_WIDTH_DWORDS];
> uint64_t npc_action;
> + uint64_t vtag_action;
> TAILQ_ENTRY(rte_flow) next;
> };
>
> @@ -162,6 +167,7 @@ TAILQ_HEAD(otx2_flow_list, rte_flow);
> /* Accessed from ethdev private - otx2_eth_dev */
> struct otx2_npc_flow_info {
> rte_atomic32_t mark_actions;
> + uint32_t vtag_actions;
> uint32_t keyx_supp_nmask[NPC_MAX_INTF];/* nibble mask */
> uint32_t keyx_len[NPC_MAX_INTF]; /* per intf key len in bits */
> uint32_t datax_len[NPC_MAX_INTF]; /* per intf data len in bits */
> diff --git a/drivers/net/octeontx2/otx2_flow_parse.c b/drivers/net/octeontx2/otx2_flow_parse.c
> index 2d9a5857c..b7ff5fd03 100644
> --- a/drivers/net/octeontx2/otx2_flow_parse.c
> +++ b/drivers/net/octeontx2/otx2_flow_parse.c
> @@ -813,6 +813,7 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev,
> const struct rte_flow_action_mark *act_mark;
> const struct rte_flow_action_queue *act_q;
> const struct rte_flow_action_vf *vf_act;
> + bool vlan_insert_action = false;
> const char *errmsg = NULL;
> int sel_act, req_act = 0;
> uint16_t pf_func, vf_id;
> @@ -932,6 +933,18 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev,
> req_act |= OTX2_FLOW_ACT_SEC;
> rq = 0;
> break;
> + case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID:
> + req_act |= OTX2_FLOW_ACT_VLAN_INSERT;
> + break;
> + case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
> + req_act |= OTX2_FLOW_ACT_VLAN_STRIP;
> + break;
> + case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN:
> + req_act |= OTX2_FLOW_ACT_VLAN_ETHTYPE_INSERT;
> + break;
> + case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP:
> + req_act |= OTX2_FLOW_ACT_VLAN_PCP_INSERT;
> + break;
> default:
> errmsg = "Unsupported action specified";
> errcode = ENOTSUP;
> @@ -939,20 +952,46 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev,
> }
> }
>
> + if (req_act &
> + (OTX2_FLOW_ACT_VLAN_INSERT | OTX2_FLOW_ACT_VLAN_ETHTYPE_INSERT |
> + OTX2_FLOW_ACT_VLAN_PCP_INSERT))
> + vlan_insert_action = true;
> +
> + if ((req_act &
> + (OTX2_FLOW_ACT_VLAN_INSERT | OTX2_FLOW_ACT_VLAN_ETHTYPE_INSERT |
> + OTX2_FLOW_ACT_VLAN_PCP_INSERT)) ==
> + OTX2_FLOW_ACT_VLAN_PCP_INSERT) {
> + errmsg = " PCP insert action can't be supported alone";
> + errcode = ENOTSUP;
> + goto err_exit;
> + }
> +
> + /* Both STRIP and INSERT actions are not supported */
> + if (vlan_insert_action && (req_act & OTX2_FLOW_ACT_VLAN_STRIP)) {
> + errmsg = "Both VLAN insert and strip actions not supported"
> + " together";
> + errcode = ENOTSUP;
> + goto err_exit;
> + }
> +
> /* Check if actions specified are compatible */
> if (attr->egress) {
> - /* Only DROP/COUNT is supported */
> - if (!(req_act & OTX2_FLOW_ACT_DROP)) {
> - errmsg = "DROP is required action for egress";
> - errcode = EINVAL;
> - goto err_exit;
> - } else if (req_act & ~(OTX2_FLOW_ACT_DROP |
> - OTX2_FLOW_ACT_COUNT)) {
> - errmsg = "Unsupported action specified";
> + if (req_act & OTX2_FLOW_ACT_VLAN_STRIP) {
> + errmsg = "VLAN pop action is not supported on Egress";
> errcode = ENOTSUP;
> goto err_exit;
> }
> - flow->npc_action = NIX_TX_ACTIONOP_DROP;
> +
> + if (req_act & OTX2_FLOW_ACT_DROP) {
> + flow->npc_action = NIX_TX_ACTIONOP_DROP;
> + } else if ((req_act & OTX2_FLOW_ACT_COUNT) ||
> + vlan_insert_action) {
> + flow->npc_action = NIX_TX_ACTIONOP_UCAST_DEFAULT;
> + } else {
> + errmsg = "Unsupported action for egress";
> + errcode = EINVAL;
> + goto err_exit;
> + }
> goto set_pf_func;
> }
>
> @@ -985,8 +1024,20 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev,
> goto err_exit;
> }
>
> + if (vlan_insert_action) {
> + errmsg = "VLAN push/Insert action is not supported on Ingress";
> + errcode = ENOTSUP;
> + goto err_exit;
> + }
> +
> + if (req_act & OTX2_FLOW_ACT_VLAN_STRIP)
> + npc->vtag_actions++;
> +
> + /* Only VLAN action is provided */
> + if (req_act == OTX2_FLOW_ACT_VLAN_STRIP)
> + flow->npc_action = NIX_RX_ACTIONOP_UCAST;
> /* Set NIX_RX_ACTIONOP */
> - if (req_act & (OTX2_FLOW_ACT_PF | OTX2_FLOW_ACT_VF)) {
> + else if (req_act & (OTX2_FLOW_ACT_PF | OTX2_FLOW_ACT_VF)) {
> flow->npc_action = NIX_RX_ACTIONOP_UCAST;
> if (req_act & OTX2_FLOW_ACT_QUEUE)
> flow->npc_action |= (uint64_t)rq << 20;
> @@ -1032,6 +1083,11 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev,
> otx2_eth_set_rx_function(dev);
> }
>
> + if (npc->vtag_actions == 1) {
> + hw->rx_offload_flags |= NIX_RX_OFFLOAD_VLAN_STRIP_F;
> + otx2_eth_set_rx_function(dev);
> + }
> +
> set_pf_func:
> /* Ideally AF must ensure that correct pf_func is set */
> flow->npc_action |= (uint64_t)pf_func << 4;
> diff --git a/drivers/net/octeontx2/otx2_flow_utils.c b/drivers/net/octeontx2/otx2_flow_utils.c
> index 14625c9ad..6215a542f 100644
> --- a/drivers/net/octeontx2/otx2_flow_utils.c
> +++ b/drivers/net/octeontx2/otx2_flow_utils.c
> @@ -916,20 +916,7 @@ otx2_flow_mcam_alloc_and_write(struct rte_flow *flow, struct otx2_mbox *mbox,
> (flow->nix_intf == OTX2_INTF_RX) ? NPC_MCAM_RX : NPC_MCAM_TX;
> req->enable_entry = 1;
> req->entry_data.action = flow->npc_action;
> -
> - /*
> - * DPDK sets vtag action on per interface basis, not
> - * per flow basis. It is a matter of how we decide to support
> - * this pmd specific behavior. There are two ways:
> - * 1. Inherit the vtag action from the one configured
> - * for this interface. This can be read from the
> - * vtag_action configured for default mcam entry of
> - * this pf_func.
> - * 2. Do not support vtag action with rte_flow.
> - *
> - * Second approach is used now.
> - */
> - req->entry_data.vtag_action = 0ULL;
> + req->entry_data.vtag_action = flow->vtag_action;
>
> for (idx = 0; idx < OTX2_MAX_MCAM_WIDTH_DWORDS; idx++) {
> req->entry_data.kw[idx] = flow->mcam_data[idx];
> --
> 2.25.1
>
prev parent reply other threads:[~2020-09-29 9:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-24 7:04 kirankumark
2020-09-29 9:51 ` Jerin Jacob [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALBAE1P=_fWPRsavRL-KNuWPhW2_AGbHGD6xGO12XrwtcDj74Q@mail.gmail.com' \
--to=jerinjacobk@gmail.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=john.mcnamara@intel.com \
--cc=kirankumark@marvell.com \
--cc=marko.kovacevic@intel.com \
--cc=ndabilpuram@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).