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 12E07A0524; Thu, 30 Jan 2020 07:38:30 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1FA731BFE5; Thu, 30 Jan 2020 07:38:29 +0100 (CET) Received: from NAM04-CO1-obe.outbound.protection.outlook.com (mail-eopbgr690088.outbound.protection.outlook.com [40.107.69.88]) by dpdk.org (Postfix) with ESMTP id C14881BFE2; Thu, 30 Jan 2020 07:38:27 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lT1XUjsXtv9p+x1m6gytoESOiCJHBzjGuHHlPNR1rf39ZaGNkBYblmqI2LKNcRT4ZEF2cF3U8ucCSMtcDjrtwddh8AXKQQSrFqCGCfjSJ2RPsLonHHUZlPMJktXJH5W88JIEBG8IxylxP3zAnuZOi9HTBpc0G8QlnUSf1O01dGP1lqKBYznebdghF4+k/d5Gc8PIdfQnTbfyX4rVVpaGECwGoMLGO4F3+X1kG6ttrFZvoEJ47UiOjLOBeYlUmaZDawO0HDFRI9qhjqdqDuhGH026c+JdY9wweqApHjhIeQcSgVv5fvsR8OcZGeveKPM7LRJvMHvN56w+WDi1PRlZYQ== 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=7XVailcuP65fAgtButm1FVR8euF5y3S1P3/2JARXCkw=; b=AYMSMgKUPTa2+8Cpbz0JGZ9ZCn8gkaMMzsgD566+G/zTb4SaCgaup3ogRRFjbt9DNvh509+w9xnhP7qqpBvsz0+gp1v9sfLKrLTnGNHLpMBJi5XJgZ9tW/yEh8IGNI/YSgCCD6XByNonoUptNb+hkgqjOggqbhW0a9yWxmSKeyJio9+SehSyd+PSjsJgyE/o23AEUoJFDn1NQ1sBu47dW8JVcEpXznv/gwyKXKBaQa/SxsftHT8lak8WBeCOeGsDg8g3hdIhpbe330zlGRRrf8cQSBzl2Sk/kb74/4S6V2ESg2+DsfnhI6tef1F5DH9cM8+HO9SVk7dtKXc2Behl7w== 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=7XVailcuP65fAgtButm1FVR8euF5y3S1P3/2JARXCkw=; b=DdVxFIxzMWikFvSNFdlIc8ZcrTiVLXStnqbylls/0YnhS5gfEPq8EfUxUffKfw5WRm5uY10TDq2wkyAOKKJYGfkNbnP2OR7GCRE0/akWXUUaPlV6dUpyqgIxYehR+7VAuYtORkNFJGqlqUmxgZob1XHN1Li1Xa/PifmU7mRmK+A= 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 DM5PR1201MB0043.namprd12.prod.outlook.com (10.174.107.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.22; Thu, 30 Jan 2020 06:38:25 +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.2665.027; Thu, 30 Jan 2020 06:38:25 +0000 From: asomalap@amd.com To: dev@dpdk.org Cc: stable@dpdk.org Date: Thu, 30 Jan 2020 12:05:07 +0530 Message-Id: <20200130063507.77339-1-asomalap@amd.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: MA1PR01CA0095.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::11) 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 MA1PR01CA0095.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.22 via Frontend Transport; Thu, 30 Jan 2020 06:38:23 +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: 8dac465d-fbdc-44cc-3742-08d7a54f0163 X-MS-TrafficTypeDiagnostic: DM5PR1201MB0043: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:989; X-Forefront-PRVS: 02981BE340 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(346002)(136003)(396003)(376002)(39860400002)(199004)(189003)(316002)(5660300002)(4326008)(1076003)(81156014)(450100002)(8936002)(8676002)(81166006)(2906002)(6916009)(2616005)(9686003)(36756003)(26005)(6666004)(478600001)(66946007)(956004)(6486002)(186003)(66476007)(16526019)(7696005)(66556008)(52116002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR1201MB0043; 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: uPecWutIUVxDDeDQeXQVW3oOtaXrzK22RxQGTVpkNznzW/Q04ZdWCljDdeQrj0aSOsFibV/Js4Hv6n+m+WROpcp7hyToiZx7pymBA0n43QaoRtNu4nHZAo0/Y9BGamKf1mxjqDXrro7NedHUY40o28WRSvbgWWvgGjvfTpWBT0UCrdF6JEgclbCuFMgYllsZ/VLskZoz2dypMU/6Nk50ngGhr6f+xyN4BItnFeoxlahjLV3vUWZXf7HfHwANX9LroZRXoHvOHCuQZ7zTFmkLHjtFboxv1NtYQY6H55806Znk0VIvYyQbKN5ErNo23F55S/DmIrdY8niO/jDPbqPbPdymi3uSXhxl2aPcgy7Um29Fo9sEmnbKR9jn5eWo/n7YVfNxWf5bBiho7Lsk2iEq84iZvqk/DDrNYky5LH3a1ckIZVsfhteRZ6stj70CU9lu X-MS-Exchange-AntiSpam-MessageData: nLOu8J41fP98I3uXGJhCbl48U7VG043DPeFKQ7FmUdTCjjrm7GKmv8MbDqlBb/cn4uyHdiCCclnSRSq1yZTpy92rMpEdSFVV7mc73th6Njn7INM/VUcjrLO7q2qnHIW5OxPXzGl4TKYXzMKp+W0BEQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8dac465d-fbdc-44cc-3742-08d7a54f0163 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2020 06:38:25.1708 (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: fKD3ebAbgG7uV8HtKtlH9wScKg/IMgS/XHygkjQq1ZFV/KuG8ZKZrEtegiDjtUtuJ4mep1aSdFQcFcFSyB4p1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0043 Subject: [dpdk-dev] [PATCH v2] 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 dissabled 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