From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 4CD6D2C4D for ; Mon, 21 Mar 2016 18:38:32 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 21 Mar 2016 10:38:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,372,1455004800"; d="scan'208";a="938531277" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga002.jf.intel.com with ESMTP; 21 Mar 2016 10:38:31 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 21 Mar 2016 10:38:31 -0700 Received: from fmsmsx113.amr.corp.intel.com ([169.254.13.211]) by fmsmsx115.amr.corp.intel.com ([10.18.116.19]) with mapi id 14.03.0248.002; Mon, 21 Mar 2016 10:38:30 -0700 From: "Wiles, Keith" To: Olivier Matz CC: "dev@dpdk.org" , "adrien.mazarguil@6wind.com" Thread-Topic: [dpdk-dev] [PATCH] mlx4: use dummy rxqs when a non-pow2 number is requested Thread-Index: AQHRg4wnW1SN61gqpkCdN+Zq1ohPWJ9kKd9r Date: Mon, 21 Mar 2016 17:38:30 +0000 Message-ID: <024DB49E-56E0-4550-A981-00CE20E6A23D@intel.com> References: <1458576484-28211-1-git-send-email-olivier.matz@6wind.com> In-Reply-To: <1458576484-28211-1-git-send-email-olivier.matz@6wind.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] mlx4: use dummy rxqs when a non-pow2 number is requested 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: Mon, 21 Mar 2016 17:38:33 -0000 Sent from my iPhone > On Mar 21, 2016, at 11:10 AM, Olivier Matz wrote= : >=20 > When using RSS, the number of rxqs has to be a power of two. > This is a problem because there is no API is dpdk that makes > the application aware of that. >=20 > A good compromise is to allow the application to request a > number of rxqs that is not a power of 2, but having inactive > queues that will never receive packets. In this configuration, > a warning will be issued to users to let them know that > this is not an optimal configuration. Not sure I like this solution. I think an error should be returned with a l= og message instead. What if the next driver needs power of three or must be= odd or even number.=20 The bigger problem is the application is no longer portable for any given n= ic configuration. We need a method for the application to query the system for these types of= information. But as we do not have that API we need to just error the requ= est off. >=20 > Signed-off-by: Olivier Matz > --- > drivers/net/mlx4/mlx4.c | 27 +++++++++++++++++---------- > 1 file changed, 17 insertions(+), 10 deletions(-) >=20 > diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c > index cc4e9aa..eaf06db 100644 > --- a/drivers/net/mlx4/mlx4.c > +++ b/drivers/net/mlx4/mlx4.c > @@ -698,7 +698,7 @@ txq_cleanup(struct txq *txq); >=20 > static int > rxq_setup(struct rte_eth_dev *dev, struct rxq *rxq, uint16_t desc, > - unsigned int socket, const struct rte_eth_rxconf *conf, > + unsigned int socket, int inactive, const struct rte_eth_rxconf *co= nf, > struct rte_mempool *mp); >=20 > static void > @@ -734,12 +734,12 @@ dev_configure(struct rte_eth_dev *dev) > } > if (rxqs_n =3D=3D priv->rxqs_n) > return 0; > - if ((rxqs_n & (rxqs_n - 1)) !=3D 0) { > - ERROR("%p: invalid number of RX queues (%u)," > - " must be a power of 2", > + if (!rte_is_power_of_2(rxqs_n)) { > + WARN("%p: number of RX queues (%u), must be a" > + " power of 2: remaining queues will be inactive", > (void *)dev, rxqs_n); > - return EINVAL; > } > + > INFO("%p: RX queues number update: %u -> %u", > (void *)dev, priv->rxqs_n, rxqs_n); > /* If RSS is enabled, disable it first. */ > @@ -775,7 +775,7 @@ dev_configure(struct rte_eth_dev *dev) > priv->rss =3D 1; > tmp =3D priv->rxqs_n; > priv->rxqs_n =3D rxqs_n; > - ret =3D rxq_setup(dev, &priv->rxq_parent, 0, 0, NULL, NULL); > + ret =3D rxq_setup(dev, &priv->rxq_parent, 0, 0, 0, NULL, NULL); > if (!ret) > return 0; > /* Failure, rollback. */ > @@ -3466,7 +3466,8 @@ rxq_setup_qp_rss(struct priv *priv, struct ibv_cq *= cq, uint16_t desc, > attr.qpg.qpg_type =3D IBV_EXP_QPG_PARENT; > /* TSS isn't necessary. */ > attr.qpg.parent_attrib.tss_child_count =3D 0; > - attr.qpg.parent_attrib.rss_child_count =3D priv->rxqs_n; > + attr.qpg.parent_attrib.rss_child_count =3D > + rte_align32pow2(priv->rxqs_n + 1) >> 1; > DEBUG("initializing parent RSS queue"); > } else { > attr.qpg.qpg_type =3D IBV_EXP_QPG_CHILD_RX; > @@ -3689,6 +3690,9 @@ skip_rtr: > * Number of descriptors to configure in queue. > * @param socket > * NUMA socket on which memory must be allocated. > + * @param inactive > + * If true, the queue is disabled because its index is higher or > + * equal to the real number of queues, which must be a power of 2. > * @param[in] conf > * Thresholds parameters. > * @param mp > @@ -3699,7 +3703,7 @@ skip_rtr: > */ > static int > rxq_setup(struct rte_eth_dev *dev, struct rxq *rxq, uint16_t desc, > - unsigned int socket, const struct rte_eth_rxconf *conf, > + unsigned int socket, int inactive, const struct rte_eth_rxconf *co= nf, > struct rte_mempool *mp) > { > struct priv *priv =3D dev->data->dev_private; > @@ -3800,7 +3804,7 @@ skip_mr: > DEBUG("priv->device_attr.max_sge is %d", > priv->device_attr.max_sge); > #ifdef RSS_SUPPORT > - if (priv->rss) > + if (priv->rss && !inactive) > tmpl.qp =3D rxq_setup_qp_rss(priv, tmpl.cq, desc, parent, > tmpl.rd); > else > @@ -3936,6 +3940,7 @@ mlx4_rx_queue_setup(struct rte_eth_dev *dev, uint16= _t idx, uint16_t desc, > { > struct priv *priv =3D dev->data->dev_private; > struct rxq *rxq =3D (*priv->rxqs)[idx]; > + int inactive =3D 0; > int ret; >=20 > if (mlx4_is_secondary()) > @@ -3967,7 +3972,9 @@ mlx4_rx_queue_setup(struct rte_eth_dev *dev, uint16= _t idx, uint16_t desc, > return -ENOMEM; > } > } > - ret =3D rxq_setup(dev, rxq, desc, socket, conf, mp); > + if (idx >=3D rte_align32pow2(priv->rxqs_n + 1) >> 1) > + inactive =3D 1; > + ret =3D rxq_setup(dev, rxq, desc, socket, inactive, conf, mp); > if (ret) > rte_free(rxq); > else { > --=20 > 2.1.4 >=20