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 5EA9AA0562; Tue, 31 Mar 2020 18:24:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3E3F81BFC4; Tue, 31 Mar 2020 18:24:51 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 605141BFC1 for ; Tue, 31 Mar 2020 18:24:50 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02VG5OEc016526 for ; Tue, 31 Mar 2020 09:24:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : content-type : mime-version; s=pfpt0818; bh=pIDH24GAjBFM+aMd46XbPD4gz9MxC9NGTbUvCa/9gxI=; b=cAPFaA/c3CtlQ/s/ouO8LmYWVoTMecbZunNulTpk55MgcWJumnbOc+IYCxKkhs3kb+wA xUPQuLUcl6D/DiI9rh6HcsNZimuHTJXO03u5wsTVwetTE+XrA9MTp92jh/iTsi8uH118 1MRaWvt61Mrb3bRv9VztxOpGMmQsVllfxOQeTKefJXLVG62WmXGQwbQBwtZok4YfjEQI uJWUbr4/4CLyOYZJslnWW2FF/Rx7BLeeiM+uE0Oawh9kIt3I2+rdsPQjl3P1Ew2JZU7c hI4x6PzXB9/BYYiGiXYF/LYbg0k7rgx8nRwscyx+3b4IMbcVLa3DHm6P5mh49nHR0uGr 0A== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 304855gdxc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 31 Mar 2020 09:24:49 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 31 Mar 2020 09:24:47 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.172) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Tue, 31 Mar 2020 09:24:47 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BRL/rtgntoQvjX6HxF74W5EMQ4B9IzrtHcmC1Pxfki1cRA3VGWmP6X45svQs4Xp6mA9DXYSwzKklcLHfYHIHjBEHHvwKZzH3hlbJEyWqYt4xnwQ2RQmJzsKDFtfC3NUcZcwdxjmI7QNzKU0Nw709Bn9Lc0xpW9Mn6wKVWqLDbLPA3pX3qkZbH2G1scvGt0N2zKWDjw1pa4lr3Wo3h/bP439VOa3kEhu/rCgUbqRhzXZ1Sut4/KByrwV+I3O0j72jl9xDxtOgXF8VmW81ZbSeLGbMOMJC1BDfP9Ggy7iVPdGSJR/zxJFYYfKdvMhKMb9fHnbaaLffncYMK4QzYLp7wg== 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=pIDH24GAjBFM+aMd46XbPD4gz9MxC9NGTbUvCa/9gxI=; b=RX4XOaajbUYUW1a3DiNr+Ve4ZkI0DiS+2J9jSculz5JBB8kHI7Cej+Yfv2V9msEh8ZocnPDJjzaQHOlnxJoS5b2f+IBWJFLaPZpIMEyHgua4nlnXj94Ck8b59YNeJ9sZWLIhdkT5q0ahvSM6VqVr2irYlsjG5sH8QVFLd/Z19e2avFmcE1SxGjRRczbEuRZki7fFk947tj/09Zes0D68fVDMTFZpMQNh+XmRsJqoDgQoKZfB/kIVFLsgLz0vBNoFBP4ZpEh8j6xV3ZLssgmJ8MeuUJvy0UICA+4FL/dGXJ2/qEG6B0eSPKABxoj9KrVaHYfIk60jKYYL/8E1ZnvUCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pIDH24GAjBFM+aMd46XbPD4gz9MxC9NGTbUvCa/9gxI=; b=hR/MjZMWPH5CS/LWYxp3d22ujHiz1ufhWZbg0Ra8YrGnoibMGekR6Vyhv3bg1YWrBMgtqUzGqTuV9+gZqinG2Olvx/S0acjTONVmNub/lgFTQysbpehtd64uDUyXm6h5n/7iKtIJoV+7Wr3aqmFcCqZl72DdE2pD/yoWPJjHhzw= Received: from MN2PR18MB2848.namprd18.prod.outlook.com (2603:10b6:208:38::19) by MN2PR18MB2432.namprd18.prod.outlook.com (2603:10b6:208:108::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.20; Tue, 31 Mar 2020 16:24:46 +0000 Received: from MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::a8b1:45c4:b84:9c02]) by MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::a8b1:45c4:b84:9c02%7]) with mapi id 15.20.2856.019; Tue, 31 Mar 2020 16:24:46 +0000 From: Harman Kalra To: Jerin Jacob , Nithin Dabilpuram , Kiran Kumar K CC: , Harman Kalra Date: Tue, 31 Mar 2020 21:54:24 +0530 Message-ID: <1585671864-4464-1-git-send-email-hkalra@marvell.com> X-Mailer: git-send-email 2.7.4 Content-Type: text/plain X-ClientProxiedBy: BM1PR0101CA0008.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::18) To MN2PR18MB2848.namprd18.prod.outlook.com (2603:10b6:208:38::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from hkarlara-OptiPlex-3046.marvell.com (115.113.156.2) by BM1PR0101CA0008.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2856.20 via Frontend Transport; Tue, 31 Mar 2020 16:24:44 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [115.113.156.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e7d67d02-1c68-45b8-6176-08d7d5900686 X-MS-TrafficTypeDiagnostic: MN2PR18MB2432: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-Forefront-PRVS: 0359162B6D X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR18MB2848.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(396003)(39860400002)(376002)(366004)(346002)(136003)(316002)(2616005)(186003)(107886003)(86362001)(81156014)(110136005)(478600001)(16526019)(52116002)(956004)(6486002)(81166006)(36756003)(7696005)(55236004)(26005)(6636002)(966005)(66946007)(8676002)(8936002)(6666004)(5660300002)(66476007)(2906002)(66556008)(4326008); DIR:OUT; SFP:1101; Received-SPF: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nkNTdeTD1hAJVVWmH9MEIm/KfRIS/evyf2LhMqbn7iVErrepxQxnidU6oMCv1/gVoEeAHAIWmsayvv4yjx+3MRuoVO989X2CuFU06bf3iNPeV4I60wEPaWfhdGpBPBHA+WlNXeHTTMCcjI9pAQviRAAIPf9uwhXJ/nCqYqQ/aVXsol7HoCqxk+D1XiEL6UwIfpmRYYnielTyEpINCK0Zc5FJbxYJpQg+yCisuzG2vGKr8SBA0hQXtx4XJ4n2ZguXGvpG1AuNFiiGTYU1TMTSgDFT6DkcopI1368RdoLVt8WbZzmuSg7Leo1vsBIpRJOcoK2boweVAd7JJ+rhaqUgsC3ja6uhyDLIdiE5hbUFA0EvKCwn67GWvuH0Kgcz5N4SjXWBpKafpU2CIXVCzIJ1Eaf8XCYAooKcyGqZmHZm4XuH6hRbdIKaabz/LlknfQ9x37FS9DDxhDgPxPxuG4344kqRr1YBdgzt+vnKnJOZcQHpem/mU9h3SnJnnl5WfdjMSBOPc+SArTj/aqntfY3Qjg== X-MS-Exchange-AntiSpam-MessageData: HIcaVfGVRZJk9dqpS5f5CyUgGcL5phZtdd38dO0x4pKtCpjyn4E9x64wzmU5enxSj7Wrk8DrHTj4NYj9rm9o0tT9XPiZz6f04qt5HMpmwHbp3ej71u5R6Je1mOx2kkz0XWvmrQRoKMbu2RO58wLPNQ== X-MS-Exchange-CrossTenant-Network-Message-Id: e7d67d02-1c68-45b8-6176-08d7d5900686 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2020 16:24:46.1589 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JdWV9iTovWFdU3onFNZvEB0uiRwn7XNbwI9Gcpzy1G+ukSTPOUIrYT++rgDDejR2zqJPclJxnkxBhBN76PairQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB2432 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-03-31_05:2020-03-31, 2020-03-31 signatures=0 Subject: [dpdk-dev] [PATCH] net/octeontx2: setting link attributes 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" Adding support to configure link attributes like speed, duplex, negotiation. Signed-off-by: Harman Kalra --- Depends on https://patchwork.dpdk.org/patch/66344/ drivers/net/octeontx2/otx2_ethdev.c | 12 ++-- drivers/net/octeontx2/otx2_ethdev.h | 3 + drivers/net/octeontx2/otx2_ethdev_ops.c | 14 ++++- drivers/net/octeontx2/otx2_link.c | 78 +++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 8 deletions(-) diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c index e60f4901c..3aee11e2e 100644 --- a/drivers/net/octeontx2/otx2_ethdev.c +++ b/drivers/net/octeontx2/otx2_ethdev.c @@ -1592,11 +1592,6 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev) goto fail_configure; } - if (conf->link_speeds & ETH_LINK_SPEED_FIXED) { - otx2_err("Setting link speed/duplex not supported"); - goto fail_configure; - } - if (conf->dcb_capability_en == 1) { otx2_err("dcb enable is not supported"); goto fail_configure; @@ -1774,6 +1769,13 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev) rte_ether_format_addr(ea_fmt, RTE_ETHER_ADDR_FMT_SIZE, ea); + /* Apply new link configurations if changed */ + rc = otx2_apply_link_speed(eth_dev); + if (rc) { + otx2_err("Failed to set link configuration"); + goto uninstall_mc_list; + } + otx2_nix_dbg("Configured port%d mac=%s nb_rxq=%d nb_txq=%d" " rx_offloads=0x%" PRIx64 " tx_offloads=0x%" PRIx64 "" " rx_flags=0x%x tx_flags=0x%x", diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h index e5684f9f0..84747f22e 100644 --- a/drivers/net/octeontx2/otx2_ethdev.h +++ b/drivers/net/octeontx2/otx2_ethdev.h @@ -331,6 +331,8 @@ struct otx2_eth_dev { bool sdp_link; /* SDP flag */ /* Inline IPsec params */ uint16_t ipsec_in_max_spi; + uint8_t duplex; + uint32_t speed; } __rte_cache_aligned; struct otx2_eth_txq { @@ -437,6 +439,7 @@ void otx2_eth_dev_link_status_update(struct otx2_dev *dev, struct cgx_link_user_info *link); int otx2_nix_dev_set_link_up(struct rte_eth_dev *eth_dev); int otx2_nix_dev_set_link_down(struct rte_eth_dev *eth_dev); +int otx2_apply_link_speed(struct rte_eth_dev *eth_dev); /* IRQ */ int otx2_nix_register_irqs(struct rte_eth_dev *eth_dev); diff --git a/drivers/net/octeontx2/otx2_ethdev_ops.c b/drivers/net/octeontx2/otx2_ethdev_ops.c index 8f1635dba..80ac2b96e 100644 --- a/drivers/net/octeontx2/otx2_ethdev_ops.c +++ b/drivers/net/octeontx2/otx2_ethdev_ops.c @@ -610,9 +610,17 @@ otx2_nix_info_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *devinfo) /* Auto negotiation disabled */ devinfo->speed_capa = ETH_LINK_SPEED_FIXED; - devinfo->speed_capa |= ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G | - ETH_LINK_SPEED_25G | ETH_LINK_SPEED_40G | - ETH_LINK_SPEED_50G | ETH_LINK_SPEED_100G; + if (!otx2_dev_is_vf_or_sdp(dev) && !otx2_dev_is_lbk(dev)) { + devinfo->speed_capa |= ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G | + ETH_LINK_SPEED_25G | ETH_LINK_SPEED_40G; + + /* 50G and 100G to be supported for board version C0 + * and above. + */ + if (!otx2_dev_is_Ax(dev)) + devinfo->speed_capa |= ETH_LINK_SPEED_50G | + ETH_LINK_SPEED_100G; + } devinfo->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; diff --git a/drivers/net/octeontx2/otx2_link.c b/drivers/net/octeontx2/otx2_link.c index 4128f56d9..12bf6c323 100644 --- a/drivers/net/octeontx2/otx2_link.c +++ b/drivers/net/octeontx2/otx2_link.c @@ -72,6 +72,9 @@ otx2_eth_dev_link_status_update(struct otx2_dev *dev, eth_link.link_autoneg = ETH_LINK_AUTONEG; eth_link.link_duplex = link->full_duplex; + otx2_dev->speed = link->speed; + otx2_dev->duplex = link->full_duplex; + /* Print link info */ nix_link_status_print(eth_dev, ð_link); @@ -184,3 +187,78 @@ otx2_nix_dev_set_link_down(struct rte_eth_dev *eth_dev) return nix_dev_set_link_state(eth_dev, 0); } + +static int +cgx_change_mode(struct otx2_eth_dev *dev, struct cgx_set_link_mode_args *cfg) +{ + struct otx2_mbox *mbox = dev->mbox; + struct cgx_set_link_mode_req *req; + + req = otx2_mbox_alloc_msg_cgx_set_link_mode(mbox); + req->args.speed = cfg->speed; + req->args.duplex = cfg->duplex; + req->args.an = cfg->an; + + return otx2_mbox_process(mbox); +} + +#define SPEED_NONE 0 +static inline uint32_t +nix_parse_link_speeds(struct otx2_eth_dev *dev, uint32_t link_speeds) +{ + uint32_t link_speed = SPEED_NONE; + + /* 50G and 100G to be supported for board version C0 and above */ + if (!otx2_dev_is_Ax(dev)) { + if (link_speeds & ETH_LINK_SPEED_100G) + link_speed = 100000; + if (link_speeds & ETH_LINK_SPEED_50G) + link_speed = 50000; + } + if (link_speeds & ETH_LINK_SPEED_40G) + link_speed = 40000; + if (link_speeds & ETH_LINK_SPEED_25G) + link_speed = 25000; + if (link_speeds & ETH_LINK_SPEED_20G) + link_speed = 20000; + if (link_speeds & ETH_LINK_SPEED_10G) + link_speed = 10000; + if (link_speeds & ETH_LINK_SPEED_5G) + link_speed = 5000; + if (link_speeds & ETH_LINK_SPEED_1G) + link_speed = 1000; + + return link_speed; +} + +static inline uint8_t +nix_parse_eth_link_duplex(uint32_t link_speeds) +{ + if ((link_speeds & ETH_LINK_SPEED_10M_HD) || + (link_speeds & ETH_LINK_SPEED_100M_HD)) + return ETH_LINK_HALF_DUPLEX; + else + return ETH_LINK_FULL_DUPLEX; +} + +int +otx2_apply_link_speed(struct rte_eth_dev *eth_dev) +{ + struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); + struct rte_eth_conf *conf = ð_dev->data->dev_conf; + struct cgx_set_link_mode_args cfg; + + /* If VF/SDP/LBK, link attributes cannot be changed */ + if (otx2_dev_is_vf_or_sdp(dev) || otx2_dev_is_lbk(dev)) + return 0; + + memset(&cfg, 0, sizeof(struct cgx_set_link_mode_args)); + cfg.speed = nix_parse_link_speeds(dev, conf->link_speeds); + if (cfg.speed != SPEED_NONE && cfg.speed != dev->speed) { + cfg.duplex = nix_parse_eth_link_duplex(conf->link_speeds); + cfg.an = (conf->link_speeds & ETH_LINK_SPEED_FIXED) == 0; + + return cgx_change_mode(dev, &cfg); + } + return 0; +} -- 2.18.0