From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ioana Ciocoi Radulescu Subject: [PATCH net-next 3/3] dpaa2-eth: bql support Date: Wed, 14 Nov 2018 11:48:36 +0000 Message-ID: <1542196109-1127-4-git-send-email-ruxandra.radulescu@nxp.com> References: <1542196109-1127-1-git-send-email-ruxandra.radulescu@nxp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: Ioana Ciornei To: "netdev@vger.kernel.org" , "davem@davemloft.net" Return-path: Received: from mail-eopbgr80048.outbound.protection.outlook.com ([40.107.8.48]:31137 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728277AbeKNVvl (ORCPT ); Wed, 14 Nov 2018 16:51:41 -0500 In-Reply-To: <1542196109-1127-1-git-send-email-ruxandra.radulescu@nxp.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: Add support for byte queue limit. On NAPI poll, we save the total number of Tx confirmed frames/bytes and register them with bql at the end of the poll function. Signed-off-by: Ioana Radulescu --- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 59 ++++++++++++++++++--= ---- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h | 2 + 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net= /ethernet/freescale/dpaa2/dpaa2-eth.c index be31287..640967a 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -288,7 +288,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, * Observance of NAPI budget is not our concern, leaving that to the calle= r. */ static int consume_frames(struct dpaa2_eth_channel *ch, - enum dpaa2_eth_fq_type *type) + struct dpaa2_eth_fq **src) { struct dpaa2_eth_priv *priv =3D ch->priv; struct dpaa2_eth_fq *fq =3D NULL; @@ -322,10 +322,10 @@ static int consume_frames(struct dpaa2_eth_channel *c= h, ch->stats.frames +=3D cleaned; =20 /* A dequeue operation only pulls frames from a single queue - * into the store. Return the frame queue type as an out param. + * into the store. Return the frame queue as an out param. */ - if (type) - *type =3D fq->type; + if (src) + *src =3D fq; =20 return cleaned; } @@ -570,8 +570,10 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, s= truct net_device *net_dev) struct rtnl_link_stats64 *percpu_stats; struct dpaa2_eth_drv_stats *percpu_extras; struct dpaa2_eth_fq *fq; + struct netdev_queue *nq; u16 queue_mapping; unsigned int needed_headroom; + u32 fd_len; int err, i; =20 percpu_stats =3D this_cpu_ptr(priv->percpu_stats); @@ -643,8 +645,12 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, s= truct net_device *net_dev) /* Clean up everything, including freeing the skb */ free_tx_fd(priv, &fd); } else { + fd_len =3D dpaa2_fd_get_len(&fd); percpu_stats->tx_packets++; - percpu_stats->tx_bytes +=3D dpaa2_fd_get_len(&fd); + percpu_stats->tx_bytes +=3D fd_len; + + nq =3D netdev_get_tx_queue(net_dev, queue_mapping); + netdev_tx_sent_queue(nq, fd_len); } =20 return NETDEV_TX_OK; @@ -660,10 +666,11 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, = struct net_device *net_dev) static void dpaa2_eth_tx_conf(struct dpaa2_eth_priv *priv, struct dpaa2_eth_channel *ch __always_unused, const struct dpaa2_fd *fd, - struct dpaa2_eth_fq *fq __always_unused) + struct dpaa2_eth_fq *fq) { struct rtnl_link_stats64 *percpu_stats; struct dpaa2_eth_drv_stats *percpu_extras; + u32 fd_len =3D dpaa2_fd_get_len(fd); u32 fd_errors; =20 /* Tracing point */ @@ -671,7 +678,10 @@ static void dpaa2_eth_tx_conf(struct dpaa2_eth_priv *p= riv, =20 percpu_extras =3D this_cpu_ptr(priv->percpu_extras); percpu_extras->tx_conf_frames++; - percpu_extras->tx_conf_bytes +=3D dpaa2_fd_get_len(fd); + percpu_extras->tx_conf_bytes +=3D fd_len; + + fq->dq_frames++; + fq->dq_bytes +=3D fd_len; =20 /* Check frame errors in the FD field */ fd_errors =3D dpaa2_fd_get_ctrl(fd) & DPAA2_FD_TX_ERR_MASK; @@ -932,8 +942,9 @@ static int dpaa2_eth_poll(struct napi_struct *napi, int= budget) struct dpaa2_eth_channel *ch; struct dpaa2_eth_priv *priv; int rx_cleaned =3D 0, txconf_cleaned =3D 0; - enum dpaa2_eth_fq_type type =3D 0; - int store_cleaned; + struct dpaa2_eth_fq *fq, *txc_fq =3D NULL; + struct netdev_queue *nq; + int store_cleaned, work_done; int err; =20 ch =3D container_of(napi, struct dpaa2_eth_channel, napi); @@ -947,18 +958,25 @@ static int dpaa2_eth_poll(struct napi_struct *napi, i= nt budget) /* Refill pool if appropriate */ refill_pool(priv, ch, priv->bpid); =20 - store_cleaned =3D consume_frames(ch, &type); - if (type =3D=3D DPAA2_RX_FQ) + store_cleaned =3D consume_frames(ch, &fq); + if (!store_cleaned) + break; + if (fq->type =3D=3D DPAA2_RX_FQ) { rx_cleaned +=3D store_cleaned; - else + } else { txconf_cleaned +=3D store_cleaned; + /* We have a single Tx conf FQ on this channel */ + txc_fq =3D fq; + } =20 /* If we either consumed the whole NAPI budget with Rx frames * or we reached the Tx confirmations threshold, we're done. */ if (rx_cleaned >=3D budget || - txconf_cleaned >=3D DPAA2_ETH_TXCONF_PER_NAPI) - return budget; + txconf_cleaned >=3D DPAA2_ETH_TXCONF_PER_NAPI) { + work_done =3D budget; + goto out; + } } while (store_cleaned); =20 /* We didn't consume the entire budget, so finish napi and @@ -972,7 +990,18 @@ static int dpaa2_eth_poll(struct napi_struct *napi, in= t budget) WARN_ONCE(err, "CDAN notifications rearm failed on core %d", ch->nctx.desired_cpu); =20 - return max(rx_cleaned, 1); + work_done =3D max(rx_cleaned, 1); + +out: + if (txc_fq) { + nq =3D netdev_get_tx_queue(priv->net_dev, txc_fq->flowid); + netdev_tx_completed_queue(nq, txc_fq->dq_frames, + txc_fq->dq_bytes); + txc_fq->dq_frames =3D 0; + txc_fq->dq_bytes =3D 0; + } + + return work_done; } =20 static void enable_ch_napi(struct dpaa2_eth_priv *priv) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net= /ethernet/freescale/dpaa2/dpaa2-eth.h index 3af706a..16545e9 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h @@ -271,6 +271,8 @@ struct dpaa2_eth_fq { u32 tx_qdbin; u16 flowid; int target_cpu; + u32 dq_frames; + u32 dq_bytes; struct dpaa2_eth_channel *channel; enum dpaa2_eth_fq_type type; =20 --=20 2.7.4