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 C3BB7A04B3; Mon, 3 Feb 2020 06:07:58 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0BC911BFC1; Mon, 3 Feb 2020 06:07:58 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2045.outbound.protection.outlook.com [40.107.94.45]) by dpdk.org (Postfix) with ESMTP id F1FDF1BFB5; Mon, 3 Feb 2020 06:07:55 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CAA9lKKcLK+Rot2EyiDubYjeznnhTLNA+k9t6grYlL7CkD4KiA8s2JSbSxZENbDSXu/E7VrEzLVc+PzPrPl1mL/4sqdaxgwoo4hgOmhV84H0dEiXaUV02RnLXC5mgCmTb6t0AxkcfWhIxJaU1scVtZ5RuCqym1B2Kk67tOlOy5PWEqeV4QzN6/X1qKil1rnCWB7YNauCSLDMpXUp8HmoVlx4OFlrbg5GVZevYRp62OHndkvI1FvR88shsPVJ06Z8rXfNGS73PiioY1NFP1ouPEZD7YZY50oCWNPnWpHjcqxEfDLAMHowxS7qtlsv/OYKkpuv9vXf3aYUGAYZArcXQA== 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=sy1AepmXinpYXnks2OhkuZWf0U+QsAEFSxbf5Cn/EVU=; b=JtJNPudwZrvyRJCY8wJUlUtS/eFCCf8hpvnegCaj3Xp0vJAh8ag1mVxurQbJX0KWfDwSqW7mbTJ3cE8jB101trA6SlMqhqIJXKF4VAyQ7P8B393pJdu5PqRq/giqV2EN4mRMhdNazhivSvRrJj4Ykqka73NgeYNPnE6WzbcueGOHAosfptSVe7JF16kcHXSUFzO9Mlu7wCd7tEMzg/7O32O5Ar6W/Ac+Hd1hBfSbLuZvJS2JG/3SIZWpeKbTdYL4scwhH4l1+CAloW9qe/tJt43mOEZ8d6Ot4mFJ6oRqe/gIaDrgqIRofbA3yxuI+BcO4V+pR7IW5+e+wAoEARDjBg== 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=sy1AepmXinpYXnks2OhkuZWf0U+QsAEFSxbf5Cn/EVU=; b=jNaRYq3fnQ6l7O59RB+ZevwTKZ7KELECYXTJq/cWfY7RFRNxuxkaT7q8VcJwoZTM/GTftWbuo6gxLeCj1NNfKSWRKHcES9SuVC+29QzaKyyn8qTG0a+Jrx6+TnDlfrLGaDq+/ZCQ4HneQVUru4gvMKTOqbL4qBtluyO+hkdolwA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Amaranath.Somalapuram@amd.com; Received: from DM5PR1201MB2474.namprd12.prod.outlook.com (10.172.87.136) by DM5PR1201MB0123.namprd12.prod.outlook.com (10.174.104.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.27; Mon, 3 Feb 2020 05:07:52 +0000 Received: from DM5PR1201MB2474.namprd12.prod.outlook.com ([fe80::3d24:2943:582c:c7b5]) by DM5PR1201MB2474.namprd12.prod.outlook.com ([fe80::3d24:2943:582c:c7b5%6]) with mapi id 15.20.2686.031; Mon, 3 Feb 2020 05:07:52 +0000 From: asomalap@amd.com To: dev@dpdk.org Cc: stable@dpdk.org Date: Mon, 3 Feb 2020 10:34:27 +0530 Message-Id: <20200203050427.62000-1-asomalap@amd.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: MA1PR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::17) To DM5PR1201MB2474.namprd12.prod.outlook.com (2603:10b6:3:e3::8) MIME-Version: 1.0 Received: from amd.amd.com (165.204.157.251) by MA1PR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.32 via Frontend Transport; Mon, 3 Feb 2020 05:07:50 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.157.251] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0f4476a2-cc1f-48ae-e772-08d7a867051f X-MS-TrafficTypeDiagnostic: DM5PR1201MB0123: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:989; X-Forefront-PRVS: 0302D4F392 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(189003)(199004)(6916009)(2616005)(36756003)(7696005)(52116002)(956004)(5660300002)(450100002)(316002)(4326008)(66556008)(16526019)(66476007)(26005)(478600001)(8936002)(186003)(81156014)(81166006)(66946007)(8676002)(1076003)(9686003)(6486002)(2906002)(6666004); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR1201MB0123; H:DM5PR1201MB2474.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: hzXO/4SEcZChgrLnS9O6RvbjbIedU5L7XHZOnDIvndFR85HRS20V6v391erUJAEf8c0o6sF9WkYKxdugyg7Obpggjy5QVsR2evaHOHSJq32jZus03vtWTtJcTI8/avJnUwMvPuM8QorGoZV2vS021+5uV04hG2ZI8epNiVMxSeWc3RO2pJoGlkCtgnl35zQ/5nzcJ1X+tjKsFgaeO3Wy2sH4jknQv96U66w+9wolgTlZga4wBqTwR6v6nvq3+/ei204qTUqsVVcPIjg1DsZmAmUEzpvPWj0tD8xFBT/MKR4OAnjsmXcRJAWm1u5hrDSNqkvVLsNRoonjnL5w4upfaqFOAqgo3enchhWgj9sqiLDkFTPTsEJvor5p4r2tSahyjFR00eCEJWkbpmSw7EhbktGcKizURewxFp6sh2wB4rAiOchq/ItsuxEnNlqY21n/ X-MS-Exchange-AntiSpam-MessageData: WVuAXhjhq/j1K/YwoOseeIr5lUwUEA/xUui6FafYIxBRA8OmDzr6lcqxQHwm1uFLD0Fcirx2wQ93Vs/ejohCP9TpNYu4Ru/EwpPJnofDrT/yKxCJIZ0h/x5jXPbJBmzDbzvxZuzKUD0VZkcL8mSfTg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f4476a2-cc1f-48ae-e772-08d7a867051f X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2020 05:07:52.1417 (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: 6Z4/g09DyJUgwp61vKj8iwy1k9U4413lAAXVU/NpBTwoyv5YK7X/wTIAk8ziSgjU2USvau4p26bG34N4zy+8IQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0123 Subject: [dpdk-dev] [PATCH v3 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. Cc: stable@dpdk.org Signed-off-by: Amaranath Somalapuram --- drivers/net/axgbe/axgbe_ethdev.c | 85 +++++++++++++++++++++++++++++++- drivers/net/axgbe/axgbe_ethdev.h | 10 ++++ 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index d0b6f091f..b88ad55ac 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -43,7 +43,11 @@ axgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, unsigned int size); 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); + 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]; @@ -170,6 +174,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) @@ -815,6 +821,83 @@ 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) { 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