From patchwork Tue Jul 7 09:22:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 234967 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp737545ilg; Tue, 7 Jul 2020 02:29:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypafUl5owISi47Go9PvxO8GYu+JeuFkaVvm8V7bnOUqLIBm8+gkHkBiX5LVU/+HeIXwYge X-Received: by 2002:a25:c711:: with SMTP id w17mr3887742ybe.465.1594114182045; Tue, 07 Jul 2020 02:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594114182; cv=none; d=google.com; s=arc-20160816; b=sAND5HM5d/SEiJDcgA9LuaMRLgfrpt7kQqdB3XK4xW/AcbbzKjgt3p36deJFbWBd7V 4l7ta8sF2z0wehaWVLx12TJme+ejIJgMOAr9QVbjMFdgscFNnyPa/AmqNClqr95edtcy h6X9FVYhee5IMGFZrGF83sxEcYlIyHmUP7NNKpA5ANlwHvIuBU8yCGxKuD3tPJgclRzv e0pJttcDKw49zA+XkgSZX/p5YJONt9DwXiiufj94Bt8STWafvva/6hVKMPgo40YRXh5n R+oouUqu/9dl+FZIKE0HXU4Y58b6WglJ6JrUIObaiq5m0ljsv/NY/tykg188S41cK1T9 dBYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=Kwi5olL4Pq6fFaxYHyWM50LdeYUh2UzlCPXokGkn3gc=; b=RRXE1ChIEGRKLDZ2Ap9vscVcVH5ehn7eZ0XcKIiouKLYoXkigh+lCIY/xFz+FziUr8 nwUeRLJWDSUznsN+KcsLSGaeVRIKKTpnlrNoCYgP1xYHSCxwah8CO6T1CEcllwOQOpx9 NMNA1tv1e/JnkfyNn73gwTCUrcjmxIyB4BjzeN5Kf4UbWLYx7fgSniMSV8MmEmHnUmIt EljNO7QRZ9L8feVPVlw9dVVdudqb+lFaaspcfqadyRE0/t94WKRw3QI5HzWD0Rj7JIMg io1mmjS8XvDvZbspuf/SnSw7o3F0WuA95sAv1nttS4tQgHPvEot7ISNA31lnam7r0z4K EutA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id 3si21695040ybo.350.2020.07.07.02.29.41; Tue, 07 Jul 2020 02:29:42 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A2CDD1DD92; Tue, 7 Jul 2020 11:27:21 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id B88221DC9B for ; Tue, 7 Jul 2020 11:27:07 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 993421A0A4E; Tue, 7 Jul 2020 11:27:07 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id A98CF1A0A46; Tue, 7 Jul 2020 11:27:05 +0200 (CEST) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 6E31240305; Tue, 7 Jul 2020 17:27:03 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Rohit Raj Date: Tue, 7 Jul 2020 14:52:29 +0530 Message-Id: <20200707092244.12791-15-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707092244.12791-1-hemant.agrawal@nxp.com> References: <20200527132326.1382-1-hemant.agrawal@nxp.com> <20200707092244.12791-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 14/29] bus/dpaa: enable set link status 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: Rohit Raj Enabled set link status API to start/stop phy device from application. Signed-off-by: Rohit Raj --- drivers/bus/dpaa/base/qbman/process.c | 27 +++++++++++++++++ drivers/bus/dpaa/include/process.h | 11 +++++++ drivers/bus/dpaa/rte_bus_dpaa_version.map | 1 + drivers/net/dpaa/dpaa_ethdev.c | 35 ++++++++++++++++------- 4 files changed, 63 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/drivers/bus/dpaa/base/qbman/process.c b/drivers/bus/dpaa/base/qbman/process.c index 68b7af243..6f7e37957 100644 --- a/drivers/bus/dpaa/base/qbman/process.c +++ b/drivers/bus/dpaa/base/qbman/process.c @@ -366,3 +366,30 @@ int dpaa_get_link_status(char *if_name) return args.link_status; } + +#define DPAA_IOCTL_UPDATE_LINK_STATUS \ + _IOW(DPAA_IOCTL_MAGIC, 0x11, struct usdpaa_ioctl_update_link_status_args) + +int dpaa_update_link_status(char *if_name, int link_status) +{ + struct usdpaa_ioctl_update_link_status_args args; + int ret; + + ret = check_fd(); + if (ret) + return ret; + + strcpy(args.if_name, if_name); + args.link_status = link_status; + + ret = ioctl(fd, DPAA_IOCTL_UPDATE_LINK_STATUS, &args); + if (ret) { + if (errno == EINVAL) + printf("Failed to set link status: Not Supported\n"); + else + printf("Failed to set link status"); + return ret; + } + + return 0; +} diff --git a/drivers/bus/dpaa/include/process.h b/drivers/bus/dpaa/include/process.h index 7305762c2..f52ea1635 100644 --- a/drivers/bus/dpaa/include/process.h +++ b/drivers/bus/dpaa/include/process.h @@ -91,7 +91,18 @@ struct usdpaa_ioctl_link_status_args { char if_name[IF_NAME_MAX_LEN]; int link_status; }; + +struct usdpaa_ioctl_update_link_status_args { + /* network device node name */ + char if_name[IF_NAME_MAX_LEN]; + /* link status(ETH_LINK_UP/DOWN) */ + int link_status; +}; + __rte_internal int dpaa_get_link_status(char *if_name); +__rte_internal +int dpaa_update_link_status(char *if_name, int link_status); + #endif /* __PROCESS_H */ diff --git a/drivers/bus/dpaa/rte_bus_dpaa_version.map b/drivers/bus/dpaa/rte_bus_dpaa_version.map index 96662d7be..5dec8d9e5 100644 --- a/drivers/bus/dpaa/rte_bus_dpaa_version.map +++ b/drivers/bus/dpaa/rte_bus_dpaa_version.map @@ -19,6 +19,7 @@ INTERNAL { dpaa_intr_disable; dpaa_intr_enable; dpaa_svr_family; + dpaa_update_link_status; fman_dealloc_bufs_mask_hi; fman_dealloc_bufs_mask_lo; fman_if_add_mac_addr; diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 3f805b2b0..3a5b319d4 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -478,18 +478,15 @@ static int dpaa_eth_link_update(struct rte_eth_dev *dev, DPAA_PMD_ERR("invalid link_speed: %s, %d", dpaa_intf->name, fif->mac_type); - ret = dpaa_get_link_status(__fif->node_name); - if (ret < 0) { - if (ret == -EINVAL) { - DPAA_PMD_DEBUG("Using default link status-No Support"); - ret = 1; - } else { - DPAA_PMD_ERR("rte_dpaa_get_link_status %d", ret); + if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) { + ret = dpaa_get_link_status(__fif->node_name); + if (ret < 0) return ret; - } + link->link_status = ret; + } else { + link->link_status = dpaa_intf->valid; } - link->link_status = ret; link->link_duplex = ETH_LINK_FULL_DUPLEX; link->link_autoneg = ETH_LINK_AUTONEG; @@ -985,17 +982,33 @@ dpaa_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) static int dpaa_link_down(struct rte_eth_dev *dev) { + struct fman_if *fif = dev->process_private; + struct __fman_if *__fif; + PMD_INIT_FUNC_TRACE(); - dpaa_eth_dev_stop(dev); + __fif = container_of(fif, struct __fman_if, __if); + + if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) + dpaa_update_link_status(__fif->node_name, ETH_LINK_DOWN); + else + dpaa_eth_dev_stop(dev); return 0; } static int dpaa_link_up(struct rte_eth_dev *dev) { + struct fman_if *fif = dev->process_private; + struct __fman_if *__fif; + PMD_INIT_FUNC_TRACE(); - dpaa_eth_dev_start(dev); + __fif = container_of(fif, struct __fman_if, __if); + + if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) + dpaa_update_link_status(__fif->node_name, ETH_LINK_UP); + else + dpaa_eth_dev_start(dev); return 0; }