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 E0BE5A0559; Mon, 16 Mar 2020 10:36:12 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 052CB1C0DA; Mon, 16 Mar 2020 10:35:05 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 9EC2F1C0B8 for ; Mon, 16 Mar 2020 10:34:57 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02G9UQ2s015065; Mon, 16 Mar 2020 02:34:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=pfpt0818; bh=Zbm0IdHsY6w1a8NrFFEVZkHSHR0rjxdZRlPAILFMZ0g=; b=WFeiON7G2Il4amPy1DaTrT5YTUCv3W7Ise2m5KI9P8/VQoMXiYq3UbB+zYGJcfkjm/GJ DFuscAWDEt2SgaIMIHHhuiBnpvSmCQ1epLS7923OGBdYd7IvUrKKbV9pM7bWbuErvBq2 OHenyUd7ULwxcWgwyQS307+s1rJiDgQRuTdLkIPmshtsGrsB35YhJaRST5gdfLgQZfDl vYJ8xNPmnn4z6dflnRo667RDFT/Y8srHCDNdaQqpVhmEAulB9V7gkul17dxE+/dECq51 YQ8FKwzUWIzQJ1FgzyGtKtoN2RvM/cPghhMukMBwB9p+ZBOge2ZWgRmlc2V6tLh9JXUR PQ== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2yrxsme52m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 16 Mar 2020 02:34:56 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 16 Mar 2020 02:34:54 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 16 Mar 2020 02:34:53 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Mon, 16 Mar 2020 02:34:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OhiEEWqIjBbrszqoicgxMzHMhEO6tDVnpr34azaZsrVPhoexkQbcbVxyfF938C8kk5qTT+CnYuMHWXNyqRyTOJL/9t+TgdVBRDYh6k5aum5wNFILAk4pm2GtYbG2cuIjjaTR1yiNQNA+qEdrYuOa1kYUnY0pD5KCwsmwflQu/r6DCG+xKdyv9/XdVS+pbTgoDS0E5gurN0Xu8qhaF93Lbe/1HFmmzy//WXYA4ji+SkFTdgAPV10Fqnf5qFunv+XzjPXTMXbPJ8p2AuCzQmpczgOAQ9eUz8tP9dgL12jJ4R2HqZgi67S7Xg33S7VshyxaiKQpdDYsfqoyVJRQiwxpbQ== 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=Zbm0IdHsY6w1a8NrFFEVZkHSHR0rjxdZRlPAILFMZ0g=; b=Ek6pppG7Shm8JCIzawmKFfKZC1gu59azx1lx6FgGb0/w/gvvvYoyfjVnr8kY77iqA6fGLYru72kS64Pt80Ictysr7dDYE+OPmWn9pjQxCuBEbnRLYycVLrW7jGhV5YPDvFJHi6pS4rF3e0yPJFMmL/zm2s0y8qVdY3vzsJW3n1a17ceG5s7Tvmh4ROhY+v9wh0PA8EPm7KUQxIi0fu0dYCFK/jj6CDpsoSyR7t/4xTJpyVE9z3C4wqdFDrsAhUzslmoA2AxZqjN/nlSeNlL4GWGOJZotjDY2M984EOZ8f81AsAu8hOcXjYA0caPUoiBdAct54gx6SiyHCSas/+XqFA== 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=Zbm0IdHsY6w1a8NrFFEVZkHSHR0rjxdZRlPAILFMZ0g=; b=cveStTxlPdl9iqItF8FvPZhflLyU6FEGybvrXRG72x1WhDI9szTfkyT2nnTZaPh7SNNis1TFvZZ11NaQBaUBSxEws2yYUyZZB6DLHoxdXm7rKOoywKlGgeONB7Amey9AdESmlDV39JIIZD3CZLWTUKwgpm1BoslJ4LJlFdWOYyE= Received: from MN2PR18MB2848.namprd18.prod.outlook.com (2603:10b6:208:38::19) by MN2PR18MB3117.namprd18.prod.outlook.com (2603:10b6:208:162::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.14; Mon, 16 Mar 2020 09:34:50 +0000 Received: from MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::f829:3e55:94f6:4efb]) by MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::f829:3e55:94f6:4efb%5]) with mapi id 15.20.2814.021; Mon, 16 Mar 2020 09:34:50 +0000 From: Harman Kalra To: , , CC: , , Harman Kalra Date: Mon, 16 Mar 2020 15:03:42 +0530 Message-ID: <1584351224-23500-7-git-send-email-hkalra@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1584351224-23500-1-git-send-email-hkalra@marvell.com> References: <1584351224-23500-1-git-send-email-hkalra@marvell.com> Content-Type: text/plain X-ClientProxiedBy: BMXPR01CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:d::16) 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 BMXPR01CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2814.13 via Frontend Transport; Mon, 16 Mar 2020 09:34:39 +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: 0c3eb087-02b8-4b42-f0de-08d7c98d40b5 X-MS-TrafficTypeDiagnostic: MN2PR18MB3117: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:102; X-Forefront-PRVS: 03449D5DD1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(376002)(39860400002)(346002)(396003)(199004)(52116002)(7696005)(478600001)(4326008)(8676002)(8936002)(107886003)(26005)(66556008)(30864003)(2906002)(86362001)(5660300002)(36756003)(55236004)(16526019)(2616005)(956004)(66946007)(6486002)(66476007)(81156014)(81166006)(6666004)(186003)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB3117; H:MN2PR18MB2848.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; 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: TcxGsHW40u5Ed69EK36NHUojVmG44dlim4KbczjHOUyJ/ViGIvN03NO9jccDFItsfZDT+oV443ekW3Lmyw0UjJAc+p7FuT8J/IoDeSaAe3b/QUHGpCouDiibx0pFyUGv6UzuKIxcEhQThSCqUb7HrGYYyFULb5cV4z/YHA6WGZPYbTLxgCmYsCg6Nc2fOV2O6rIRsonD8UBNsDd2CKY2hoapyf5/O/qSHFk99uNZuqLnwShWEjiD0OneLzkn5GWELfaG4v4hDqUlOiZe3U9IcMICjClcW0Co/GQa0kitci2B0DcBv6VpEEtsJBsfMFSFiz8uJesvQUKxlRpWjby97Du+9e53XWize+wUPtR9PDM9WMHMUeRr+e74gzXGctMKLWqp62fmW8BzVrJkgkcM1XqOmS6rj2kmue8ogVlhaFITB2IMwb1AgN6M3C5eIrnv X-MS-Exchange-AntiSpam-MessageData: ZuUy7oUM6jIsumGCpJIpR1J2wZX2I0kramNSvyfnwHZ6cw80eXwhBVNlWh01l0OzFrgbKw5pWJrN642JESCainM2WeBy8sOh9GGaf0MAdCM6JRi5/MUMATOZmwAC9C6ZzDSp1ydE98368X41npl2FQ== X-MS-Exchange-CrossTenant-Network-Message-Id: 0c3eb087-02b8-4b42-f0de-08d7c98d40b5 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Mar 2020 09:34:41.1010 (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: oo8hdql7/SZB8qr69iMLsmGy3qicDB1PAgZjp8IBhRgeRV208mZp9HLe6o9748lDUYH6AjyiexH8x1Mq9tqwTg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB3117 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-03-16_02:2020-03-12, 2020-03-16 signatures=0 Subject: [dpdk-dev] [PATCH 6/8] net/octeontx: add set link up down support 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 for setting link up/down eth operation. It is used to enable disable lmac. Also implemented a poll function for getting the link status at regular intervals. Signed-off-by: Harman Kalra --- doc/guides/nics/features/octeontx.ini | 1 + drivers/net/octeontx/base/octeontx_bgx.c | 12 ++ drivers/net/octeontx/base/octeontx_bgx.h | 3 + drivers/net/octeontx/octeontx_ethdev.c | 152 ++++++++++++++++----- drivers/net/octeontx/octeontx_ethdev.h | 7 +- drivers/net/octeontx/octeontx_ethdev_ops.c | 31 +++++ 6 files changed, 169 insertions(+), 37 deletions(-) diff --git a/doc/guides/nics/features/octeontx.ini b/doc/guides/nics/features/octeontx.ini index 53c541f4b..377bb4d30 100644 --- a/doc/guides/nics/features/octeontx.ini +++ b/doc/guides/nics/features/octeontx.ini @@ -6,6 +6,7 @@ [Features] Speed capabilities = Y Link status = Y +Link status event = Y Lock-free Tx queue = Y Queue start/stop = P MTU update = Y diff --git a/drivers/net/octeontx/base/octeontx_bgx.c b/drivers/net/octeontx/base/octeontx_bgx.c index cc2bbd104..d8611cb77 100644 --- a/drivers/net/octeontx/base/octeontx_bgx.c +++ b/drivers/net/octeontx/base/octeontx_bgx.c @@ -207,6 +207,18 @@ octeontx_bgx_port_link_status(int port) return link; } +int +octeontx_bgx_port_set_link_state(int port, bool enable) +{ + struct octeontx_mbox_hdr hdr; + + hdr.coproc = OCTEONTX_BGX_COPROC; + hdr.msg = MBOX_BGX_PORT_SET_LINK_STATE; + hdr.vfid = port; + + return octeontx_mbox_send(&hdr, &enable, sizeof(bool), NULL, 0); +} + int octeontx_bgx_port_promisc_set(int port, int en) { diff --git a/drivers/net/octeontx/base/octeontx_bgx.h b/drivers/net/octeontx/base/octeontx_bgx.h index e385de42d..6b7476510 100644 --- a/drivers/net/octeontx/base/octeontx_bgx.h +++ b/drivers/net/octeontx/base/octeontx_bgx.h @@ -5,6 +5,7 @@ #ifndef __OCTEONTX_BGX_H__ #define __OCTEONTX_BGX_H__ +#include #include #include @@ -31,6 +32,7 @@ #define MBOX_BGX_PORT_ADD_MACADDR 15 #define MBOX_BGX_PORT_DEL_MACADDR 16 #define MBOX_BGX_PORT_GET_MACADDR_ENTRIES 17 +#define MBOX_BGX_PORT_SET_LINK_STATE 20 /* BGX port configuration parameters: */ typedef struct octeontx_mbox_bgx_port_conf { @@ -132,6 +134,7 @@ int octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr, int index); int octeontx_bgx_port_mac_del(int port, uint32_t index); int octeontx_bgx_port_mac_entries_get(int port); int octeontx_bgx_port_mtu_set(int port, int mtu); +int octeontx_bgx_port_set_link_state(int port, bool en); #endif /* __OCTEONTX_BGX_H__ */ diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index 5dd40bc04..08c621b4b 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -11,6 +11,8 @@ #include #include +#include +#include #include #include #include @@ -18,7 +20,6 @@ #include #include #include -#include #include "octeontx_ethdev.h" #include "octeontx_rxtx.h" @@ -153,11 +154,102 @@ octeontx_port_open(struct octeontx_nic *nic) return res; } +static void +octeontx_link_status_print(struct rte_eth_dev *eth_dev, + struct rte_eth_link *link) +{ + if (link && link->link_status) + octeontx_log_info("Port %u: Link Up - speed %u Mbps - %s", + (eth_dev->data->port_id), + link->link_speed, + link->link_duplex == ETH_LINK_FULL_DUPLEX ? + "full-duplex" : "half-duplex"); + else + octeontx_log_info("Port %d: Link Down", + (int)(eth_dev->data->port_id)); +} + +static void +octeontx_link_status_update(struct octeontx_nic *nic, + struct rte_eth_link *link) +{ + memset(link, 0, sizeof(*link)); + + link->link_status = nic->link_up ? ETH_LINK_UP : ETH_LINK_DOWN; + + switch (nic->speed) { + case OCTEONTX_LINK_SPEED_SGMII: + link->link_speed = ETH_SPEED_NUM_1G; + break; + + case OCTEONTX_LINK_SPEED_XAUI: + link->link_speed = ETH_SPEED_NUM_10G; + break; + + case OCTEONTX_LINK_SPEED_RXAUI: + case OCTEONTX_LINK_SPEED_10G_R: + link->link_speed = ETH_SPEED_NUM_10G; + break; + case OCTEONTX_LINK_SPEED_QSGMII: + link->link_speed = ETH_SPEED_NUM_5G; + break; + case OCTEONTX_LINK_SPEED_40G_R: + link->link_speed = ETH_SPEED_NUM_40G; + break; + + case OCTEONTX_LINK_SPEED_RESERVE1: + case OCTEONTX_LINK_SPEED_RESERVE2: + default: + link->link_speed = ETH_SPEED_NUM_NONE; + octeontx_log_err("incorrect link speed %d", nic->speed); + break; + } + + link->link_duplex = ETH_LINK_FULL_DUPLEX; + link->link_autoneg = ETH_LINK_AUTONEG; +} + +static void +octeontx_link_status_poll(void *arg) +{ + struct octeontx_nic *nic = arg; + struct rte_eth_link link; + struct rte_eth_dev *dev; + int res; + + PMD_INIT_FUNC_TRACE(); + + dev = nic->dev; + + res = octeontx_bgx_port_link_status(nic->port_id); + if (res < 0) { + octeontx_log_err("Failed to get port %d link status", + nic->port_id); + } else { + if (nic->link_up != (uint8_t)res) { + nic->link_up = (uint8_t)res; + octeontx_link_status_update(nic, &link); + octeontx_link_status_print(dev, &link); + rte_eth_linkstatus_set(dev, &link); + _rte_eth_dev_callback_process(dev, + RTE_ETH_EVENT_INTR_LSC, + NULL); + } + } + + res = rte_eal_alarm_set(OCCTX_INTR_POLL_INTERVAL_MS * 1000, + octeontx_link_status_poll, nic); + if (res < 0) + octeontx_log_err("Failed to restart alarm for port %d, err: %d", + nic->port_id, res); +} + static void octeontx_port_close(struct octeontx_nic *nic) { PMD_INIT_FUNC_TRACE(); + rte_eal_alarm_cancel(octeontx_link_status_poll, nic); octeontx_bgx_port_close(nic->port_id); octeontx_log_dbg("port closed %d", nic->port_id); } @@ -411,6 +503,8 @@ octeontx_dev_close(struct rte_eth_dev *dev) rte_free(dev->data->mac_addrs); dev->data->mac_addrs = NULL; + octeontx_port_close(nic); + dev->tx_pkt_burst = NULL; dev->rx_pkt_burst = NULL; } @@ -503,7 +597,7 @@ octeontx_dev_start(struct rte_eth_dev *dev) { struct octeontx_nic *nic = octeontx_pmd_priv(dev); struct octeontx_rxq *rxq; - int ret = 0, i; + int ret, i; PMD_INIT_FUNC_TRACE(); /* Rechecking if any new offload set to update @@ -636,7 +730,10 @@ octeontx_port_link_status(struct octeontx_nic *nic) return res; } - nic->link_up = (uint8_t)res; + if (nic->link_up != (uint8_t)res || nic->print_flag == -1) { + nic->link_up = (uint8_t)res; + nic->print_flag = 1; + } octeontx_log_dbg("port %d link status %d", nic->port_id, nic->link_up); return res; @@ -661,39 +758,12 @@ octeontx_dev_link_update(struct rte_eth_dev *dev, return res; } - link.link_status = nic->link_up; - - switch (nic->speed) { - case OCTEONTX_LINK_SPEED_SGMII: - link.link_speed = ETH_SPEED_NUM_1G; - break; - - case OCTEONTX_LINK_SPEED_XAUI: - link.link_speed = ETH_SPEED_NUM_10G; - break; - - case OCTEONTX_LINK_SPEED_RXAUI: - case OCTEONTX_LINK_SPEED_10G_R: - link.link_speed = ETH_SPEED_NUM_10G; - break; - case OCTEONTX_LINK_SPEED_QSGMII: - link.link_speed = ETH_SPEED_NUM_5G; - break; - case OCTEONTX_LINK_SPEED_40G_R: - link.link_speed = ETH_SPEED_NUM_40G; - break; - - case OCTEONTX_LINK_SPEED_RESERVE1: - case OCTEONTX_LINK_SPEED_RESERVE2: - default: - link.link_speed = ETH_SPEED_NUM_NONE; - octeontx_log_err("incorrect link speed %d", nic->speed); - break; + octeontx_link_status_update(nic, &link); + if (nic->print_flag) { + octeontx_link_status_print(nic->dev, &link); + nic->print_flag = 0; } - link.link_duplex = ETH_LINK_FULL_DUPLEX; - link.link_autoneg = ETH_LINK_AUTONEG; - return rte_eth_linkstatus_set(dev, &link); } @@ -855,7 +925,7 @@ octeontx_vf_start_tx_queue(struct rte_eth_dev *dev, struct octeontx_nic *nic, return res; } -static int +int octeontx_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx) { struct octeontx_nic *nic = octeontx_pmd_priv(dev); @@ -881,7 +951,7 @@ octeontx_vf_stop_tx_queue(struct rte_eth_dev *dev, struct octeontx_nic *nic, return ret; } -static int +int octeontx_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx) { struct octeontx_nic *nic = octeontx_pmd_priv(dev); @@ -1201,6 +1271,8 @@ static const struct eth_dev_ops octeontx_dev_ops = { .tx_queue_release = octeontx_dev_tx_queue_release, .rx_queue_setup = octeontx_dev_rx_queue_setup, .rx_queue_release = octeontx_dev_rx_queue_release, + .dev_set_link_up = octeontx_dev_set_link_up, + .dev_set_link_down = octeontx_dev_set_link_down, .dev_supported_ptypes_get = octeontx_dev_supported_ptypes_get, .mtu_set = octeontx_dev_mtu_set, .pool_ops_supported = octeontx_pool_ops, @@ -1285,6 +1357,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, nic->ev_queues = 1; nic->ev_ports = 1; + nic->print_flag = -1; data->dev_link.link_status = ETH_LINK_DOWN; data->dev_started = 0; @@ -1321,6 +1394,13 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, goto free_mac_addrs; } + res = rte_eal_alarm_set(OCCTX_INTR_POLL_INTERVAL_MS * 1000, + octeontx_link_status_poll, nic); + if (res) { + octeontx_log_err("Failed to start link polling alarm"); + goto err; + } + /* Update port_id mac to eth_dev */ memcpy(data->mac_addrs, nic->mac_addr, RTE_ETHER_ADDR_LEN); diff --git a/drivers/net/octeontx/octeontx_ethdev.h b/drivers/net/octeontx/octeontx_ethdev.h index e7e0d40c7..186a044f7 100644 --- a/drivers/net/octeontx/octeontx_ethdev.h +++ b/drivers/net/octeontx/octeontx_ethdev.h @@ -30,7 +30,7 @@ #define OCTEONTX_MAX_LMAC_PER_BGX 4 #define OCCTX_RX_NB_SEG_MAX 6 - +#define OCCTX_INTR_POLL_INTERVAL_MS 1000 /* VLAN tag inserted by OCCTX_TX_VTAG_ACTION. * In Tx space is always reserved for this in FRS. */ @@ -121,6 +121,7 @@ struct octeontx_nic { uint64_t tx_offloads; uint16_t tx_offload_flags; struct octeontx_vlan_info vlan_info; + int print_flag; } __rte_cache_aligned; struct octeontx_txq { @@ -143,10 +144,14 @@ void octeontx_set_tx_function(struct rte_eth_dev *dev); /* VLAN */ +int octeontx_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx); +int octeontx_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx); int octeontx_dev_vlan_offload_init(struct rte_eth_dev *dev); int octeontx_dev_vlan_offload_fini(struct rte_eth_dev *eth_dev); int octeontx_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask); int octeontx_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on); +int octeontx_dev_set_link_up(struct rte_eth_dev *eth_dev); +int octeontx_dev_set_link_down(struct rte_eth_dev *eth_dev); #endif /* __OCTEONTX_ETHDEV_H__ */ diff --git a/drivers/net/octeontx/octeontx_ethdev_ops.c b/drivers/net/octeontx/octeontx_ethdev_ops.c index 8c3065542..b5f0bfe8a 100644 --- a/drivers/net/octeontx/octeontx_ethdev_ops.c +++ b/drivers/net/octeontx/octeontx_ethdev_ops.c @@ -182,3 +182,34 @@ octeontx_dev_vlan_offload_fini(struct rte_eth_dev *dev) return rc; } + +int +octeontx_dev_set_link_up(struct rte_eth_dev *eth_dev) +{ + struct octeontx_nic *nic = octeontx_pmd_priv(eth_dev); + int rc, i; + + rc = octeontx_bgx_port_set_link_state(nic->port_id, true); + if (rc) + goto done; + + /* Start tx queues */ + for (i = 0; i < eth_dev->data->nb_tx_queues; i++) + octeontx_dev_tx_queue_start(eth_dev, i); + +done: + return rc; +} + +int +octeontx_dev_set_link_down(struct rte_eth_dev *eth_dev) +{ + struct octeontx_nic *nic = octeontx_pmd_priv(eth_dev); + int i; + + /* Stop tx queues */ + for (i = 0; i < eth_dev->data->nb_tx_queues; i++) + octeontx_dev_tx_queue_stop(eth_dev, i); + + return octeontx_bgx_port_set_link_state(nic->port_id, false); +} -- 2.18.0