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 93B71A0562; Fri, 3 Apr 2020 10:53:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5C0301C196; Fri, 3 Apr 2020 10:52:46 +0200 (CEST) Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by dpdk.org (Postfix) with ESMTP id 9C2EB1C13B for ; Fri, 3 Apr 2020 10:52:44 +0200 (CEST) Received: by mail-pj1-f65.google.com with SMTP id v13so2724364pjb.0 for ; Fri, 03 Apr 2020 01:52:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jEi6+DAvO3qWxEUD0qAJaTszTCYD75tL2SNkU7HX/ms=; b=Ei41gDS2lS6aM7f0x+AvtdYjmVJv+aJw3mNKviAx4NlY16p1BGevMFc4n9aq4aMnIS neSH1SfCigSJcMD+ehPBDNfNZB+gk/xlNzP2ErfbTr/z6mZUyNoA4eTN0JBMg1DnkERX FJyjVpm5gDGh55m2ZCL1CjHsEwTCisgNOhE3jykz34z/DeTAM1OJQBJjRml3twdw4bZM voioWjfhJF/evmPXWbmlAFeh/vFRthqxpQ891wJQ6xeY7JqP29nGMeacD1PyY2jOI4i+ OwbbhoIZmFOJZlZEfaZ4QNHM0eYNz39GPoWb9XUKJAMWMz0u4i31x+uc8o1AtXvRBG/a 4Z6A== 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=jEi6+DAvO3qWxEUD0qAJaTszTCYD75tL2SNkU7HX/ms=; b=stvvoB6PEIm4nNpB9oyMxZTgyXZJdaaWDkP9i0bPHNQcwOC2zA4w5qS9kVqdkd4nep lbx6h6f6KTeZw9aOifO2/8VWpJDm77onvWGFEcT+SW+/vQ2cyUdqBFQUS9MPe2RI/KRM DgXWMpl1Zii3T7PejopbhUpHwmaBreyuF57EKTeBZlPgFuN67oWxyXD9l68a9Nj2DgLp cajcfRtAadlny431F29gxB5uslxrXZUrp93oV6Y3IC/10iVRSTh3DNKGfKhDzz82cHo3 Csidqf63zAQGASgv8sXvWxW6oHIsniKguxZxNOTcy3Ibuf3d2kJ4yQpKrs0HHPG7bNnG JbZg== X-Gm-Message-State: AGi0PuYET+omuG0fEm7386HvTn0myGLhB0NM9uOzvHynXUh3CwbLBo1W VgMSdE2vLT4/k+rdUMSx8i8= X-Google-Smtp-Source: APiQypK6/PDZkJ054WlUEwwdFuQsG+ElCiC1epPVlfFFh7muF+eHQyktzDXmM/coEEZU6O+G2g5sug== X-Received: by 2002:a17:902:dc83:: with SMTP id n3mr6805043pld.133.1585903963797; Fri, 03 Apr 2020 01:52:43 -0700 (PDT) Received: from hyd1588t430.marvell.com ([115.113.156.2]) by smtp.gmail.com with ESMTPSA id s9sm5267899pjr.5.2020.04.03.01.52.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Apr 2020 01:52:43 -0700 (PDT) From: Nithin Dabilpuram To: Jerin Jacob , Nithin Dabilpuram , Kiran Kumar K Cc: dev@dpdk.org, kkanas@marvell.com Date: Fri, 3 Apr 2020 14:22:10 +0530 Message-Id: <20200403085216.32684-6-nithind1988@gmail.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20200403085216.32684-1-nithind1988@gmail.com> References: <20200312111907.31555-1-ndabilpuram@marvell.com> <20200403085216.32684-1-nithind1988@gmail.com> Subject: [dpdk-dev] [PATCH v3 05/11] net/octeontx2: add tm node suspend and resume cb 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: Krzysztof Kanas Add TM support to suspend and resume nodes post hierarchy commit. Signed-off-by: Krzysztof Kanas Signed-off-by: Nithin Dabilpuram --- drivers/net/octeontx2/otx2_tm.c | 81 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/drivers/net/octeontx2/otx2_tm.c b/drivers/net/octeontx2/otx2_tm.c index 3e2ace6..b0e86f0 100644 --- a/drivers/net/octeontx2/otx2_tm.c +++ b/drivers/net/octeontx2/otx2_tm.c @@ -1540,6 +1540,28 @@ nix_tm_alloc_resources(struct rte_eth_dev *eth_dev, bool xmit_enable) return 0; } +static int +send_tm_reqval(struct otx2_mbox *mbox, + struct nix_txschq_config *req, + struct rte_tm_error *error) +{ + int rc; + + if (!req->num_regs || + req->num_regs > MAX_REGS_PER_MBOX_MSG) { + error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED; + error->message = "invalid config"; + return -EIO; + } + + rc = otx2_mbox_process(mbox); + if (rc) { + error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED; + error->message = "unexpected fatal error"; + } + return rc; +} + static uint16_t nix_tm_lvl2nix(struct otx2_eth_dev *dev, uint32_t lvl) { @@ -1806,9 +1828,68 @@ otx2_nix_tm_node_delete(struct rte_eth_dev *eth_dev, uint32_t node_id, return 0; } +static int +nix_tm_node_suspend_resume(struct rte_eth_dev *eth_dev, uint32_t node_id, + struct rte_tm_error *error, bool suspend) +{ + struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); + struct otx2_mbox *mbox = dev->mbox; + struct otx2_nix_tm_node *tm_node; + struct nix_txschq_config *req; + uint16_t flags; + int rc; + + tm_node = nix_tm_node_search(dev, node_id, true); + if (!tm_node) { + error->type = RTE_TM_ERROR_TYPE_NODE_ID; + error->message = "no such node"; + return -EINVAL; + } + + if (!(dev->tm_flags & NIX_TM_COMMITTED)) { + error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED; + error->message = "hierarchy doesn't exist"; + return -EINVAL; + } + + flags = tm_node->flags; + flags = suspend ? (flags & ~NIX_TM_NODE_ENABLED) : + (flags | NIX_TM_NODE_ENABLED); + + if (tm_node->flags == flags) + return 0; + + /* send mbox for state change */ + req = otx2_mbox_alloc_msg_nix_txschq_cfg(mbox); + + req->lvl = tm_node->hw_lvl; + req->num_regs = prepare_tm_sw_xoff(tm_node, suspend, + req->reg, req->regval); + rc = send_tm_reqval(mbox, req, error); + if (!rc) + tm_node->flags = flags; + return rc; +} + +static int +otx2_nix_tm_node_suspend(struct rte_eth_dev *eth_dev, uint32_t node_id, + struct rte_tm_error *error) +{ + return nix_tm_node_suspend_resume(eth_dev, node_id, error, true); +} + +static int +otx2_nix_tm_node_resume(struct rte_eth_dev *eth_dev, uint32_t node_id, + struct rte_tm_error *error) +{ + return nix_tm_node_suspend_resume(eth_dev, node_id, error, false); +} + const struct rte_tm_ops otx2_tm_ops = { .node_add = otx2_nix_tm_node_add, .node_delete = otx2_nix_tm_node_delete, + .node_suspend = otx2_nix_tm_node_suspend, + .node_resume = otx2_nix_tm_node_resume, }; static int -- 2.8.4