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 6D88FA0565; Tue, 17 Mar 2020 16:45:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8AD131C1D8; Tue, 17 Mar 2020 16:40:02 +0100 (CET) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by dpdk.org (Postfix) with ESMTP id 8F5371C19E for ; Tue, 17 Mar 2020 16:39:58 +0100 (CET) Received: by mail-wm1-f66.google.com with SMTP id a132so21977668wme.1 for ; Tue, 17 Mar 2020 08:39:58 -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=z9jKKJJO9EzUs8leQlzsq3zf3600//xIfPAbqgSBAbM=; b=YDMUcC+NuZGDwJlYhZAJMq+8De7/mMOc4yd+WReKrrgCzbvqsYa8RVW+qO3VkArY96 v27GUxa2+HBfbAG+RJbc5xSbPUcfCkY8hU5SdtrgBcR9UbG5QytPrSCk7+4n2Ru/VAv7 S4fOfJajcYU5dEReT1+t5o5N2Szr+TWKEygfc= 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=z9jKKJJO9EzUs8leQlzsq3zf3600//xIfPAbqgSBAbM=; b=fskv9f/fNtY9dpobSRJ26/u0/cSAbSXuA/fRoXkMvuMQw1g1wvw/kxkKUH+LUJR8KP RcC5txeYxfdLTnw/zsjItUJrKo48GWXwx7UH1nzzTzEc/baAG6n5EmqHH8ic6OaAfoQe QsMX652FKdnp737DmzfGwjUmU6hMaSr46CqhLeH+bnpqG2kCUdI+WjTbccc01So9SzJP +9qeu18Ss/wGdiP96bsHwv1zFTjPa7z9xjFlYBVHbeKnFp7ejyV/9tcCI4RmO8RPGPYS FBOn3FQwV4pQvBkmDFnBd6wlsFW3BRwf2QYPv16+Jj2UgkBPrpkjk9v6k7ydtnL3SPiF B9rA== X-Gm-Message-State: ANhLgQ2Hqj9rf/8dO4mG/Q0ZaZtpxsWnEnU4AWIzxHuZGj3OrZby+hdv Myj11tO2pVUdyQ+JJd2e9KtSk6vF5BiJzYg7PhRONF91fuBS1Itp4PSDbnssK74PgtGytjLkunj ZP783cvtpyHv5X4dL6gQ4BYx7AgEWobCj5RiPQ13TJr0X4LMhpixIJi3rmhXM8Wjoh0LV X-Google-Smtp-Source: ADFU+vuRvnB6j2X3P7fsRqdwGDTyR2rqqVkbJ4y+EKqBw9DsjC7iJhAAz+KNeiNBlZByzg0AuOwv8A== X-Received: by 2002:a1c:7e57:: with SMTP id z84mr5787381wmc.148.1584459597916; Tue, 17 Mar 2020 08:39:57 -0700 (PDT) Received: from S60.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id q4sm5052142wro.56.2020.03.17.08.39.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Mar 2020 08:39:57 -0700 (PDT) From: Venkat Duvvuru To: dev@dpdk.org Cc: Kishore Padmanabha , Venkat Duvvuru Date: Tue, 17 Mar 2020 21:08:24 +0530 Message-Id: <1584459511-5353-27-git-send-email-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1584459511-5353-1-git-send-email-venkatkumar.duvvuru@broadcom.com> References: <1584459511-5353-1-git-send-email-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH 26/33] 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 29d45e7..bce5632 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -65,6 +65,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_TRUFLOW) += tf_ulp/ulp_utils.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_TRUFLOW) += tf_ulp/ulp_mapper.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_TRUFLOW) += tf_ulp/ulp_matcher.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_TRUFLOW) += tf_ulp/ulp_rte_parser.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_TRUFLOW) += 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