From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id DDEC11B2AA for ; Tue, 13 Feb 2018 12:53:46 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 89DB320A86; Tue, 13 Feb 2018 06:53:46 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Tue, 13 Feb 2018 06:53:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=dVxNm4/oOePMvPLPUIP4p/9Dktni/FL1qmELcWpXsEw=; b=k8XzH/dT lUoxVRH9sce5n9PwEeR3+Nxwjt+HFdRfNx2xdNl3kT+UzFKgN5Ev3dWghGv6EPIQ +LPiY0hTMG80zhymgDdQcqfioY3OJw3zVtmnYWxj2ncmdxCDZZ6haxFciPhru6Jc Var78fTy/sy61yTHOAztbzDLeU9jvuA2jVtu3lv8DNFu53IRxzuxFP1Gm5jAuT2h DtDg300L8Zhi/xVazj/UzASeFrJedD15N58MV8+A9oUWC0fKIkQjqaQi+EHfa7zN wGGa2SfDYMLuXu1rur9HHYt5ien2iR79Gnb9fURtVUQ+Bw8Euvnn4R4ip8EMG0gT CxZ+trmrb0KJ6A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=dVxNm4/oOePMvPLPUIP4p/9Dktni/ FL1qmELcWpXsEw=; b=V1RBCzsb42XtJvio++2Eg38k0ES/8orLCi8DF/ew8L+4U H1C/WwGcd5ucUKF21EVTTKlMBLcDseY0XtH4T75Ft4+Pqubnwr0q1w8yaEvHIGP5 TzRobUjwUrStvJEg6yXmLByYrRwVKb7xSnNIkUfbULYAYYsVvXrIqbYMQR+qUCSn pIrB/wETWf7j8Q6Rwf9U+GhTOHPbSwUNotXG91P7IjdbRqwQiwnT+Ce928V2bJom qvodb1yRwSlpyi4GcGJKEQfET2cX5Oy6k8xvpJz49bKd+5VxNgmacGErbxMym/WA jvifHx4R28QR4fJ6FJnVw3N34+y8IOsvVROUUNQ3g== X-ME-Sender: Received: from yliu-mob (unknown [115.150.27.48]) by mail.messagingengine.com (Postfix) with ESMTPA id 7EF4C246A5; Tue, 13 Feb 2018 06:53:45 -0500 (EST) Date: Tue, 13 Feb 2018 19:53:42 +0800 From: Yuanhan Liu To: Yongseok Koh Cc: stable@dpdk.org Message-ID: <20180213115342.GE2156@yliu-mob> References: <20180212182022.36466-1-yskoh@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180212182022.36466-1-yskoh@mellanox.com> User-Agent: Mutt/1.5.24 (2015-08-30) Subject: Re: [dpdk-stable] [PATCH] net/mlx5: fix handling link status event X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Feb 2018 11:53:47 -0000 On Mon, Feb 12, 2018 at 10:20:22AM -0800, Yongseok Koh wrote: > [ backported from upstream commit c7bf62255edf ] > > Even though link of a port gets down, device still can receive traffic. > That is the reason why mlx5_set_link_up/down() switches rx/tx_pkt_burst(). > However, if link gets down by an external command (e.g. ifconfig), it isn't > effective. It is better to change burst functions when link status change > is detected. > > Fixes: 62072098b54e ("mlx5: support setting link up or down") > Cc: stable@dpdk.org > > Signed-off-by: Yongseok Koh > Acked-by: Nelio Laranjeiro Applied to dpdk-stable/17.11. Thanks! --yliu > --- > drivers/net/mlx5/mlx5.c | 1 - > drivers/net/mlx5/mlx5.h | 1 + > drivers/net/mlx5/mlx5_ethdev.c | 118 ++++++++++++++++++++++++++++++---------- > drivers/net/mlx5/mlx5_trigger.c | 23 ++------ > 4 files changed, 95 insertions(+), 48 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c > index eba674269..40804b3e6 100644 > --- a/drivers/net/mlx5/mlx5.c > +++ b/drivers/net/mlx5/mlx5.c > @@ -932,7 +932,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) > /* Bring Ethernet device up. */ > DEBUG("forcing Ethernet interface up"); > priv_set_flags(priv, ~IFF_UP, IFF_UP); > - mlx5_link_update(priv->dev, 1); > continue; > > port_error: > diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h > index 1a4f444c7..de9071f5d 100644 > --- a/drivers/net/mlx5/mlx5.h > +++ b/drivers/net/mlx5/mlx5.h > @@ -210,6 +210,7 @@ int priv_set_flags(struct priv *, unsigned int, unsigned int); > int mlx5_dev_configure(struct rte_eth_dev *); > void mlx5_dev_infos_get(struct rte_eth_dev *, struct rte_eth_dev_info *); > const uint32_t *mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev); > +int priv_link_update(struct priv *, int); > int mlx5_link_update(struct rte_eth_dev *, int); > int mlx5_dev_set_mtu(struct rte_eth_dev *, uint16_t); > int mlx5_dev_get_flow_ctrl(struct rte_eth_dev *, struct rte_eth_fc_conf *); > diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c > index e91c0f633..25f84e9bc 100644 > --- a/drivers/net/mlx5/mlx5_ethdev.c > +++ b/drivers/net/mlx5/mlx5_ethdev.c > @@ -914,25 +914,104 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete) > } > > /** > - * DPDK callback to retrieve physical link information. > + * Enable receiving and transmitting traffic. > * > - * @param dev > - * Pointer to Ethernet device structure. > + * @param priv > + * Pointer to private structure. > + */ > +static void > +priv_link_start(struct priv *priv) > +{ > + struct rte_eth_dev *dev = priv->dev; > + int err; > + > + priv_dev_select_tx_function(priv, dev); > + priv_dev_select_rx_function(priv, dev); > + err = priv_dev_traffic_enable(priv, dev); > + if (err) > + ERROR("%p: error occurred while configuring control flows: %s", > + (void *)priv, strerror(err)); > + err = priv_flow_start(priv, &priv->flows); > + if (err) > + ERROR("%p: error occurred while configuring flows: %s", > + (void *)priv, strerror(err)); > +} > + > +/** > + * Disable receiving and transmitting traffic. > + * > + * @param priv > + * Pointer to private structure. > + */ > +static void > +priv_link_stop(struct priv *priv) > +{ > + struct rte_eth_dev *dev = priv->dev; > + > + priv_flow_stop(priv, &priv->flows); > + priv_dev_traffic_disable(priv, dev); > + dev->rx_pkt_burst = removed_rx_burst; > + dev->tx_pkt_burst = removed_tx_burst; > +} > + > +/** > + * Retrieve physical link information and update rx/tx_pkt_burst callbacks > + * accordingly. > + * > + * @param priv > + * Pointer to private structure. > * @param wait_to_complete > * Wait for request completion (ignored). > */ > int > -mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete) > +priv_link_update(struct priv *priv, int wait_to_complete) > { > + struct rte_eth_dev *dev = priv->dev; > struct utsname utsname; > int ver[3]; > + int ret; > + struct rte_eth_link dev_link = dev->data->dev_link; > > if (uname(&utsname) == -1 || > sscanf(utsname.release, "%d.%d.%d", > &ver[0], &ver[1], &ver[2]) != 3 || > KERNEL_VERSION(ver[0], ver[1], ver[2]) < KERNEL_VERSION(4, 9, 0)) > - return mlx5_link_update_unlocked_gset(dev, wait_to_complete); > - return mlx5_link_update_unlocked_gs(dev, wait_to_complete); > + ret = mlx5_link_update_unlocked_gset(dev, wait_to_complete); > + else > + ret = mlx5_link_update_unlocked_gs(dev, wait_to_complete); > + /* If lsc interrupt is disabled, should always be ready for traffic. */ > + if (!dev->data->dev_conf.intr_conf.lsc) { > + priv_link_start(priv); > + return ret; > + } > + /* Re-select burst callbacks only if link status has been changed. */ > + if (!ret && dev_link.link_status != dev->data->dev_link.link_status) { > + if (dev->data->dev_link.link_status == ETH_LINK_UP) > + priv_link_start(priv); > + else > + priv_link_stop(priv); > + } > + return ret; > +} > + > +/** > + * DPDK callback to retrieve physical link information. > + * > + * @param dev > + * Pointer to Ethernet device structure. > + * @param wait_to_complete > + * Wait for request completion (ignored). > + */ > +int > +mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete) > +{ > + struct priv *priv = dev->data->dev_private; > + int ret; > + > + priv_lock(priv); > + ret = priv_link_update(priv, wait_to_complete); > + priv_unlock(priv); > + return ret; > } > > /** > @@ -1151,7 +1230,7 @@ priv_link_status_update(struct priv *priv) > { > struct rte_eth_link *link = &priv->dev->data->dev_link; > > - mlx5_link_update(priv->dev, 0); > + priv_link_update(priv, 0); > if (((link->link_speed == 0) && link->link_status) || > ((link->link_speed != 0) && !link->link_status)) { > /* > @@ -1354,8 +1433,6 @@ priv_dev_interrupt_handler_install(struct priv *priv, struct rte_eth_dev *dev) > * > * @param priv > * Pointer to private data structure. > - * @param dev > - * Pointer to rte_eth_dev structure. > * @param up > * Nonzero for link up, otherwise link down. > * > @@ -1363,24 +1440,9 @@ priv_dev_interrupt_handler_install(struct priv *priv, struct rte_eth_dev *dev) > * 0 on success, errno value on failure. > */ > static int > -priv_dev_set_link(struct priv *priv, struct rte_eth_dev *dev, int up) > +priv_dev_set_link(struct priv *priv, int up) > { > - int err; > - > - if (up) { > - err = priv_set_flags(priv, ~IFF_UP, IFF_UP); > - if (err) > - return err; > - priv_dev_select_tx_function(priv, dev); > - priv_dev_select_rx_function(priv, dev); > - } 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; > + return priv_set_flags(priv, ~IFF_UP, up ? IFF_UP : ~IFF_UP); > } > > /** > @@ -1399,7 +1461,7 @@ mlx5_set_link_down(struct rte_eth_dev *dev) > int err; > > priv_lock(priv); > - err = priv_dev_set_link(priv, dev, 0); > + err = priv_dev_set_link(priv, 0); > priv_unlock(priv); > return err; > } > @@ -1420,7 +1482,7 @@ mlx5_set_link_up(struct rte_eth_dev *dev) > int err; > > priv_lock(priv); > - err = priv_dev_set_link(priv, dev, 1); > + err = priv_dev_set_link(priv, 1); > priv_unlock(priv); > return err; > } > diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c > index 39c5ec5d2..01780ef18 100644 > --- a/drivers/net/mlx5/mlx5_trigger.c > +++ b/drivers/net/mlx5/mlx5_trigger.c > @@ -154,38 +154,23 @@ mlx5_dev_start(struct rte_eth_dev *dev) > (void *)dev, strerror(err)); > goto error; > } > - /* Update send callback. */ > - priv_dev_select_tx_function(priv, dev); > err = priv_rxq_start(priv); > if (err) { > ERROR("%p: RXQ allocation failed: %s", > (void *)dev, strerror(err)); > goto error; > } > - /* Update receive callback. */ > - priv_dev_select_rx_function(priv, dev); > - err = priv_dev_traffic_enable(priv, dev); > - if (err) { > - ERROR("%p: an error occurred while configuring control flows:" > - " %s", > - (void *)priv, strerror(err)); > - goto error; > - } > - err = priv_flow_start(priv, &priv->flows); > - if (err) { > - ERROR("%p: an error occurred while configuring flows:" > - " %s", > - (void *)priv, strerror(err)); > - goto error; > - } > err = priv_rx_intr_vec_enable(priv); > if (err) { > ERROR("%p: RX interrupt vector creation failed", > (void *)priv); > goto error; > } > - priv_dev_interrupt_handler_install(priv, dev); > priv_xstats_init(priv); > + /* Update link status and Tx/Rx callbacks for the first time. */ > + memset(&dev->data->dev_link, 0, sizeof(struct rte_eth_link)); > + priv_link_update(priv, 1); > + priv_dev_interrupt_handler_install(priv, dev); > priv_unlock(priv); > return 0; > error: > -- > 2.11.0