From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8FF09A0577; Mon, 13 Apr 2020 21:47:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D600E1C0B4; Mon, 13 Apr 2020 21:42:55 +0200 (CEST) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 8038B1C1E6 for ; Mon, 13 Apr 2020 21:42:52 +0200 (CEST) Received: by mail-pf1-f193.google.com with SMTP id r20so3316045pfh.9 for ; Mon, 13 Apr 2020 12:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hmmihKI/fy3B8Q89yjaOQY4ITGY9iRlonej5aa7Yz8M=; b=RxlhDqgTISpKgENYNy0jwZf/oUZ/eDYSkUDYa9kOfCLoGBxrRd0pJ1D0tHK9MxDyLQ RNQkdT5e/9Roc3VsrGaFffE60dmepzZD/QCeiOZNCXFZ5a2UiIirvON4m+Od2+/tdQxP nvCxAh7NM5Raqu5AmclSA3l0mFGn2GrAh+99E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hmmihKI/fy3B8Q89yjaOQY4ITGY9iRlonej5aa7Yz8M=; b=MI8UG8Fq2VDNRPaLu0SBPzxDGWYNUQ9bBlDuMvoGHC0BBK5TaIVOF7T7GBy35dWcrw 64uKwPOprURJysGQrHRgHJ6dLEpCNQCj863lNBMbUStKGigwFwn9ndbfhEtUbUQHKgur l+xeWP4jZ2/NlWAfiLCHt23HEpB901IFTE0ue9C7KOpO1L6s6DbNaxCbhUjpRjtXPzYm K6Zk1QPuUCp6ykcOqTal7sClP0C2/+gj2mPdBMJ+x2LaUfdwBofSEb82fukgnJEsLUg2 qefMElj4Xi8QJEmUk6SKgzHjga3dyeSEmc7C09hmSL5kNK2fMF0lu2dH0U0vrquq2aVS XuZQ== X-Gm-Message-State: AGi0PubTeAJTzCQaX/NdMWPL7DePlrQPdky9ie4xt3lp2RwdqNrBqdKF yVcW0KAq3uFvdTYo2m6HYWtC10wrmjNFnAvVP1myGXl8o1Ae6Ff8hrpBuistYetbRdnexxSj4sW OTmyVnkpa43uX+paMeQiCQD5kSsLjyhvWy63gCdkQqRV1sn0nyEcujYpnXCuUGQj0Djm/ X-Google-Smtp-Source: APiQypIkFpub96g1U3tdg0CORUXCUfxCP6gI3Zt12A5xbWJGWD1TsvJWsKplI2r6Tca9tRI6PZruig== X-Received: by 2002:aa7:9207:: with SMTP id 7mr19174624pfo.178.1586806971219; Mon, 13 Apr 2020 12:42:51 -0700 (PDT) Received: from S60.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 9sm1381663pfn.204.2020.04.13.12.42.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Apr 2020 12:42:50 -0700 (PDT) From: Venkat Duvvuru To: dev@dpdk.org Cc: Kishore Padmanabha , Venkat Duvvuru Date: Tue, 14 Apr 2020 01:10:04 +0530 Message-Id: <1586806811-21736-28-git-send-email-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586806811-21736-1-git-send-email-venkatkumar.duvvuru@broadcom.com> References: <1584459511-5353-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <1586806811-21736-1-git-send-email-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH v2 27/34] net/bnxt: add support for rte flow create driver hook X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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: Kishore Padmanabha This patch does the following 1. Validates rte_flow_create arguments 2. Parses rte_flow_item types 3. Parses rte_flow_action types 4. Calls ulp_matcher_pattern_match to see if the flow is supported 5. If there is a match, calls ulp_mapper_flow_create to program key & action tables Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Lance Richardson Reviewed-by: Ajit Kumar Khaparde --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 177 ++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+) create mode 100644 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 5e2d751..5ed33cc 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -65,6 +65,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_utils.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_mapper.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_matcher.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_rte_parser.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/bnxt_ulp_flow.c # # Export include files diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c new file mode 100644 index 0000000..6402dd3 --- /dev/null +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c @@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2014-2020 Broadcom + * All rights reserved. + */ + +#include "bnxt.h" +#include "bnxt_tf_common.h" +#include "ulp_rte_parser.h" +#include "ulp_matcher.h" +#include "ulp_flow_db.h" +#include "ulp_mapper.h" +#include + +static int32_t +bnxt_ulp_flow_validate_args(const struct rte_flow_attr *attr, + const struct rte_flow_item pattern[], + const struct rte_flow_action actions[], + struct rte_flow_error *error) +{ + /* Perform the validation of the arguments for null */ + if (!error) + return BNXT_TF_RC_ERROR; + + if (!pattern) { + rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM_NUM, + NULL, + "NULL pattern."); + return BNXT_TF_RC_ERROR; + } + + if (!actions) { + rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_NUM, + NULL, + "NULL action."); + return BNXT_TF_RC_ERROR; + } + + if (!attr) { + rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR, + NULL, + "NULL attribute."); + return BNXT_TF_RC_ERROR; + } + + if (attr->egress && attr->ingress) { + rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR, + attr, + "EGRESS AND INGRESS UNSUPPORTED"); + return BNXT_TF_RC_ERROR; + } + return BNXT_TF_RC_SUCCESS; +} + +/* Function to create the rte flow. */ +static struct rte_flow * +bnxt_ulp_flow_create(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, + const struct rte_flow_item pattern[], + const struct rte_flow_action actions[], + struct rte_flow_error *error) +{ + struct ulp_rte_hdr_bitmap hdr_bitmap; + struct ulp_rte_hdr_field hdr_field[BNXT_ULP_PROTO_HDR_MAX]; + struct ulp_rte_act_bitmap act_bitmap; + struct ulp_rte_act_prop act_prop; + enum ulp_direction_type dir = ULP_DIR_INGRESS; + uint32_t class_id, act_tmpl; + uint32_t app_priority; + int ret; + struct bnxt_ulp_context *ulp_ctx = NULL; + uint32_t vnic; + uint8_t svif; + struct rte_flow *flow_id; + uint32_t fid; + + if (bnxt_ulp_flow_validate_args(attr, + pattern, actions, + error) == BNXT_TF_RC_ERROR) { + BNXT_TF_DBG(ERR, "Invalid arguments being passed\n"); + return NULL; + } + + ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(dev); + if (!ulp_ctx) { + BNXT_TF_DBG(ERR, "ULP context is not initialized\n"); + return NULL; + } + + /* clear the header bitmap and field structure */ + memset(&hdr_bitmap, 0, sizeof(struct ulp_rte_hdr_bitmap)); + memset(hdr_field, 0, sizeof(hdr_field)); + memset(&act_bitmap, 0, sizeof(act_bitmap)); + memset(&act_prop, 0, sizeof(act_prop)); + + svif = bnxt_get_svif(dev->data->port_id, false); + BNXT_TF_DBG(ERR, "SVIF for port[%d][port]=0x%08x\n", + dev->data->port_id, svif); + + hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].size = sizeof(svif); + hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec[0] = svif; + hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].mask[0] = -1; + ULP_BITMAP_SET(hdr_bitmap.bits, BNXT_ULP_HDR_BIT_SVIF); + + /* + * VNIC is being pushed as 32bit and the pop will take care of + * proper size + */ + vnic = (uint32_t)bnxt_get_vnic_id(dev->data->port_id); + vnic = htonl(vnic); + rte_memcpy(&act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC], + &vnic, BNXT_ULP_ACT_PROP_SZ_VNIC); + + /* Parse the rte flow pattern */ + ret = bnxt_ulp_rte_parser_hdr_parse(pattern, + &hdr_bitmap, + hdr_field); + if (ret != BNXT_TF_RC_SUCCESS) + goto parse_error; + + /* Parse the rte flow action */ + ret = bnxt_ulp_rte_parser_act_parse(actions, + &act_bitmap, + &act_prop); + if (ret != BNXT_TF_RC_SUCCESS) + goto parse_error; + + if (attr->egress) + dir = ULP_DIR_EGRESS; + + ret = ulp_matcher_pattern_match(dir, &hdr_bitmap, hdr_field, + &act_bitmap, &class_id); + + if (ret != BNXT_TF_RC_SUCCESS) + goto parse_error; + + ret = ulp_matcher_action_match(dir, &act_bitmap, &act_tmpl); + if (ret != BNXT_TF_RC_SUCCESS) + goto parse_error; + + app_priority = attr->priority; + /* call the ulp mapper to create the flow in the hardware */ + ret = ulp_mapper_flow_create(ulp_ctx, + app_priority, + &hdr_bitmap, + hdr_field, + &act_bitmap, + &act_prop, + class_id, + act_tmpl, + &fid); + if (!ret) { + flow_id = (struct rte_flow *)((uintptr_t)fid); + return flow_id; + } + +parse_error: + rte_flow_error_set(error, ret, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, + "Failed to create flow."); + return NULL; +} + +const struct rte_flow_ops bnxt_ulp_rte_flow_ops = { + .validate = NULL, + .create = bnxt_ulp_flow_create, + .destroy = NULL, + .flush = NULL, + .query = NULL, + .isolate = NULL +}; -- 2.7.4