From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by dpdk.org (Postfix) with ESMTP id 62F0356A1 for ; Thu, 17 Mar 2016 16:39:19 +0100 (CET) Received: by mail-wm0-f54.google.com with SMTP id l68so31760649wml.0 for ; Thu, 17 Mar 2016 08:39:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wlRGPq0ZcGTE0zteq/ehELfpqlsB/Hvtp6rjihBS81k=; b=cXGF68+Pb29z3GSGJpk+hZBFHlOsXiAhRxEWAgH0EhfSqsQmBaEATlk7OvnIPoaKSo AU45/Gn4ycbXgzTWGzY3O3w56t+OaIxBDnMG8TZbsbREhrFCDHAu0zXDdQls4W7xwNOh J1wSERW+OaBIgpWxkWPpZzH1Dr08mc8ToxO8nIGFtOmn3Vo3u4uBt8rXUTj1Dxk2hisP 6hkRUf4xz20h4Sc8gh3rFJCgma3fFg5cPQg+S+ScPYFlhaKcC6EaDlHq+EnniVr+hGhd 0ppsXhpkBwwyx1yERE1dfmsTXGm76vFPvtecYSc8SxxTT+fzwTJT9C44F8gXkCNYPebM 4ytg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wlRGPq0ZcGTE0zteq/ehELfpqlsB/Hvtp6rjihBS81k=; b=dsZKF9/OZBt6tboengykieU3WVJTeSL0DgDgCXvQfEqkJdk5j3RH/ggXnk8IuIztd0 lbFoBHPYomsfo5mQvvIb7lFPj6543sfRnpSYJkcC1nRwWl0IL8jVx1MEV/kAqklEMe51 F3oh3WBxPiGO+2DvkOspMeW9iNUF21wmp6+jX/rzp2cG1rNjSVK6k6Q3SN40UmFSBb8S n/QwOG6e5gtCm4JBaWd2rlrhLeGRryMKNtNpl+ZlwMZvQQNjHA9dXQfuwHEJgkTlh/51 uqWD7RrnWoSXn4BGPipxvIZ1lBpEsPqXsgrcDZCpnMLkDpRBXMDCM4/5Y3CJyr8+T8T2 5QvQ== X-Gm-Message-State: AD7BkJJ0wOJ/GSKTUTVMfSHWiWILrsT3x/75lnC0jBONocCr2t15bDRjgq57KbCWY33/Ptrj X-Received: by 10.28.0.148 with SMTP id 142mr11083367wma.72.1458229159289; Thu, 17 Mar 2016 08:39:19 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id r62sm8674354wmd.15.2016.03.17.08.39.17 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 Mar 2016 08:39:18 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Cc: Or Ami Date: Thu, 17 Mar 2016 16:38:54 +0100 Message-Id: <1458229138-20597-2-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458229138-20597-1-git-send-email-adrien.mazarguil@6wind.com> References: <1457015279-3089-1-git-send-email-adrien.mazarguil@6wind.com> <1458229138-20597-1-git-send-email-adrien.mazarguil@6wind.com> Subject: [dpdk-dev] [PATCH v3 1/5] mlx5: add callbacks to support link (up / down) changes X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Mar 2016 15:39:19 -0000 From: Or Ami Burst functions are updated to make sure applications cannot attempt to send/receive after link is brought down. Signed-off-by: Or Ami --- doc/guides/rel_notes/release_16_04.rst | 4 ++ drivers/net/mlx5/mlx5.c | 2 + drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_ethdev.c | 85 ++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+) diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst index 5f9eb3e..a011f0b 100644 --- a/doc/guides/rel_notes/release_16_04.rst +++ b/doc/guides/rel_notes/release_16_04.rst @@ -130,6 +130,10 @@ This section should contain new features added in this release. Sample format: Only available with Mellanox OFED >= 3.2. +* **Added mlx5 link up/down callbacks.** + + Implemented callbacks to bring link up and down. + * **Added af_packet dynamic removal function.** Af_packet device can now be detached using API, like other PMD devices. diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index ad69ec2..14ac4ba 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -148,6 +148,8 @@ static const struct eth_dev_ops mlx5_dev_ops = { .dev_configure = mlx5_dev_configure, .dev_start = mlx5_dev_start, .dev_stop = mlx5_dev_stop, + .dev_set_link_down = mlx5_set_link_down, + .dev_set_link_up = mlx5_set_link_up, .dev_close = mlx5_dev_close, .promiscuous_enable = mlx5_promiscuous_enable, .promiscuous_disable = mlx5_promiscuous_disable, diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 43b24fb..9a3f240 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -168,6 +168,8 @@ void mlx5_dev_link_status_handler(void *); void mlx5_dev_interrupt_handler(struct rte_intr_handle *, void *); void priv_dev_interrupt_handler_uninstall(struct priv *, struct rte_eth_dev *); void priv_dev_interrupt_handler_install(struct priv *, struct rte_eth_dev *); +int mlx5_set_link_down(struct rte_eth_dev *dev); +int mlx5_set_link_up(struct rte_eth_dev *dev); /* mlx5_mac.c */ diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index 6704382..f609e0f 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -968,3 +968,88 @@ priv_dev_interrupt_handler_install(struct priv *priv, struct rte_eth_dev *dev) dev); } } + +/** + * Change the link state (UP / DOWN). + * + * @param dev + * Pointer to Ethernet device structure. + * @param up + * Nonzero for link up, otherwise link down. + * + * @return + * 0 on success, errno value on failure. + */ +static int +priv_set_link(struct priv *priv, int up) +{ + struct rte_eth_dev *dev = priv->dev; + int err; + unsigned int i; + + if (up) { + err = priv_set_flags(priv, ~IFF_UP, IFF_UP); + if (err) + return err; + for (i = 0; i < priv->rxqs_n; i++) + if ((*priv->rxqs)[i]->sp) + break; + /* Check if an sp queue exists. + * Note: Some old frames might be received. + */ + if (i == priv->rxqs_n) + dev->rx_pkt_burst = mlx5_rx_burst; + else + dev->rx_pkt_burst = mlx5_rx_burst_sp; + dev->tx_pkt_burst = mlx5_tx_burst; + } else { + err = priv_set_flags(priv, ~IFF_UP, ~IFF_UP); + if (err) + return err; + dev->rx_pkt_burst = removed_rx_burst; + dev->tx_pkt_burst = removed_tx_burst; + } + return 0; +} + +/** + * DPDK callback to bring the link DOWN. + * + * @param dev + * Pointer to Ethernet device structure. + * + * @return + * 0 on success, errno value on failure. + */ +int +mlx5_set_link_down(struct rte_eth_dev *dev) +{ + struct priv *priv = dev->data->dev_private; + int err; + + priv_lock(priv); + err = priv_set_link(priv, 0); + priv_unlock(priv); + return err; +} + +/** + * DPDK callback to bring the link UP. + * + * @param dev + * Pointer to Ethernet device structure. + * + * @return + * 0 on success, errno value on failure. + */ +int +mlx5_set_link_up(struct rte_eth_dev *dev) +{ + struct priv *priv = dev->data->dev_private; + int err; + + priv_lock(priv); + err = priv_set_link(priv, 1); + priv_unlock(priv); + return err; +} -- 2.1.4