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 3C49CA0518; Fri, 24 Jul 2020 07:35:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8493B1C129; Fri, 24 Jul 2020 07:33:50 +0200 (CEST) Received: from mail-vs1-f98.google.com (mail-vs1-f98.google.com [209.85.217.98]) by dpdk.org (Postfix) with ESMTP id 46C351C038 for ; Fri, 24 Jul 2020 07:33:43 +0200 (CEST) Received: by mail-vs1-f98.google.com with SMTP id j186so4279176vsd.10 for ; Thu, 23 Jul 2020 22:33:43 -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=2Vu/gwo6ygMfKTfd6jhHY/WRcuh58bqBZtSqRpS4Jj0=; b=cZGdDxOsS2gM6b++EtxUqyyE6gKPBJkwPJ+DVMPIr0pJjEfoXJtLjfXKlYPsO8a0fO +HzYVCAfEJtOIEXcrkUQu7BHuVt0veu7tp6RJ8HWtXE4oAWv5eKAyOdb9OAh6EJvAkgY JPYnyPeC86ZAF5uojj8h4JfMDGY2vVih2wfT0= 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=2Vu/gwo6ygMfKTfd6jhHY/WRcuh58bqBZtSqRpS4Jj0=; b=BM8zNQYEjxj0Y7UxhqGFqo8ziW+dGUkO+blu7cmeUh4tDAKuh/qe4CVbl0YY43bSwI k7pdmGHje1QRqgnvqmDSO1kFVHhabtLYr22oPycFY81UimMjLShVW+0O4uvStECAXwIw ndGu9cITbJ/3NvlTuibAuGbLyWkh71hGJETCXqsHBUYzzFnrrMF4IiSrS7p0bjQIR49k hok/3Qqe6eR+2DWo4Og8ppDgdWercf6DSOW1npIVGMzot45WnNOKZEtNTfYqUNFD7+mD dLAQhOmiTZ93vpLMp0HcA7dpUeMkISu4NBUhnkHnSqG4ljyalaQZ2zg4QM5eoDRzw6YR P9UA== X-Gm-Message-State: AOAM530+D16bQkW8mv6iYTdzvogFFQgiGQsPY+AUCsXWo+7qFOWaAPjl BBotE/X8vz6W7N6iQZ5Lt5m3ifSfC9wOQloZCnic979nvT+S4SaumdMGgkknVugj4HfUHtTUUbZ A89qpu7iCL7nQjNbEZUYSRJfObOUfxN9CX+fnq9tUiv8piZUxpj1Eoz/isXEKqar+BEpIaFgaj5 Gccw== X-Google-Smtp-Source: ABdhPJyRvJWKiBCDlIGr/HtwYBD/qZo5Oc1T96BQdPMX/wM4fWYGW5lp1SBJgKBNnRAC5ikwfo5AHK3rw4+S X-Received: by 2002:a67:d485:: with SMTP id g5mr6940847vsj.229.1595568822575; Thu, 23 Jul 2020 22:33:42 -0700 (PDT) Received: from localhost.localdomain ([192.19.223.252]) by smtp-relay.gmail.com with ESMTPS id h17sm592840vsk.0.2020.07.23.22.33.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jul 2020 22:33:42 -0700 (PDT) X-Relaying-Domain: broadcom.com From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Venkat Duvvuru , Somnath Kotur , Shahaji Bhosle Date: Thu, 23 Jul 2020 22:32:28 -0700 Message-Id: <20200724053235.71069-16-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200724053235.71069-1-ajit.khaparde@broadcom.com> References: <20200723115639.22357-1-somnath.kotur@broadcom.com> <20200724053235.71069-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 15/22] net/bnxt: delete VF FW rules on representor create 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: Venkat Duvvuru Truflow stack adds VFR to VF and VF to VFR conduits when VF representor is created. However, in the ingress direction the VF's fw rules conflict with Truflow rules, resulting in not hitting the Truflow VFR rules. To fix this, fw is going to remove it’s VF rules when vf representor is created in Truflow mode and will restore the removed rules when vf representor is destroyed. This patch invokes the vf representor alloc and free hwrm commands as part of which fw will do the above mentioned actions. Signed-off-by: Venkat Duvvuru Signed-off-by: Somnath Kotur Reviewed-by: Shahaji Bhosle Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_hwrm.c | 49 +++++++++ drivers/net/bnxt/bnxt_hwrm.h | 2 + drivers/net/bnxt/bnxt_reps.c | 19 +++- drivers/net/bnxt/hsi_struct_def_dpdk.h | 138 +++++++++++++++++++++++++ 4 files changed, 205 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 7ea13a8b2..f5f0dfe73 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -5486,6 +5486,55 @@ int bnxt_hwrm_cfa_counter_qstats(struct bnxt *bp, return 0; } +int bnxt_hwrm_cfa_vfr_alloc(struct bnxt *bp, uint16_t vf_idx) +{ + struct hwrm_cfa_vfr_alloc_output *resp = bp->hwrm_cmd_resp_addr; + struct hwrm_cfa_vfr_alloc_input req = {0}; + int rc; + + if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) { + PMD_DRV_LOG(DEBUG, + "Not a PF or trusted VF. Command not supported\n"); + return 0; + } + + HWRM_PREP(&req, HWRM_CFA_VFR_ALLOC, BNXT_USE_CHIMP_MB); + req.vf_id = rte_cpu_to_le_16(vf_idx); + snprintf(req.vfr_name, sizeof(req.vfr_name), "%svfr%d", + bp->eth_dev->data->name, vf_idx); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB); + HWRM_CHECK_RESULT(); + + HWRM_UNLOCK(); + PMD_DRV_LOG(DEBUG, "VFR %d allocated\n", vf_idx); + return rc; +} + +int bnxt_hwrm_cfa_vfr_free(struct bnxt *bp, uint16_t vf_idx) +{ + struct hwrm_cfa_vfr_free_output *resp = bp->hwrm_cmd_resp_addr; + struct hwrm_cfa_vfr_free_input req = {0}; + int rc; + + if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) { + PMD_DRV_LOG(DEBUG, + "Not a PF or trusted VF. Command not supported\n"); + return 0; + } + + HWRM_PREP(&req, HWRM_CFA_VFR_FREE, BNXT_USE_CHIMP_MB); + req.vf_id = rte_cpu_to_le_16(vf_idx); + snprintf(req.vfr_name, sizeof(req.vfr_name), "%svfr%d", + bp->eth_dev->data->name, vf_idx); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB); + HWRM_CHECK_RESULT(); + HWRM_UNLOCK(); + PMD_DRV_LOG(DEBUG, "VFR %d freed\n", vf_idx); + return rc; +} + #ifdef RTE_LIBRTE_BNXT_PMD_SYSTEM int bnxt_hwrm_oem_cmd(struct bnxt *bp, uint32_t entry_num) diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 01201a7a4..4a2af13c9 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -278,4 +278,6 @@ int bnxt_hwrm_port_phy_qcaps(struct bnxt *bp); int bnxt_hwrm_oem_cmd(struct bnxt *bp, uint32_t entry_num); int bnxt_clear_one_vnic_filter(struct bnxt *bp, struct bnxt_filter_info *filter); +int bnxt_hwrm_cfa_vfr_alloc(struct bnxt *bp, uint16_t vf_idx); +int bnxt_hwrm_cfa_vfr_free(struct bnxt *bp, uint16_t vf_idx); #endif diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c index c425e69aa..2f775e0c0 100644 --- a/drivers/net/bnxt/bnxt_reps.c +++ b/drivers/net/bnxt/bnxt_reps.c @@ -272,7 +272,7 @@ static int bnxt_tf_vfr_alloc(struct rte_eth_dev *vfr_ethdev) if (rc) { BNXT_TF_DBG(DEBUG, "Default flow rule creation for VFR->VF failed!\n"); - return -EIO; + goto err; } BNXT_TF_DBG(DEBUG, "*** Default flow rule created for VFR->VF! ***\n"); @@ -283,7 +283,7 @@ static int bnxt_tf_vfr_alloc(struct rte_eth_dev *vfr_ethdev) if (rc) { BNXT_TF_DBG(DEBUG, "Failed to get action_ptr for VFR->VF dflt rule\n"); - return -EIO; + goto rep2vf_free; } BNXT_TF_DBG(DEBUG, "tx_cfa_action = %d\n", vfr->vfr_tx_cfa_action); rc = ulp_default_flow_create(parent_dev, param_list, @@ -292,13 +292,24 @@ static int bnxt_tf_vfr_alloc(struct rte_eth_dev *vfr_ethdev) if (rc) { BNXT_TF_DBG(DEBUG, "Default flow rule creation for VF->VFR failed!\n"); - return -EIO; + goto rep2vf_free; } BNXT_TF_DBG(DEBUG, "*** Default flow rule created for VF->VFR! ***\n"); BNXT_TF_DBG(DEBUG, "vfr2rep_flow_id = %d\n", vfr->vf2rep_flow_id); + rc = bnxt_hwrm_cfa_vfr_alloc(parent_bp, vfr->vf_id); + if (rc) + goto vf2rep_free; + return 0; + +vf2rep_free: + ulp_default_flow_destroy(vfr->parent_dev, vfr->vf2rep_flow_id); +rep2vf_free: + ulp_default_flow_destroy(vfr->parent_dev, vfr->rep2vf_flow_id); +err: + return -EIO; } static int bnxt_vfr_alloc(struct rte_eth_dev *vfr_ethdev) @@ -414,6 +425,8 @@ static int bnxt_vfr_free(struct bnxt_vf_representor *vfr) vfr->vfr_tx_cfa_action = 0; vfr->rx_cfa_code = 0; + rc = bnxt_hwrm_cfa_vfr_free(parent_bp, vfr->vf_id); + return rc; } diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 598da7153..fb4f712ce 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -35127,6 +35127,144 @@ struct hwrm_cfa_pair_info_output { uint8_t valid; } __rte_packed; +/********************** + * hwrm_cfa_vfr_alloc * + **********************/ + + +/* hwrm_cfa_vfr_alloc_input (size:448b/56B) */ +struct hwrm_cfa_vfr_alloc_input { + /* The HWRM command request type. */ + uint16_t req_type; + /* + * The completion ring to send the completion event on. This should + * be the NQ ID returned from the `nq_alloc` HWRM command. + */ + uint16_t cmpl_ring; + /* + * The sequence ID is used by the driver for tracking multiple + * commands. This ID is treated as opaque data by the firmware and + * the value is returned in the `hwrm_resp_hdr` upon completion. + */ + uint16_t seq_id; + /* + * The target ID of the command: + * * 0x0-0xFFF8 - The function ID + * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors + * * 0xFFFD - Reserved for user-space HWRM interface + * * 0xFFFF - HWRM + */ + uint16_t target_id; + /* + * A physical address pointer pointing to a host buffer that the + * command's response data will be written. This can be either a host + * physical address (HPA) or a guest physical address (GPA) and must + * point to a physically contiguous block of memory. + */ + uint64_t resp_addr; + /* Logical VF number (range: 0 -> MAX_VFS -1). */ + uint16_t vf_id; + /* + * This field is reserved for the future use. + * It shall be set to 0. + */ + uint16_t reserved; + uint8_t unused_0[4]; + /* VF Representor name (32 byte string). */ + char vfr_name[32]; +} __rte_packed; + +/* hwrm_cfa_vfr_alloc_output (size:128b/16B) */ +struct hwrm_cfa_vfr_alloc_output { + /* The specific error status for the command. */ + uint16_t error_code; + /* The HWRM command request type. */ + uint16_t req_type; + /* The sequence ID from the original command. */ + uint16_t seq_id; + /* The length of the response data in number of bytes. */ + uint16_t resp_len; + /* Rx CFA code. */ + uint16_t rx_cfa_code; + /* Tx CFA action. */ + uint16_t tx_cfa_action; + uint8_t unused_0[3]; + /* + * This field is used in Output records to indicate that the output + * is completely written to RAM. This field should be read as '1' + * to indicate that the output has been completely written. + * When writing a command completion or response to an internal processor, + * the order of writes has to be such that this field is written last. + */ + uint8_t valid; +} __rte_packed; + +/********************* + * hwrm_cfa_vfr_free * + *********************/ + + +/* hwrm_cfa_vfr_free_input (size:448b/56B) */ +struct hwrm_cfa_vfr_free_input { + /* The HWRM command request type. */ + uint16_t req_type; + /* + * The completion ring to send the completion event on. This should + * be the NQ ID returned from the `nq_alloc` HWRM command. + */ + uint16_t cmpl_ring; + /* + * The sequence ID is used by the driver for tracking multiple + * commands. This ID is treated as opaque data by the firmware and + * the value is returned in the `hwrm_resp_hdr` upon completion. + */ + uint16_t seq_id; + /* + * The target ID of the command: + * * 0x0-0xFFF8 - The function ID + * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors + * * 0xFFFD - Reserved for user-space HWRM interface + * * 0xFFFF - HWRM + */ + uint16_t target_id; + /* + * A physical address pointer pointing to a host buffer that the + * command's response data will be written. This can be either a host + * physical address (HPA) or a guest physical address (GPA) and must + * point to a physically contiguous block of memory. + */ + uint64_t resp_addr; + /* VF Representor name (32 byte string). */ + char vfr_name[32]; + /* Logical VF number (range: 0 -> MAX_VFS -1). */ + uint16_t vf_id; + uint16_t reserved; + uint8_t unused_0[4]; +} __rte_packed; + +/* hwrm_cfa_vfr_free_output (size:128b/16B) */ +struct hwrm_cfa_vfr_free_output { + /* The specific error status for the command. */ + uint16_t error_code; + /* The HWRM command request type. */ + uint16_t req_type; + /* The sequence ID from the original command. */ + uint16_t seq_id; + /* The length of the response data in number of bytes. */ + uint16_t resp_len; + uint8_t unused_0[7]; + /* + * This field is used in Output records to indicate that the output + * is completely written to RAM. This field should be read as '1' + * to indicate that the output has been completely written. + * When writing a command completion or response to an internal processor, + * the order of writes has to be such that this field is written last. + */ + uint8_t valid; +} __rte_packed; + + + /*************************************** * hwrm_cfa_redirect_query_tunnel_type * ***************************************/ -- 2.21.1 (Apple Git-122.3)