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 7C833A0563; Wed, 15 Apr 2020 10:25:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 152901D600; Wed, 15 Apr 2020 10:20:37 +0200 (CEST) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by dpdk.org (Postfix) with ESMTP id 323A21D5EA for ; Wed, 15 Apr 2020 10:20:34 +0200 (CEST) Received: by mail-pg1-f173.google.com with SMTP id i3so1176150pgk.1 for ; Wed, 15 Apr 2020 01:20:34 -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=7YM7yZ71rh4I+l8lwRJqn9srHwtf/bN5cwja4/J5T/0=; b=LHLoals1jj6MjhBN329udaSh1eFBkUgaZWzvANjby/quRnqNjUelKiwcrDXdjNOoM9 jGpVIvXi0ejJsNWOonBMoIDKHqwedSv9fZQgC/4U5WNbIvTURZi6iTqPmb3ptluHDk1V NVtjljbjsnewiuvDsQPsqOUnr5KtiHnlXJOSc= 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=7YM7yZ71rh4I+l8lwRJqn9srHwtf/bN5cwja4/J5T/0=; b=m7LLjhjHL7EpjdcXrEY6P5XNZXEsSUaABGfmZNTgCAhKs64dOzWFgPOM0mfPbs8au5 QVp5yfJ8cjp01kJJHrkLzYwKCb0icvjaMOl05EjmC32Ccuo5A2HtdZ+KR/FO/Oyf0WNc zEUWnIAIWMYM64EfR9bchyXet13e/Fta1F93M4Iurf5xPcNVvGejlqNZWdbvlQnHjAs/ 17ql+UiywlQRVGXlRqLFAV4zabrknfHWPXaaz5R0QFt6xFDRynaxYKjvPVjvoDpFc9m9 HwyGEnXnGk0oo/EPZ//WJFRTp3vSVn1lUI9JKYsf+FsDKMRvZFug57P9gQZ+J6frmlID dNCw== X-Gm-Message-State: AGi0PubTgGy6Ix5FDmdW/JuJYxZ/do4Fi/3/+IId7QtoqARZdp3SJX3r jzJn6KUOL0m/2kKMHsLtx445AW8fHOO1lWYCCNh/DX4f4gRn0ENnt1sutERMbolZSzqAK/y2Rw6 r3TnxTasVbMxXrBm6wrJn3bkRvhl7DQiUreLnHKSnZ3Aov/+ucE4Odw34YRzl4FTwskMV X-Google-Smtp-Source: APiQypJo0DyovD0QB+axEYv6I48TM6s3ADa5jjBoeEqvjA006+wkPlWXYAgQAWa99Bo/aKXqzKJEYg== X-Received: by 2002:a63:721e:: with SMTP id n30mr24096668pgc.94.1586938832492; Wed, 15 Apr 2020 01:20:32 -0700 (PDT) Received: from S60.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id fy21sm3819019pjb.25.2020.04.15.01.20.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Apr 2020 01:20:31 -0700 (PDT) From: Venkat Duvvuru To: dev@dpdk.org Cc: Kishore Padmanabha , Venkat Duvvuru Date: Wed, 15 Apr 2020 13:49:03 +0530 Message-Id: <1586938751-32808-27-git-send-email-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586938751-32808-1-git-send-email-venkatkumar.duvvuru@broadcom.com> References: <1586852011-37536-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <1586938751-32808-1-git-send-email-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH v4 26/34] net/bnxt: add support for rte flow action parsing 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. Registers a callback handler for each rte_flow_action type, if it is supported 2. Iterates through each rte_flow_action till RTE_FLOW_ACTION_TYPE_END 3. Invokes the action call back handler 4. Each action call back handler will populate the respective fields in act_details & act_bitmap Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Lance Richardson Reviewed-by: Ajit Kumar Khaparde --- drivers/net/bnxt/tf_ulp/bnxt_tf_common.h | 7 + drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 441 ++++++++++++++++++++++++++ drivers/net/bnxt/tf_ulp/ulp_rte_parser.h | 85 ++++- drivers/net/bnxt/tf_ulp/ulp_template_db.c | 199 ++++++++++++ drivers/net/bnxt/tf_ulp/ulp_template_db.h | 7 + drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 13 + 6 files changed, 751 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h b/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h index e4ebfc5..f417579 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h +++ b/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h @@ -31,6 +31,13 @@ enum bnxt_tf_rc { BNXT_TF_RC_SUCCESS = 0 }; +/* eth IPv4 Type */ +enum bnxt_ulp_eth_ip_type { + BNXT_ULP_ETH_IPV4 = 4, + BNXT_ULP_ETH_IPV6 = 5, + BNXT_ULP_MAX_ETH_IP_TYPE = 0 +}; + /* ulp direction Type */ enum ulp_direction_type { ULP_DIR_INGRESS, diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index 3ffdcbd..7a31b43 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -30,6 +30,21 @@ static inline void ulp_util_field_int_write(uint8_t *buffer, memcpy(buffer, &temp_val, sizeof(uint32_t)); } +/* Utility function to skip the void items. */ +static inline int32_t +ulp_rte_item_skip_void(const struct rte_flow_item **item, uint32_t increment) +{ + if (!*item) + return 0; + if (increment) + (*item)++; + while ((*item) && (*item)->type == RTE_FLOW_ITEM_TYPE_VOID) + (*item)++; + if (*item) + return 1; + return 0; +} + /* * Function to handle the parsing of RTE Flows and placing * the RTE flow items into the ulp structures. @@ -73,6 +88,45 @@ bnxt_ulp_rte_parser_hdr_parse(const struct rte_flow_item pattern[], return BNXT_TF_RC_SUCCESS; } +/* + * Function to handle the parsing of RTE Flows and placing + * the RTE flow actions into the ulp structures. + */ +int32_t +bnxt_ulp_rte_parser_act_parse(const struct rte_flow_action actions[], + struct ulp_rte_act_bitmap *act_bitmap, + struct ulp_rte_act_prop *act_prop) +{ + const struct rte_flow_action *action_item = actions; + struct bnxt_ulp_rte_act_info *hdr_info; + + /* Parse all the items in the pattern */ + while (action_item && action_item->type != RTE_FLOW_ACTION_TYPE_END) { + /* get the header information from the flow_hdr_info table */ + hdr_info = &ulp_act_info[action_item->type]; + if (hdr_info->act_type == + BNXT_ULP_ACT_TYPE_NOT_SUPPORTED) { + BNXT_TF_DBG(ERR, + "Truflow parser does not support act %u\n", + action_item->type); + return BNXT_TF_RC_ERROR; + } else if (hdr_info->act_type == + BNXT_ULP_ACT_TYPE_SUPPORTED) { + /* call the registered callback handler */ + if (hdr_info->proto_act_func) { + if (hdr_info->proto_act_func(action_item, + act_bitmap, + act_prop) != + BNXT_TF_RC_SUCCESS) { + return BNXT_TF_RC_ERROR; + } + } + } + action_item++; + } + return BNXT_TF_RC_SUCCESS; +} + /* Function to handle the parsing of RTE Flow item PF Header. */ static int32_t ulp_rte_parser_svif_set(struct ulp_rte_hdr_bitmap *hdr_bitmap, @@ -765,3 +819,390 @@ ulp_rte_void_hdr_handler(const struct rte_flow_item *item __rte_unused, { return BNXT_TF_RC_SUCCESS; } + +/* Function to handle the parsing of RTE Flow action void Header. */ +int32_t +ulp_rte_void_act_handler(const struct rte_flow_action *action_item __rte_unused, + struct ulp_rte_act_bitmap *act __rte_unused, + struct ulp_rte_act_prop *act_prop __rte_unused) +{ + return BNXT_TF_RC_SUCCESS; +} + +/* Function to handle the parsing of RTE Flow action Mark Header. */ +int32_t +ulp_rte_mark_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop) +{ + const struct rte_flow_action_mark *mark; + uint32_t mark_id = 0; + + mark = action_item->conf; + if (mark) { + mark_id = tfp_cpu_to_be_32(mark->id); + memcpy(&act_prop->act_details[BNXT_ULP_ACT_PROP_IDX_MARK], + &mark_id, BNXT_ULP_ACT_PROP_SZ_MARK); + + /* Update the hdr_bitmap with vxlan */ + ULP_BITMAP_SET(act->bits, BNXT_ULP_ACTION_BIT_MARK); + return BNXT_TF_RC_SUCCESS; + } + BNXT_TF_DBG(ERR, "Parse Error: Mark arg is invalid\n"); + return BNXT_TF_RC_ERROR; +} + +/* Function to handle the parsing of RTE Flow action RSS Header. */ +int32_t +ulp_rte_rss_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop __rte_unused) +{ + const struct rte_flow_action_rss *rss; + + rss = action_item->conf; + if (rss) { + /* Update the hdr_bitmap with vxlan */ + ULP_BITMAP_SET(act->bits, BNXT_ULP_ACTION_BIT_RSS); + return BNXT_TF_RC_SUCCESS; + } + BNXT_TF_DBG(ERR, "Parse Error: RSS arg is invalid\n"); + return BNXT_TF_RC_ERROR; +} + +/* Function to handle the parsing of RTE Flow action vxlan_encap Header. */ +int32_t +ulp_rte_vxlan_encap_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *ap) +{ + const struct rte_flow_action_vxlan_encap *vxlan_encap; + const struct rte_flow_item *item; + const struct rte_flow_item_eth *eth_spec; + const struct rte_flow_item_ipv4 *ipv4_spec; + const struct rte_flow_item_ipv6 *ipv6_spec; + struct rte_flow_item_vxlan vxlan_spec; + uint32_t vlan_num = 0, vlan_size = 0; + uint32_t ip_size = 0, ip_type = 0; + uint32_t vxlan_size = 0; + uint8_t *buff; + /* IP header per byte - ver/hlen, TOS, ID, ID, FRAG, FRAG, TTL, PROTO */ + const uint8_t def_ipv4_hdr[] = {0x45, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x40, 0x11}; + + vxlan_encap = action_item->conf; + if (!vxlan_encap) { + BNXT_TF_DBG(ERR, "Parse Error: Vxlan_encap arg is invalid\n"); + return BNXT_TF_RC_ERROR; + } + + item = vxlan_encap->definition; + if (!item) { + BNXT_TF_DBG(ERR, "Parse Error: definition arg is invalid\n"); + return BNXT_TF_RC_ERROR; + } + + if (!ulp_rte_item_skip_void(&item, 0)) + return BNXT_TF_RC_ERROR; + + /* must have ethernet header */ + if (item->type != RTE_FLOW_ITEM_TYPE_ETH) { + BNXT_TF_DBG(ERR, "Parse Error:vxlan encap does not have eth\n"); + return BNXT_TF_RC_ERROR; + } + eth_spec = item->spec; + buff = &ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_DMAC]; + ulp_encap_buffer_copy(buff, + eth_spec->dst.addr_bytes, + BNXT_ULP_ACT_PROP_SZ_ENCAP_L2_DMAC); + + /* Goto the next item */ + if (!ulp_rte_item_skip_void(&item, 1)) + return BNXT_TF_RC_ERROR; + + /* May have vlan header */ + if (item->type == RTE_FLOW_ITEM_TYPE_VLAN) { + vlan_num++; + buff = &ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG]; + ulp_encap_buffer_copy(buff, + item->spec, + sizeof(struct rte_flow_item_vlan)); + + if (!ulp_rte_item_skip_void(&item, 1)) + return BNXT_TF_RC_ERROR; + } + + /* may have two vlan headers */ + if (item->type == RTE_FLOW_ITEM_TYPE_VLAN) { + vlan_num++; + memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG + + sizeof(struct rte_flow_item_vlan)], + item->spec, + sizeof(struct rte_flow_item_vlan)); + if (!ulp_rte_item_skip_void(&item, 1)) + return BNXT_TF_RC_ERROR; + } + /* Update the vlan count and size of more than one */ + if (vlan_num) { + vlan_size = vlan_num * sizeof(struct rte_flow_item_vlan); + vlan_num = tfp_cpu_to_be_32(vlan_num); + memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG_NUM], + &vlan_num, + sizeof(uint32_t)); + vlan_size = tfp_cpu_to_be_32(vlan_size); + memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG_SZ], + &vlan_size, + sizeof(uint32_t)); + } + + /* L3 must be IPv4, IPv6 */ + if (item->type == RTE_FLOW_ITEM_TYPE_IPV4) { + ipv4_spec = item->spec; + ip_size = BNXT_ULP_ENCAP_IPV4_SIZE; + + /* copy the ipv4 details */ + if (ulp_buffer_is_empty(&ipv4_spec->hdr.version_ihl, + BNXT_ULP_ENCAP_IPV4_VER_HLEN_TOS)) { + buff = &ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_IP]; + ulp_encap_buffer_copy(buff, + def_ipv4_hdr, + BNXT_ULP_ENCAP_IPV4_VER_HLEN_TOS + + BNXT_ULP_ENCAP_IPV4_ID_PROTO); + } else { + const uint8_t *tmp_buff; + + buff = &ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_IP]; + ulp_encap_buffer_copy(buff, + &ipv4_spec->hdr.version_ihl, + BNXT_ULP_ENCAP_IPV4_VER_HLEN_TOS); + buff = &ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_IP + + BNXT_ULP_ENCAP_IPV4_VER_HLEN_TOS]; + tmp_buff = (const uint8_t *)&ipv4_spec->hdr.packet_id; + ulp_encap_buffer_copy(buff, + tmp_buff, + BNXT_ULP_ENCAP_IPV4_ID_PROTO); + } + buff = &ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_IP + + BNXT_ULP_ENCAP_IPV4_VER_HLEN_TOS + + BNXT_ULP_ENCAP_IPV4_ID_PROTO]; + ulp_encap_buffer_copy(buff, + (const uint8_t *)&ipv4_spec->hdr.dst_addr, + BNXT_ULP_ENCAP_IPV4_DEST_IP); + + /* Update the ip size details */ + ip_size = tfp_cpu_to_be_32(ip_size); + memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_IP_SZ], + &ip_size, sizeof(uint32_t)); + + /* update the ip type */ + ip_type = rte_cpu_to_be_32(BNXT_ULP_ETH_IPV4); + memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_L3_TYPE], + &ip_type, sizeof(uint32_t)); + + if (!ulp_rte_item_skip_void(&item, 1)) + return BNXT_TF_RC_ERROR; + } else if (item->type == RTE_FLOW_ITEM_TYPE_IPV6) { + ipv6_spec = item->spec; + ip_size = BNXT_ULP_ENCAP_IPV6_SIZE; + + /* copy the ipv4 details */ + memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_IP], + ipv6_spec, BNXT_ULP_ENCAP_IPV6_SIZE); + + /* Update the ip size details */ + ip_size = tfp_cpu_to_be_32(ip_size); + memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_IP_SZ], + &ip_size, sizeof(uint32_t)); + + /* update the ip type */ + ip_type = rte_cpu_to_be_32(BNXT_ULP_ETH_IPV6); + memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_L3_TYPE], + &ip_type, sizeof(uint32_t)); + + if (!ulp_rte_item_skip_void(&item, 1)) + return BNXT_TF_RC_ERROR; + } else { + BNXT_TF_DBG(ERR, "Parse Error: Vxlan Encap expects L3 hdr\n"); + return BNXT_TF_RC_ERROR; + } + + /* L4 is UDP */ + if (item->type != RTE_FLOW_ITEM_TYPE_UDP) { + BNXT_TF_DBG(ERR, "vxlan encap does not have udp\n"); + return BNXT_TF_RC_ERROR; + } + /* copy the udp details */ + ulp_encap_buffer_copy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_UDP], + item->spec, BNXT_ULP_ENCAP_UDP_SIZE); + + if (!ulp_rte_item_skip_void(&item, 1)) + return BNXT_TF_RC_ERROR; + + /* Finally VXLAN */ + if (item->type != RTE_FLOW_ITEM_TYPE_VXLAN) { + BNXT_TF_DBG(ERR, "vxlan encap does not have vni\n"); + return BNXT_TF_RC_ERROR; + } + vxlan_size = sizeof(struct rte_flow_item_vxlan); + /* copy the vxlan details */ + memcpy(&vxlan_spec, item->spec, vxlan_size); + vxlan_spec.flags = 0x08; + ulp_encap_buffer_copy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_TUN], + (const uint8_t *)&vxlan_spec, + vxlan_size); + vxlan_size = tfp_cpu_to_be_32(vxlan_size); + memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_TUN_SZ], + &vxlan_size, sizeof(uint32_t)); + + /*update the hdr_bitmap with vxlan */ + ULP_BITMAP_SET(act->bits, BNXT_ULP_ACTION_BIT_VXLAN_ENCAP); + return BNXT_TF_RC_SUCCESS; +} + +/* Function to handle the parsing of RTE Flow action vxlan_encap Header */ +int32_t +ulp_rte_vxlan_decap_act_handler(const struct rte_flow_action *action_item + __rte_unused, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop __rte_unused) +{ + /* update the hdr_bitmap with vxlan */ + ULP_BITMAP_SET(act->bits, BNXT_ULP_ACTION_BIT_VXLAN_DECAP); + return BNXT_TF_RC_SUCCESS; +} + +/* Function to handle the parsing of RTE Flow action drop Header. */ +int32_t +ulp_rte_drop_act_handler(const struct rte_flow_action *action_item __rte_unused, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop __rte_unused) +{ + /* Update the hdr_bitmap with drop */ + ULP_BITMAP_SET(act->bits, BNXT_ULP_ACTION_BIT_DROP); + return BNXT_TF_RC_SUCCESS; +} + +/* Function to handle the parsing of RTE Flow action count. */ +int32_t +ulp_rte_count_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop __rte_unused) + +{ + const struct rte_flow_action_count *act_count; + + act_count = action_item->conf; + if (act_count) { + if (act_count->shared) { + BNXT_TF_DBG(ERR, + "Parse Error:Shared count not supported\n"); + return BNXT_TF_RC_PARSE_ERR; + } + memcpy(&act_prop->act_details[BNXT_ULP_ACT_PROP_IDX_COUNT], + &act_count->id, + BNXT_ULP_ACT_PROP_SZ_COUNT); + } + + /* Update the hdr_bitmap with count */ + ULP_BITMAP_SET(act->bits, BNXT_ULP_ACTION_BIT_COUNT); + return BNXT_TF_RC_SUCCESS; +} + +/* Function to handle the parsing of RTE Flow action PF. */ +int32_t +ulp_rte_pf_act_handler(const struct rte_flow_action *action_item __rte_unused, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop) +{ + uint8_t *svif_buf; + uint8_t *vnic_buffer; + uint32_t svif; + + /* Update the hdr_bitmap with vnic bit */ + ULP_BITMAP_SET(act->bits, BNXT_ULP_ACTION_BIT_VNIC); + + /* copy the PF of the current device into VNIC Property */ + svif_buf = &act_prop->act_details[BNXT_ULP_ACT_PROP_IDX_VNIC]; + ulp_util_field_int_read(svif_buf, &svif); + vnic_buffer = &act_prop->act_details[BNXT_ULP_ACT_PROP_IDX_VNIC]; + ulp_util_field_int_write(vnic_buffer, svif); + + return BNXT_TF_RC_SUCCESS; +} + +/* Function to handle the parsing of RTE Flow action VF. */ +int32_t +ulp_rte_vf_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop) +{ + const struct rte_flow_action_vf *vf_action; + + vf_action = action_item->conf; + if (vf_action) { + if (vf_action->original) { + BNXT_TF_DBG(ERR, + "Parse Error:VF Original not supported\n"); + return BNXT_TF_RC_PARSE_ERR; + } + /* TBD: Update the computed VNIC using VF conversion */ + memcpy(&act_prop->act_details[BNXT_ULP_ACT_PROP_IDX_VNIC], + &vf_action->id, + BNXT_ULP_ACT_PROP_SZ_VNIC); + } + + /* Update the hdr_bitmap with count */ + ULP_BITMAP_SET(act->bits, BNXT_ULP_ACTION_BIT_VNIC); + return BNXT_TF_RC_SUCCESS; +} + +/* Function to handle the parsing of RTE Flow action port_id. */ +int32_t +ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop) +{ + const struct rte_flow_action_port_id *port_id; + + port_id = act_item->conf; + if (port_id) { + if (port_id->original) { + BNXT_TF_DBG(ERR, + "ParseErr:Portid Original not supported\n"); + return BNXT_TF_RC_PARSE_ERR; + } + /* TBD: Update the computed VNIC using port conversion */ + memcpy(&act_prop->act_details[BNXT_ULP_ACT_PROP_IDX_VNIC], + &port_id->id, + BNXT_ULP_ACT_PROP_SZ_VNIC); + } + + /* Update the hdr_bitmap with count */ + ULP_BITMAP_SET(act->bits, BNXT_ULP_ACTION_BIT_VNIC); + return BNXT_TF_RC_SUCCESS; +} + +/* Function to handle the parsing of RTE Flow action phy_port. */ +int32_t +ulp_rte_phy_port_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop) +{ + const struct rte_flow_action_phy_port *phy_port; + + phy_port = action_item->conf; + if (phy_port) { + if (phy_port->original) { + BNXT_TF_DBG(ERR, + "Parse Err:Port Original not supported\n"); + return BNXT_TF_RC_PARSE_ERR; + } + memcpy(&act_prop->act_details[BNXT_ULP_ACT_PROP_IDX_VPORT], + &phy_port->index, + BNXT_ULP_ACT_PROP_SZ_VPORT); + } + + /* Update the hdr_bitmap with count */ + ULP_BITMAP_SET(act->bits, BNXT_ULP_ACTION_BIT_VPORT); + return BNXT_TF_RC_SUCCESS; +} diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h index 3a7845d..0ab43d2 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h @@ -12,6 +12,14 @@ #include "ulp_template_db.h" #include "ulp_template_struct.h" +/* defines to be used in the tunnel header parsing */ +#define BNXT_ULP_ENCAP_IPV4_VER_HLEN_TOS 2 +#define BNXT_ULP_ENCAP_IPV4_ID_PROTO 6 +#define BNXT_ULP_ENCAP_IPV4_DEST_IP 4 +#define BNXT_ULP_ENCAP_IPV4_SIZE 12 +#define BNXT_ULP_ENCAP_IPV6_SIZE 8 +#define BNXT_ULP_ENCAP_UDP_SIZE 4 + /* * Function to handle the parsing of RTE Flows and placing * the RTE flow items into the ulp structures. @@ -21,6 +29,15 @@ bnxt_ulp_rte_parser_hdr_parse(const struct rte_flow_item pattern[], struct ulp_rte_hdr_bitmap *hdr_bitmap, struct ulp_rte_hdr_field *hdr_field); +/* + * Function to handle the parsing of RTE Flows and placing + * the RTE flow actions into the ulp structures. + */ +int32_t +bnxt_ulp_rte_parser_act_parse(const struct rte_flow_action actions[], + struct ulp_rte_act_bitmap *act_bitmap, + struct ulp_rte_act_prop *act_prop); + /* Function to handle the parsing of RTE Flow item PF Header. */ int32_t ulp_rte_pf_hdr_handler(const struct rte_flow_item *item, @@ -45,7 +62,7 @@ ulp_rte_port_id_hdr_handler(const struct rte_flow_item *item, uint32_t *field_idx, uint32_t *vlan_idx); -/* Function to handle the parsing of RTE Flow item port id Header. */ +/* Function to handle the parsing of RTE Flow item port Header. */ int32_t ulp_rte_phy_port_hdr_handler(const struct rte_flow_item *item, struct ulp_rte_hdr_bitmap *hdr_bitmap, @@ -117,4 +134,70 @@ ulp_rte_void_hdr_handler(const struct rte_flow_item *item, uint32_t *field_idx, uint32_t *vlan_idx); +/* Function to handle the parsing of RTE Flow action void Header. */ +int32_t +ulp_rte_void_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop); + +/* Function to handle the parsing of RTE Flow action RSS Header. */ +int32_t +ulp_rte_rss_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop); + +/* Function to handle the parsing of RTE Flow action Mark Header. */ +int32_t +ulp_rte_mark_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop); + +/* Function to handle the parsing of RTE Flow action vxlan_encap Header. */ +int32_t +ulp_rte_vxlan_encap_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop); + +/* Function to handle the parsing of RTE Flow action vxlan_encap Header. */ +int32_t +ulp_rte_vxlan_decap_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop); + +/* Function to handle the parsing of RTE Flow action drop Header. */ +int32_t +ulp_rte_drop_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop); + +/* Function to handle the parsing of RTE Flow action count. */ +int32_t +ulp_rte_count_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop); + +/* Function to handle the parsing of RTE Flow action PF. */ +int32_t +ulp_rte_pf_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop); + +/* Function to handle the parsing of RTE Flow action VF. */ +int32_t +ulp_rte_vf_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop); + +/* Function to handle the parsing of RTE Flow action port_id. */ +int32_t +ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_p); + +/* Function to handle the parsing of RTE Flow action phy_port. */ +int32_t +ulp_rte_phy_port_act_handler(const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act, + struct ulp_rte_act_prop *act_prop); + #endif /* _ULP_RTE_PARSER_H_ */ diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db.c b/drivers/net/bnxt/tf_ulp/ulp_template_db.c index 6c214b2..411f1e3 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db.c +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db.c @@ -96,6 +96,205 @@ uint32_t ulp_act_prop_map_table[] = { BNXT_ULP_ACT_PROP_SZ_LAST }; +struct bnxt_ulp_rte_act_info ulp_act_info[] = { + [RTE_FLOW_ACTION_TYPE_END] = { + .act_type = BNXT_ULP_ACT_TYPE_END, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_VOID] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_void_act_handler + }, + [RTE_FLOW_ACTION_TYPE_PASSTHRU] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_JUMP] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_MARK] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_mark_act_handler + }, + [RTE_FLOW_ACTION_TYPE_FLAG] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_QUEUE] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_DROP] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_drop_act_handler + }, + [RTE_FLOW_ACTION_TYPE_COUNT] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_count_act_handler + }, + [RTE_FLOW_ACTION_TYPE_RSS] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_rss_act_handler + }, + [RTE_FLOW_ACTION_TYPE_PF] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_pf_act_handler + }, + [RTE_FLOW_ACTION_TYPE_VF] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_vf_act_handler + }, + [RTE_FLOW_ACTION_TYPE_PHY_PORT] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_phy_port_act_handler + }, + [RTE_FLOW_ACTION_TYPE_PORT_ID] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_port_id_act_handler + }, + [RTE_FLOW_ACTION_TYPE_METER] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_SECURITY] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_OF_POP_VLAN] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_OF_POP_MPLS] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_vxlan_encap_act_handler + }, + [RTE_FLOW_ACTION_TYPE_VXLAN_DECAP] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_vxlan_decap_act_handler + }, + [RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_NVGRE_DECAP] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_RAW_ENCAP] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_RAW_DECAP] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_SET_IPV4_DST] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_SET_IPV6_DST] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_SET_TP_SRC] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_SET_TP_DST] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_MAC_SWAP] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_DEC_TTL] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_SET_TTL] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_SET_MAC_SRC] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_SET_MAC_DST] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_INC_TCP_ACK] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + }, + [RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK] = { + .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, + .proto_act_func = NULL + } +}; + struct bnxt_ulp_device_params ulp_device_params[] = { [BNXT_ULP_DEVICE_ID_WH_PLUS] = { .global_fid_enable = BNXT_ULP_SYM_YES, diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db.h b/drivers/net/bnxt/tf_ulp/ulp_template_db.h index 906b542..dfab266 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db.h @@ -74,6 +74,13 @@ enum bnxt_ulp_hdr_bit { BNXT_ULP_HDR_BIT_LAST = 0x0000000000200000 }; +enum bnxt_ulp_act_type { + BNXT_ULP_ACT_TYPE_NOT_SUPPORTED = 0, + BNXT_ULP_ACT_TYPE_SUPPORTED = 1, + BNXT_ULP_ACT_TYPE_END = 2, + BNXT_ULP_ACT_TYPE_LAST = 3 +}; + enum bnxt_ulp_byte_order { BNXT_ULP_BYTE_ORDER_BE, BNXT_ULP_BYTE_ORDER_LE, diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h index 0699634..47c0dd8 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h @@ -72,6 +72,19 @@ struct ulp_rte_act_prop { uint8_t act_details[BNXT_ULP_ACT_PROP_IDX_LAST]; }; +/* Flow Parser Action Information Structure */ +struct bnxt_ulp_rte_act_info { + enum bnxt_ulp_act_type act_type; + /* Flow Parser Protocol Action Function Prototype */ + int32_t (*proto_act_func) + (const struct rte_flow_action *action_item, + struct ulp_rte_act_bitmap *act_bitmap, + struct ulp_rte_act_prop *act_prop); +}; + +/* Flow Parser Action Information Structure Array defined in template source*/ +extern struct bnxt_ulp_rte_act_info ulp_act_info[]; + /* Flow Matcher structures */ struct bnxt_ulp_header_match_info { struct ulp_rte_hdr_bitmap hdr_bitmap; -- 2.7.4