From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7D3FBA0C52; Wed, 13 Oct 2021 19:36:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C853B411CE; Wed, 13 Oct 2021 19:35:16 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 4A43441166 for ; Wed, 13 Oct 2021 19:35:04 +0200 (CEST) Received: from localhost.localdomain (unknown [5.144.123.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id EA3477F6FD; Wed, 13 Oct 2021 20:35:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru EA3477F6FD DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1634146504; bh=tgFrB5XaIG7OLv4R1Eyu1Ibwh8tRdnWJW/kmPt6sTeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oYjfvOqPQuTMaRiVu/ltKRlUpRE31w/Zc58oWajco1STy52pPwpuHh5wg4j3b7RgG B1vz4ILgGd7IT8u09zJxvlhvf64MmNIV/Xkv5XnPcu0M4rTCPLT/lsap737YMbCTRO fe0z0hFUAN1sb+NQ2A38m5YmK/PCAVGEZgZmOciQ= From: Ivan Malov To: dev@dpdk.org Cc: Ferruh Yigit , Thomas Monjalon , Ori Kam , Andrew Rybchenko , Hyong Youb Kim , John Daley Date: Wed, 13 Oct 2021 20:34:45 +0300 Message-Id: <20211013173448.28621-10-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211013173448.28621-1-ivan.malov@oktetlabs.ru> References: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> <20211013173448.28621-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 09/12] net/enic: support meta flow actions to overrule destinations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Andrew Rybchenko Add support for actions PORT_REPRESENTOR and REPRESENTED_PORT based on the existing support for action PORT_ID. Signed-off-by: Andrew Rybchenko Acked-by: Hyong Youb Kim --- doc/guides/nics/features/enic.ini | 2 + drivers/net/enic/enic_fm_flow.c | 93 +++++++++++++++++++++++++------ 2 files changed, 77 insertions(+), 18 deletions(-) diff --git a/doc/guides/nics/features/enic.ini b/doc/guides/nics/features/enic.ini index a582616c07..ecff6c5f26 100644 --- a/doc/guides/nics/features/enic.ini +++ b/doc/guides/nics/features/enic.ini @@ -62,6 +62,8 @@ of_set_vlan_pcp = Y of_set_vlan_vid = Y passthru = Y port_id = Y +port_representor = Y +represented_port = Y queue = Y rss = Y vxlan_decap = Y diff --git a/drivers/net/enic/enic_fm_flow.c b/drivers/net/enic/enic_fm_flow.c index cd364ee16b..4092ff1f61 100644 --- a/drivers/net/enic/enic_fm_flow.c +++ b/drivers/net/enic/enic_fm_flow.c @@ -1242,6 +1242,35 @@ vf_egress_port_id_action(struct enic_flowman *fm, return 0; } +static int +enic_fm_check_transfer_dst(struct enic *enic, uint16_t dst_port_id, + struct rte_eth_dev **dst_dev, + struct rte_flow_error *error) +{ + struct rte_eth_dev *dev; + + ENICPMD_LOG(DEBUG, "port id %u", dst_port_id); + if (!rte_eth_dev_is_valid_port(dst_port_id)) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, "invalid port_id"); + } + dev = &rte_eth_devices[dst_port_id]; + if (!dev_is_enic(dev)) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, "port_id is not enic"); + } + if (enic->switch_domain_id != pmd_priv(dev)->switch_domain_id) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, "destination and source ports are not in the same switch domain"); + } + + *dst_dev = dev; + return 0; +} + /* Translate flow actions to flowman TCAM entry actions */ static int enic_fm_copy_action(struct enic_flowman *fm, @@ -1446,24 +1475,10 @@ enic_fm_copy_action(struct enic_flowman *fm, vnic_h = enic->fm_vnic_handle; /* This port */ break; } - ENICPMD_LOG(DEBUG, "port id %u", port->id); - if (!rte_eth_dev_is_valid_port(port->id)) { - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - NULL, "invalid port_id"); - } - dev = &rte_eth_devices[port->id]; - if (!dev_is_enic(dev)) { - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - NULL, "port_id is not enic"); - } - if (enic->switch_domain_id != - pmd_priv(dev)->switch_domain_id) { - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - NULL, "destination and source ports are not in the same switch domain"); - } + ret = enic_fm_check_transfer_dst(enic, port->id, &dev, + error); + if (ret) + return ret; vnic_h = pmd_priv(dev)->fm_vnic_handle; overlap |= PORT_ID; /* @@ -1560,6 +1575,48 @@ enic_fm_copy_action(struct enic_flowman *fm, ovlan |= rte_be_to_cpu_16(vid->vlan_vid); break; } + case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR: { + const struct rte_flow_action_ethdev *ethdev; + struct rte_eth_dev *dev; + + ethdev = actions->conf; + ret = enic_fm_check_transfer_dst(enic, ethdev->port_id, + &dev, error); + if (ret) + return ret; + vnic_h = pmd_priv(dev)->fm_vnic_handle; + overlap |= PORT_ID; + /* + * Action PORT_REPRESENTOR implies ingress destination. + * Noting to do. We add an implicit stree at the + * end if needed. + */ + ingress = 1; + break; + } + case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT: { + const struct rte_flow_action_ethdev *ethdev; + struct rte_eth_dev *dev; + + if (overlap & PORT_ID) { + ENICPMD_LOG(DEBUG, "cannot have multiple egress PORT_ID actions"); + goto unsupported; + } + ethdev = actions->conf; + ret = enic_fm_check_transfer_dst(enic, ethdev->port_id, + &dev, error); + if (ret) + return ret; + vnic_h = pmd_priv(dev)->fm_vnic_handle; + overlap |= PORT_ID; + /* Action REPRESENTED_PORT: always egress destination */ + ingress = 0; + ret = vf_egress_port_id_action(fm, dev, vnic_h, &fm_op, + error); + if (ret) + return ret; + break; + } default: goto unsupported; } -- 2.20.1