From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 095641B42C for ; Tue, 12 Feb 2019 07:36:25 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Feb 2019 22:36:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,361,1544515200"; d="scan'208";a="117197645" Received: from pgsmsx108.gar.corp.intel.com ([10.221.44.103]) by orsmga008.jf.intel.com with ESMTP; 11 Feb 2019 22:36:23 -0800 Received: from pgsmsx103.gar.corp.intel.com ([169.254.2.6]) by PGSMSX108.gar.corp.intel.com ([169.254.8.83]) with mapi id 14.03.0415.000; Tue, 12 Feb 2019 14:36:22 +0800 From: "Zhao1, Wei" To: Julien Meunier , "Ananyev, Konstantin" , "Lu, Wenzhuo" , "Zhang, Qi Z" CC: "dev@dpdk.org" Thread-Topic: [PATCH 1/2] net/ixgbe: do not start on unsupported loopback mode Thread-Index: AQHUvwrbkwm+ra5Yk06SFrq/I9cgKaXbu6yA Date: Tue, 12 Feb 2019 06:36:22 +0000 Message-ID: References: <20190102160055.30301-1-julien.meunier@nokia.com> <20190207173005.38372-1-julien.meunier@nokia.com> In-Reply-To: <20190207173005.38372-1-julien.meunier@nokia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [172.30.20.206] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 1/2] net/ixgbe: do not start on unsupported loopback mode 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: , X-List-Received-Date: Tue, 12 Feb 2019 06:36:26 -0000 Hi, Meunier Only a little change need for this patch. Acked-by: Wei Zhao > -----Original Message----- > From: Julien Meunier [mailto:julien.meunier@nokia.com] > Sent: Friday, February 8, 2019 1:30 AM > To: Ananyev, Konstantin ; Lu, Wenzhuo > ; Zhao1, Wei ; Zhang, Qi Z > > Cc: dev@dpdk.org > Subject: [PATCH 1/2] net/ixgbe: do not start on unsupported loopback mode >=20 > Only TX->RX loopback is supported currently on 82599EB. If a user wants t= o > apply an another loopback configuration (!=3D IXGBE_LPBK_82599_TX_RX), > ixgbe PMD ignores it and continues the configuration without raising any > error. >=20 > Let's robustify this part by checking if the requested loopback mode is c= orrect > for the current device, before starting it. If it is not valid, PMD will = refuse to > start. >=20 > Signed-off-by: Julien Meunier > --- > v2: > - factorize code > - check if loopback is really supported > --- > drivers/net/ixgbe/ixgbe_ethdev.c | 13 +++++++++---- > drivers/net/ixgbe/ixgbe_rxtx.c | 37 +++++++++++++++++++++++++++++-- > ------ > drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++ > 3 files changed, 40 insertions(+), 12 deletions(-) >=20 > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c > b/drivers/net/ixgbe/ixgbe_ethdev.c > index 7493110..558f60b 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > @@ -2652,10 +2652,15 @@ ixgbe_dev_start(struct rte_eth_dev *dev) > goto error; > } >=20 > - /* Skip link setup if loopback mode is enabled for 82599. */ > - if (hw->mac.type =3D=3D ixgbe_mac_82599EB && > - dev->data->dev_conf.lpbk_mode =3D=3D > IXGBE_LPBK_82599_TX_RX) > - goto skip_link_setup; > + /* Skip link setup if loopback mode is enabled. */ > + if (dev->data->dev_conf.lpbk_mode !=3D 0) { > + err =3D ixgbe_check_supported_loopback_mode(dev); > + if (err < 0) { > + PMD_INIT_LOG(ERR, "Unsupported loopback > mode"); > + goto error; > + } else > + goto skip_link_setup; > + } >=20 > if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) { > err =3D hw->mac.ops.setup_sfp(hw); > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxt= x.c > index 9a79d18..c9a70a8 100644 > --- a/drivers/net/ixgbe/ixgbe_rxtx.c > +++ b/drivers/net/ixgbe/ixgbe_rxtx.c > @@ -4879,13 +4879,18 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev) > hlreg0 &=3D ~IXGBE_HLREG0_JUMBOEN; >=20 > /* > - * If loopback mode is configured for 82599, set LPBK bit. > + * If loopback mode is configured, set LPBK bit. > */ > - if (hw->mac.type =3D=3D ixgbe_mac_82599EB && > - dev->data->dev_conf.lpbk_mode =3D=3D > IXGBE_LPBK_82599_TX_RX) > + if (dev->data->dev_conf.lpbk_mode !=3D 0) { > + rc =3D ixgbe_check_supported_loopback_mode(dev); > + if (rc < 0) { > + PMD_INIT_LOG(ERR, "Unsupported loopback > mode"); > + return rc; > + } > hlreg0 |=3D IXGBE_HLREG0_LPBK; > - else > + } else { > hlreg0 &=3D ~IXGBE_HLREG0_LPBK; > + } >=20 > IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0); >=20 > @@ -5062,6 +5067,21 @@ ixgbe_dev_tx_init(struct rte_eth_dev *dev) } >=20 > /* > + * Check if requested loopback mode is supported */ int > +ixgbe_check_supported_loopback_mode(struct rte_eth_dev *dev) { > + struct ixgbe_hw *hw =3D IXGBE_DEV_PRIVATE_TO_HW(dev->data- > >dev_private); > + > + if (dev->data->dev_conf.lpbk_mode =3D=3D IXGBE_LPBK_82599_TX_RX) > + if (hw->mac.type =3D=3D ixgbe_mac_82599EB) > + return 0; > + > + return -ENOTSUP; > +} > + > +/* > * Set up link for 82599 loopback mode Tx->Rx. > */ > static inline void __attribute__((cold)) @@ -5148,10 +5168,11 @@ > ixgbe_dev_rxtx_start(struct rte_eth_dev *dev) > rxctrl |=3D IXGBE_RXCTRL_RXEN; > hw->mac.ops.enable_rx_dma(hw, rxctrl); >=20 > - /* If loopback mode is enabled for 82599, set up the link accordingly > */ > - if (hw->mac.type =3D=3D ixgbe_mac_82599EB && > - dev->data->dev_conf.lpbk_mode =3D=3D > IXGBE_LPBK_82599_TX_RX) > - ixgbe_setup_loopback_link_82599(hw); > + /* If loopback mode is enabled, set up the link accordingly */ > + if (dev->data->dev_conf.lpbk_mode !=3D 0) { > + if (hw->mac.type =3D=3D ixgbe_mac_82599EB) > + ixgbe_setup_loopback_link_82599(hw); > + } >=20 > #ifdef RTE_LIBRTE_SECURITY > if ((dev->data->dev_conf.rxmode.offloads & diff --git > a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h index > 39378f7..2d8011d 100644 > --- a/drivers/net/ixgbe/ixgbe_rxtx.h > +++ b/drivers/net/ixgbe/ixgbe_rxtx.h > @@ -276,6 +276,8 @@ void ixgbe_set_tx_function(struct rte_eth_dev *dev, > struct ixgbe_tx_queue *txq); > */ > void ixgbe_set_rx_function(struct rte_eth_dev *dev); >=20 > +int ixgbe_check_supported_loopback_mode(struct rte_eth_dev *dev); > + Space needed? > uint16_t ixgbe_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, > uint16_t nb_pkts); > uint16_t ixgbe_recv_scattered_pkts_vec(void *rx_queue, > -- > 2.10.2