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 09B6EA0577; Tue, 14 Apr 2020 10:20:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0DD1B1C1CE; Tue, 14 Apr 2020 10:15:14 +0200 (CEST) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id 4B31D1C1CE for ; Tue, 14 Apr 2020 10:15:12 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id h11so4378735plr.11 for ; Tue, 14 Apr 2020 01:15:12 -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 :mime-version:content-transfer-encoding; bh=dMog4HurHdG92ygenIiRNGXBdVu/NvRB+TO4BExLogQ=; b=Vrp0t+o/mW0CiPl+YX99mbemD+wXLEhFvj1yBeEAJKa3vKZKy4hdxr75MWrcQE1g6A cI3EhL9MjVH8Suh91G9bNQq+kvVxsDpFdMpLOAlGhqC4RnVAUvMsOkQy3W3XBMmQ05eC X1jfXAOT2itFwHlhWED9j3eyHDitRSeiALzIQ= 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:mime-version:content-transfer-encoding; bh=dMog4HurHdG92ygenIiRNGXBdVu/NvRB+TO4BExLogQ=; b=coksRDpnhZEvMgaOpnzw4CED8NjBQJZlhjXp3lRVVXjBzz+AFz8Jd00xaiTUuzFYE2 CvVr4nudHXeqOWASEWGRGQmrT5pFLUFGu1DT9TEALliY8GVNLlRGTL2w/lEpYdw2cwG3 FpCvlO//kW3xpsDcn8oo+Yt9m+Qlhh71Y6ngJiJ0aZGy9ZUFgtkv5HN3tugWmrcS6CjR oIwbyWcjRZaS1K3mTCxLWNAGz08B5Oz6MXVH74RpANhkIp2dgy0KOLgKYDYOImjXheZZ AlvwJ+yzEQV4EUReQRz5KEpQmK9mN9FnmwAZnbK+628PkMMuKym/ohoTSltglbjAngvX knzw== X-Gm-Message-State: AGi0PubrjXHQywo6Psrk64He2z1x2TfPL+xrkcfq4WaHLJqjy+c8FsPO gw7FwM5Rc1QQfEi27AJXsD+K3X+I5fl3IUYtZN94e9wwu4QT45/KwrWZt5grdQka75oHaW+vgxm cb0jeTlQC5mKkgonSx6BpGfWZy6yX3Zl6U5TIxDn7/6YRLmWyAKFY2AzCIZnDUcEZt4M9 X-Google-Smtp-Source: APiQypIHvj2Y8rsPPjsxaXAyGIdXYb3mV+W56lftxgC8TohZYM3yqrSSIA5bhT8fzhyaUeJz9sBWJw== X-Received: by 2002:a17:90a:be12:: with SMTP id a18mr8958083pjs.162.1586852110931; Tue, 14 Apr 2020 01:15:10 -0700 (PDT) Received: from S60.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id e196sm671176pfh.43.2020.04.14.01.15.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Apr 2020 01:15:10 -0700 (PDT) From: Venkat Duvvuru To: dev@dpdk.org Cc: Venkat Duvvuru , Mike Baucom Date: Tue, 14 Apr 2020 13:43:30 +0530 Message-Id: <1586852011-37536-34-git-send-email-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586852011-37536-1-git-send-email-venkatkumar.duvvuru@broadcom.com> References: <1586806811-21736-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <1586852011-37536-1-git-send-email-venkatkumar.duvvuru@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] =?utf-8?q?=5BPATCH_v3_33/34=5D_net/bnxt=3A_add_support?= =?utf-8?q?_for_injecting_mark_into_packet=E2=80=99s_mbuf?= 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" When a flow is offloaded with MARK action (RTE_FLOW_ACTION_TYPE_MARK), each packet of that flow will have metadata set in its completion. This metadata will be used to fetch an index into a mark table where the actual MARK for that flow is stored. Fetch the MARK from the mark table and inject it into packet’s mbuf. Signed-off-by: Venkat Duvvuru Signed-off-by: Mike Baucom Reviewed-by: Lance Richardson Reviewed-by: Ajit Kumar Khaparde --- drivers/net/bnxt/bnxt_rxr.c | 153 ++++++++++++++++++++++++--------- drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c | 55 +++++++++++- drivers/net/bnxt/tf_ulp/ulp_mark_mgr.h | 18 ++++ 3 files changed, 183 insertions(+), 43 deletions(-) diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c index bef9720..40da2f2 100644 --- a/drivers/net/bnxt/bnxt_rxr.c +++ b/drivers/net/bnxt/bnxt_rxr.c @@ -20,6 +20,9 @@ #include "bnxt_hwrm.h" #endif +#include +#include + /* * RX Ring handling */ @@ -399,6 +402,109 @@ bnxt_get_rx_ts_thor(struct bnxt *bp, uint32_t rx_ts_cmpl) } #endif +static void +bnxt_ulp_set_mark_in_mbuf(struct bnxt *bp, struct rx_pkt_cmpl_hi *rxcmp1, + struct rte_mbuf *mbuf) +{ + uint32_t cfa_code; + uint32_t meta_fmt; + uint32_t meta; + uint32_t eem = 0; + uint32_t mark_id; + uint32_t flags2; + int rc; + + cfa_code = rte_le_to_cpu_16(rxcmp1->cfa_code); + flags2 = rte_le_to_cpu_32(rxcmp1->flags2); + meta = rte_le_to_cpu_32(rxcmp1->metadata); + if (meta) { + meta >>= BNXT_RX_META_CFA_CODE_SHIFT; + + /* The flags field holds extra bits of info from [6:4] + * which indicate if the flow is in TCAM or EM or EEM + */ + meta_fmt = (flags2 & BNXT_CFA_META_FMT_MASK) >> + BNXT_CFA_META_FMT_SHFT; + /* meta_fmt == 4 => 'b100 => 'b10x => EM. + * meta_fmt == 5 => 'b101 => 'b10x => EM + VLAN + * meta_fmt == 6 => 'b110 => 'b11x => EEM + * meta_fmt == 7 => 'b111 => 'b11x => EEM + VLAN. + */ + meta_fmt >>= BNXT_CFA_META_FMT_EM_EEM_SHFT; + + eem = meta_fmt == BNXT_CFA_META_FMT_EEM; + + /* For EEM flows, The first part of cfa_code is 16 bits. + * The second part is embedded in the + * metadata field from bit 19 onwards. The driver needs to + * ignore the first 19 bits of metadata and use the next 12 + * bits as higher 12 bits of cfa_code. + */ + if (eem) + cfa_code |= meta << BNXT_CFA_CODE_META_SHIFT; + } + + if (cfa_code) { + mbuf->hash.fdir.hi = 0; + mbuf->hash.fdir.id = 0; + if (eem) + rc = ulp_mark_db_mark_get(&bp->ulp_ctx, true, + cfa_code, &mark_id); + else + rc = ulp_mark_db_mark_get(&bp->ulp_ctx, false, + cfa_code, &mark_id); + /* If the above fails, simply return and don't add the mark to + * mbuf + */ + if (rc) + return; + + mbuf->hash.fdir.hi = mark_id; + mbuf->udata64 = (cfa_code & 0xffffffffull) << 32; + mbuf->hash.fdir.id = rxcmp1->cfa_code; + mbuf->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID; + } +} + +void bnxt_set_mark_in_mbuf(struct bnxt *bp, + struct rx_pkt_cmpl_hi *rxcmp1, + struct rte_mbuf *mbuf) +{ + uint32_t cfa_code = 0; + uint8_t meta_fmt = 0; + uint16_t flags2 = 0; + uint32_t meta = 0; + + cfa_code = rte_le_to_cpu_16(rxcmp1->cfa_code); + if (!cfa_code) + return; + + if (cfa_code && !bp->mark_table[cfa_code].valid) + return; + + flags2 = rte_le_to_cpu_16(rxcmp1->flags2); + meta = rte_le_to_cpu_32(rxcmp1->metadata); + if (meta) { + meta >>= BNXT_RX_META_CFA_CODE_SHIFT; + + /* The flags field holds extra bits of info from [6:4] + * which indicate if the flow is in TCAM or EM or EEM + */ + meta_fmt = (flags2 & BNXT_CFA_META_FMT_MASK) >> + BNXT_CFA_META_FMT_SHFT; + + /* meta_fmt == 4 => 'b100 => 'b10x => EM. + * meta_fmt == 5 => 'b101 => 'b10x => EM + VLAN + * meta_fmt == 6 => 'b110 => 'b11x => EEM + * meta_fmt == 7 => 'b111 => 'b11x => EEM + VLAN. + */ + meta_fmt >>= BNXT_CFA_META_FMT_EM_EEM_SHFT; + } + + mbuf->hash.fdir.hi = bp->mark_table[cfa_code].mark_id; + mbuf->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID; +} + static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt, struct bnxt_rx_queue *rxq, uint32_t *raw_cons) { @@ -415,6 +521,7 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt, uint16_t cmp_type; uint32_t flags2_f = 0; uint16_t flags_type; + struct bnxt *bp = rxq->bp; rxcmp = (struct rx_pkt_cmpl *) &cpr->cp_desc_ring[cp_cons]; @@ -490,7 +597,10 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt, mbuf->ol_flags |= PKT_RX_RSS_HASH; } - bnxt_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf); + if (bp->truflow) + bnxt_ulp_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf); + else + bnxt_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf); #ifdef RTE_LIBRTE_IEEE1588 if (unlikely((flags_type & RX_PKT_CMPL_FLAGS_MASK) == @@ -896,44 +1006,3 @@ int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq) return 0; } - -void bnxt_set_mark_in_mbuf(struct bnxt *bp, - struct rx_pkt_cmpl_hi *rxcmp1, - struct rte_mbuf *mbuf) -{ - uint32_t cfa_code = 0; - uint8_t meta_fmt = 0; - uint16_t flags2 = 0; - uint32_t meta = 0; - - cfa_code = rte_le_to_cpu_16(rxcmp1->cfa_code); - if (!cfa_code) - return; - - if (cfa_code && !bp->mark_table[cfa_code].valid) - return; - - flags2 = rte_le_to_cpu_16(rxcmp1->flags2); - meta = rte_le_to_cpu_32(rxcmp1->metadata); - if (meta) { - meta >>= BNXT_RX_META_CFA_CODE_SHIFT; - - /* - * The flags field holds extra bits of info from [6:4] - * which indicate if the flow is in TCAM or EM or EEM - */ - meta_fmt = (flags2 & BNXT_CFA_META_FMT_MASK) >> - BNXT_CFA_META_FMT_SHFT; - - /* - * meta_fmt == 4 => 'b100 => 'b10x => EM. - * meta_fmt == 5 => 'b101 => 'b10x => EM + VLAN - * meta_fmt == 6 => 'b110 => 'b11x => EEM - * meta_fmt == 7 => 'b111 => 'b11x => EEM + VLAN. - */ - meta_fmt >>= BNXT_CFA_META_FMT_EM_EEM_SHFT; - } - - mbuf->hash.fdir.hi = bp->mark_table[cfa_code].mark_id; - mbuf->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID; -} diff --git a/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c index 566668e..ad83531 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c @@ -58,7 +58,7 @@ ulp_mark_db_mark_set(struct bnxt_ulp_context *ctxt, idx = ulp_mark_db_idx_get(is_gfid, fid, mtbl); if (is_gfid) { - BNXT_TF_DBG(ERR, "Set GFID[0x%0x] = 0x%0x\n", idx, mark); + BNXT_TF_DBG(DEBUG, "Set GFID[0x%0x] = 0x%0x\n", idx, mark); mtbl->gfid_tbl[idx].mark_id = mark; mtbl->gfid_tbl[idx].valid = true; @@ -176,6 +176,59 @@ ulp_mark_db_deinit(struct bnxt_ulp_context *ctxt) } /* + * Get a Mark from the Mark Manager + * + * ctxt [in] The ulp context for the mark manager + * + * is_gfid [in] The type of fid (GFID or LFID) + * + * fid [in] The flow id that is returned by HW in BD + * + * mark [out] The mark that is associated with the FID + * + */ +int32_t +ulp_mark_db_mark_get(struct bnxt_ulp_context *ctxt, + bool is_gfid, + uint32_t fid, + uint32_t *mark) +{ + struct bnxt_ulp_mark_tbl *mtbl; + uint32_t idx = 0; + + if (!ctxt || !mark) + return -EINVAL; + + mtbl = bnxt_ulp_cntxt_ptr2_mark_db_get(ctxt); + if (!mtbl) { + BNXT_TF_DBG(ERR, "Unable to get Mark Table\n"); + return -EINVAL; + } + + idx = ulp_mark_db_idx_get(is_gfid, fid, mtbl); + + if (is_gfid) { + if (!mtbl->gfid_tbl[idx].valid) + return -EINVAL; + + BNXT_TF_DBG(DEBUG, "Get GFID[0x%0x] = 0x%0x\n", + idx, mtbl->gfid_tbl[idx].mark_id); + + *mark = mtbl->gfid_tbl[idx].mark_id; + } else { + if (!mtbl->gfid_tbl[idx].valid) + return -EINVAL; + + BNXT_TF_DBG(DEBUG, "Get LFID[0x%0x] = 0x%0x\n", + idx, mtbl->lfid_tbl[idx].mark_id); + + *mark = mtbl->lfid_tbl[idx].mark_id; + } + + return 0; +} + +/* * Adds a Mark to the Mark Manager * * ctxt [in] The ulp context for the mark manager diff --git a/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.h b/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.h index f0d1515..0f8a5e5 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.h +++ b/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.h @@ -55,6 +55,24 @@ int32_t ulp_mark_db_deinit(struct bnxt_ulp_context *ctxt); /* + * Get a Mark from the Mark Manager + * + * ctxt [in] The ulp context for the mark manager + * + * is_gfid [in] The type of fid (GFID or LFID) + * + * fid [in] The flow id that is returned by HW in BD + * + * mark [out] The mark that is associated with the FID + * + */ +int32_t +ulp_mark_db_mark_get(struct bnxt_ulp_context *ctxt, + bool is_gfid, + uint32_t fid, + uint32_t *mark); + +/* * Adds a Mark to the Mark Manager * * ctxt [in] The ulp context for the mark manager -- 2.7.4