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 CAD6EA0565; Mon, 2 Mar 2020 08:47:31 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BB7491BFFE; Mon, 2 Mar 2020 08:47:24 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2060.outbound.protection.outlook.com [40.107.220.60]) by dpdk.org (Postfix) with ESMTP id 4EF041BFF0 for ; Mon, 2 Mar 2020 08:47:22 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e+keW31j0knw0tGeppdCX8W9W0Kq9s5zNZFYDxaGidd2+i+DoXIc1udv+K3cDkQ9gbUSh68ev9HRYveRUyPRIQTooA5u7j/qfyCNgKwkHXNAJB5Gecd0jzo1rIWIZOyLVbTT3c1dODPNgWTc7YkC21Wn9x4C66NOUND+dH/1+841a0jzybMesiSf5ZcbvGs+9xa5P3F1F3L6M4vHH9NS88XnH8hEY+ne/53Uib1td4Uy2TqpPHF1JYUu7H2OQGzU+UocQ77F49ErH/97Ex/fB/Od4hog6NoD7P5d1xSJGXjiDeJK2RbvcmFUyomINKKOqS2S71UxAkxy/Pjf/7ykBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N9PSFce4TU0CV3w80yrAP/WKZhL/z7bDA3tU6Git8tg=; b=DnRBKRiZp/yJKLHuKgz7H3339pLiR0g44SGn+wXqnAvjyuuWrEA6x3NoN0MNgv7+JGHfFslqCMpL60S2pZp1bNpo6uEEjRqcFN74iMhoRx7FBIVzhcpFxP49cIEQDcjWcrb8TD8KsUo1WSBg2YZ5srSWou3p1fymvoxuuFATcSzdY7qNO7PAhqlM0unvkxvFRxCVCsErwIfSVgzJtnqmaH08wXozPIGZf/QYqrbY8UXqobhenpYAlu2taGX2LQfFg54qXSOo5InWo7NUAIEELoH2vlsrICvFRCj+H70RBODCJmpvmHCuu6GoSWN+4PLwJ5ivxBEu6P3A8ht/exeF5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N9PSFce4TU0CV3w80yrAP/WKZhL/z7bDA3tU6Git8tg=; b=mi7+zXOkCiHGYocMadqwe+pas1wDAu2WAcfB/nkoh8yXXATUPs/+XOkzis1J3aK2GLYtTf+31VXpDWvonk7tj2uGzty5S6HTox7clmZ1gH7+Feyj1k5M+w1SRoO+7bIrdqA5Y7d9vbR9P47lgUTUFSAbUXzBh+YzTdrq1DujEOI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Amaranath.Somalapuram@amd.com; Received: from DM5PR1201MB2474.namprd12.prod.outlook.com (2603:10b6:3:e3::8) by DM5SPR00MB246.namprd12.prod.outlook.com (2603:10b6:3:128::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.15; Mon, 2 Mar 2020 07:47:18 +0000 Received: from DM5PR1201MB2474.namprd12.prod.outlook.com ([fe80::f914:4efa:e6a:8d81]) by DM5PR1201MB2474.namprd12.prod.outlook.com ([fe80::f914:4efa:e6a:8d81%11]) with mapi id 15.20.2772.019; Mon, 2 Mar 2020 07:47:18 +0000 From: asomalap@amd.com To: dev@dpdk.org Cc: Ravi1.Kumar@amd.com Date: Mon, 2 Mar 2020 13:16:57 +0530 Message-Id: <20200302074658.89636-1-asomalap@amd.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: MA1PR0101CA0044.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::30) To DM5PR1201MB2474.namprd12.prod.outlook.com (2603:10b6:3:e3::8) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from amd.amd.com (165.204.156.251) by MA1PR0101CA0044.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.15 via Frontend Transport; Mon, 2 Mar 2020 07:47:17 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.156.251] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c1d62ed8-7f1b-460e-85a5-08d7be7deedb X-MS-TrafficTypeDiagnostic: DM5SPR00MB246:|DM5SPR00MB246: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:989; X-Forefront-PRVS: 033054F29A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(346002)(366004)(396003)(39860400002)(136003)(376002)(199004)(189003)(9686003)(81156014)(81166006)(8676002)(8936002)(5660300002)(316002)(16526019)(186003)(6916009)(66556008)(66476007)(66946007)(26005)(2616005)(956004)(1076003)(2906002)(7696005)(36756003)(4326008)(478600001)(6666004)(6486002)(52116002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5SPR00MB246; H:DM5PR1201MB2474.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PY5EcXAbQix9bGUK62aq1Dwq9iCNy6idEwZ0qhk4NzpLUkgAykJN1s6HEadvPFpbUCAgJK3PiwjnMA9oMsUOHpL8BGHPb85x+zeAWQucEuIPNl8sECMBCXor39txBhYwxZfy6Bm2Tole8AAnU8g+MBr7QJr+Cq4CJI7j2kIn84KQii3Dl8FnvhTyyY6yzFoLX9sLFGJUzYOAix7XQScmuydDshrScrZ8hADi8w09xKMKlpTlehGBY8JvOYapDRpnnhuM0x6baI2+E+wMXoYv1St2mZRuP2/HQb22ar3GFzamAM5YMHKazT4jWT6B2eymKfwyct/5igQDGsmlGz3fPJ4YaYwl77aRH2zNp0jJD9POXhXnjYM727XLCPALHtwJT7IpZzSr35FQe1HIcDLxwoRsR7yfZB714fVofkzbHfH52lpAKURquvLpo9faDNhb X-MS-Exchange-AntiSpam-MessageData: fg+KD86GiiWBrMdzS54UK9iaGoKxUZXijQsq1lo/IdKbgI+6zxKkkrPOP7Huw8WQQKcHc3iOo13JsybMfAsIYLmE2ECNHW//0kZpDqaaMewmxetgbuqr+oITG0AELzP0rZJFHP9YrJLfEItXEor6SQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1d62ed8-7f1b-460e-85a5-08d7be7deedb X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2020 07:47:18.6056 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mq7XWbs/SmgjdBh2fCHHhZ7OLT2iunt4ipm5OPPuacoJvaJk3P3bO80v2ADG8Sslno+lgjfCRYv1Oexdz4BeGQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5SPR00MB246 Subject: [dpdk-dev] [PATCH v4 1/2] net/axgbe: support flow control API 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: Amaranath Somalapuram Adding api for flow_ctrl_get and flow_ctrl_set. By default axgbe driver flow control is disabled. Adding dpdk flow control to set water high and low. Signed-off-by: Amaranath Somalapuram --- drivers/net/axgbe/axgbe_ethdev.c | 84 ++++++++++++++++++++++++++++++++ drivers/net/axgbe/axgbe_ethdev.h | 10 ++++ 2 files changed, 94 insertions(+) diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index 00974e737..867c4744f 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -47,6 +47,10 @@ axgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, static int axgbe_dev_xstats_reset(struct rte_eth_dev *dev); static int axgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); +static int axgbe_flow_ctrl_get(struct rte_eth_dev *dev, + struct rte_eth_fc_conf *fc_conf); +static int axgbe_flow_ctrl_set(struct rte_eth_dev *dev, + struct rte_eth_fc_conf *fc_conf); struct axgbe_xstats { char name[RTE_ETH_XSTATS_NAME_SIZE]; @@ -174,6 +178,8 @@ static const struct eth_dev_ops axgbe_eth_dev_ops = { .rx_queue_release = axgbe_dev_rx_queue_release, .tx_queue_setup = axgbe_dev_tx_queue_setup, .tx_queue_release = axgbe_dev_tx_queue_release, + .flow_ctrl_get = axgbe_flow_ctrl_get, + .flow_ctrl_set = axgbe_flow_ctrl_set, }; static int axgbe_phy_reset(struct axgbe_port *pdata) @@ -843,6 +849,84 @@ axgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) return 0; } +static int +axgbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) +{ + struct axgbe_port *pdata = dev->data->dev_private; + struct xgbe_fc_info fc = pdata->fc; + unsigned int reg, reg_val = 0; + + reg = MAC_Q0TFCR; + reg_val = AXGMAC_IOREAD(pdata, reg); + fc.low_water[0] = AXGMAC_MTL_IOREAD_BITS(pdata, 0, MTL_Q_RQFCR, RFA); + fc.high_water[0] = AXGMAC_MTL_IOREAD_BITS(pdata, 0, MTL_Q_RQFCR, RFD); + fc.pause_time[0] = AXGMAC_GET_BITS(reg_val, MAC_Q0TFCR, PT); + fc.autoneg = pdata->pause_autoneg; + + if (pdata->rx_pause && pdata->tx_pause) + fc.mode = RTE_FC_FULL; + else if (pdata->rx_pause) + fc.mode = RTE_FC_RX_PAUSE; + else if (pdata->tx_pause) + fc.mode = RTE_FC_TX_PAUSE; + else + fc.mode = RTE_FC_NONE; + + fc_conf->high_water = (1024 + (fc.low_water[0] << 9)) / 1024; + fc_conf->low_water = (1024 + (fc.high_water[0] << 9)) / 1024; + fc_conf->pause_time = fc.pause_time[0]; + fc_conf->send_xon = fc.send_xon; + fc_conf->mode = fc.mode; + + return 0; +} + +static int +axgbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) +{ + struct axgbe_port *pdata = dev->data->dev_private; + struct xgbe_fc_info fc = pdata->fc; + unsigned int reg, reg_val = 0; + reg = MAC_Q0TFCR; + + pdata->pause_autoneg = fc_conf->autoneg; + pdata->phy.pause_autoneg = pdata->pause_autoneg; + fc.send_xon = fc_conf->send_xon; + AXGMAC_MTL_IOWRITE_BITS(pdata, 0, MTL_Q_RQFCR, RFA, + AXGMAC_FLOW_CONTROL_VALUE(1024 * fc_conf->high_water)); + AXGMAC_MTL_IOWRITE_BITS(pdata, 0, MTL_Q_RQFCR, RFD, + AXGMAC_FLOW_CONTROL_VALUE(1024 * fc_conf->low_water)); + AXGMAC_SET_BITS(reg_val, MAC_Q0TFCR, PT, fc_conf->pause_time); + AXGMAC_IOWRITE(pdata, reg, reg_val); + fc.mode = fc_conf->mode; + + if (fc.mode == RTE_FC_FULL) { + pdata->tx_pause = 1; + pdata->rx_pause = 1; + } else if (fc.mode == RTE_FC_RX_PAUSE) { + pdata->tx_pause = 0; + pdata->rx_pause = 1; + } else if (fc.mode == RTE_FC_TX_PAUSE) { + pdata->tx_pause = 1; + pdata->rx_pause = 0; + } else { + pdata->tx_pause = 0; + pdata->rx_pause = 0; + } + + if (pdata->tx_pause != (unsigned int)pdata->phy.tx_pause) + pdata->hw_if.config_tx_flow_control(pdata); + + if (pdata->rx_pause != (unsigned int)pdata->phy.rx_pause) + pdata->hw_if.config_rx_flow_control(pdata); + + pdata->hw_if.config_flow_control(pdata); + pdata->phy.tx_pause = pdata->tx_pause; + pdata->phy.rx_pause = pdata->rx_pause; + + return 0; +} + static void axgbe_get_all_hw_features(struct axgbe_port *pdata) { unsigned int mac_hfr0, mac_hfr1, mac_hfr2; diff --git a/drivers/net/axgbe/axgbe_ethdev.h b/drivers/net/axgbe/axgbe_ethdev.h index a1083b17b..746fb2f15 100644 --- a/drivers/net/axgbe/axgbe_ethdev.h +++ b/drivers/net/axgbe/axgbe_ethdev.h @@ -485,6 +485,15 @@ struct axgbe_mmc_stats { uint64_t rxwatchdogerror; }; +/* Flow control parameters */ +struct xgbe_fc_info { + uint32_t high_water[AXGBE_PRIORITY_QUEUES]; + uint32_t low_water[AXGBE_PRIORITY_QUEUES]; + uint16_t pause_time[AXGBE_PRIORITY_QUEUES]; + uint16_t send_xon; + enum rte_eth_fc_mode mode; + uint8_t autoneg; +}; /* * Structure to store private data for each port. */ @@ -625,6 +634,7 @@ struct axgbe_port { uint32_t rx_csum_enable; struct axgbe_mmc_stats mmc_stats; + struct xgbe_fc_info fc; }; void axgbe_init_function_ptrs_dev(struct axgbe_hw_if *hw_if); -- 2.17.1