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 758D8A056F; Tue, 3 Mar 2020 09:20:21 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 56F782C16; Tue, 3 Mar 2020 09:20:21 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2054.outbound.protection.outlook.com [40.107.236.54]) by dpdk.org (Postfix) with ESMTP id AFFB02C02 for ; Tue, 3 Mar 2020 09:20:19 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XW+a59G+QwJsxAJqNu7mvLvQtg6Gkm5QalKhAF52dmkd8+jZErIwTdBDiyYo53zAREYSV1pzkTxuRvfbJ5V85EdbU1TT/XB98qSRzSRNRqRUpXuCl0DuFEt3/naWI7lbHz3gUpKaQjLDrW4KxaMwgkdRrUG7a0wdIOSYZeQ0flHnS8fMYC51k2RU+Qi+5L1NsBNliHw+gSqVnrzduHFpxDfaGMVRvxFyvnWVHpPsM0tPYM/bxgJ/TeJLlduNSUPJXd3RZ1eNw87q8cUOE2jNni7p+NKmX7Npo5TJbZchfaYUHiAgXph7jCqhDuGaLEZA6dGKxo5ix0xFXR+ayoM1iQ== 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=8KFAWbWWFUooQhCL704jHIf9LXcHK+yE6I1L82K5/NQ=; b=BYF3rUIOPzz9x59t2bib6IW/UhjWCwJLzk7uv55HQdVvZ+1E8qtWcmAjR/SjVAVrtpEzJoKhC5tFPZuCHPek+oFcSwzbb89F68EPycgxUhK3VNuvJshmtVAeEcdT6+5rkN9vsPAOgHvjqsDLvDzhWn3yre0cixCd42Qr5IZ/Tsn3n9zYTeX7UWPS0qhLEBI7lwys7sEcEG1HuEXOmyqckx8pjOFpe2k+zdAqvN32v+xqcX5V7VdwjgFQ6NbIPGWj4xiphLZCGFpd+JIVrn4CZHu56VtCqbu8jn6Td/8k4nAYv9g1q8mf/HqVcPVmAF4+Q2GK+hxlDWEjWv07IVNK8w== 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=8KFAWbWWFUooQhCL704jHIf9LXcHK+yE6I1L82K5/NQ=; b=MODJrICB1+I0/NR3QLVFVIQ1qBCVSSylk9hBM1tBStp2KlaxwzSkVOkm7gDTLYMn8zCtkPtU1IZO/fKnRnpPMazolldXlQ4D3YJC6+RnFoYt950AUJ97zHiy5U+2l+PFRIGGMnpKHWnSPltepTxlw7EkP+SvqBwyyaQZW9FsR8w= 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 DM5PR1201MB0140.namprd12.prod.outlook.com (2603:10b6:4:57::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.14; Tue, 3 Mar 2020 08:20:17 +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; Tue, 3 Mar 2020 08:20:17 +0000 From: asomalap@amd.com To: dev@dpdk.org Cc: Ravi1.Kumar@amd.com Date: Tue, 3 Mar 2020 13:49:57 +0530 Message-Id: <20200303081958.71437-1-asomalap@amd.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: MA1PR0101CA0045.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::31) 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 MA1PR0101CA0045.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.15 via Frontend Transport; Tue, 3 Mar 2020 08:20:16 +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: e3dcea1f-8381-41ce-52e8-08d7bf4bb4bb X-MS-TrafficTypeDiagnostic: DM5PR1201MB0140:|DM5PR1201MB0140: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:989; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(346002)(366004)(39860400002)(136003)(396003)(376002)(199004)(189003)(8676002)(8936002)(2906002)(6666004)(316002)(66946007)(81156014)(7696005)(1076003)(81166006)(52116002)(5660300002)(66476007)(66556008)(6916009)(956004)(6486002)(186003)(16526019)(26005)(36756003)(2616005)(478600001)(9686003)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR1201MB0140; 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: YfRiljNPE6rrPLrpVFUhrLyMSrV4oy3EXV/F3xUi2V457y0pnxjvOLUL0L86DQ/niKaBUfs42Mxbr6lCFkVKkVaxwfMBa8QR+4jRN0KIL4H7xFcHbETlGNUP47su00I4PfNjB2sKqwgpk+xZpVJTJkvgI6bw//axjHMXDIhZze4oq0EUx1/qLFdsGCqQQs+OilB32H1MVQnkWg9D85ZgXefYNMsay79ff3j8e1Viwlcaur4QYCpyVQCAq9Zspf5VSvcBKh5fvFecqgf5fpdclYuvhw/ulEYerVdmxOPdizmYYnqhgSmFMwhLXk9dMUiIOttzUr6CFu4bsfgCnjsjwuNHhVjl24LZpx0Jg7q2qUMjJsNqQB6C01LxxA1vVBQNSb/2oMr6cd42+g7L6e+jHnKgz8EByoh+KrZuq+kdaExJjn7E379tP7O5cGKjjuUG X-MS-Exchange-AntiSpam-MessageData: VtKxTtHw0G5T/p6uZPWf+FYNi5D2gZ6iF0Lc4i2vYAv4Nq9XYVVhvNW79SSVJjcMHnI8Oqpn+CovWCxlTf2wuFrIvXzWR4yu5nyot2u59GgApP2MZbA3zMmiprEg7NVY1s6J5J49x2D8MXhRrstXFw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3dcea1f-8381-41ce-52e8-08d7bf4bb4bb X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 08:20:17.6310 (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: v8e75myUguUgfPXIuTg20e5LYSWPz7LwkMrm3o8g7NgBM9LnStffw47Bu1NKA7XRhVQk/naNNV3NwRtWKDXXSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0140 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 | 11 +++++ 2 files changed, 95 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..436d780c9 100644 --- a/drivers/net/axgbe/axgbe_ethdev.h +++ b/drivers/net/axgbe/axgbe_ethdev.h @@ -485,6 +485,16 @@ 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 +635,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