From 8b99b4595d2b5f4d0b2252b16de83572e03b337a Mon Sep 17 00:00:00 2001 From: Kavi Akhila-B46177 Date: Thu, 2 Nov 2017 12:05:35 +0530 Subject: [PATCH] staging: fsl_ppfe/eth: Avoid packet drop at TMU queues Added flow control between TMU queues and PFE Linux driver, based on TMU credits availability. Added tx_qos module parameter to control this behavior. Use queue-0 as default queue to transmit packets. Signed-off-by: Calvin Johnson Signed-off-by: Akhila Kavi Signed-off-by: Anjaneyulu Jagarlmudi --- drivers/staging/fsl_ppfe/pfe_eth.c | 17 +++++++++++++---- drivers/staging/fsl_ppfe/pfe_hif_lib.c | 7 +++++-- 2 files changed, 18 insertions(+), 6 deletions(-) --- a/drivers/staging/fsl_ppfe/pfe_eth.c +++ b/drivers/staging/fsl_ppfe/pfe_eth.c @@ -293,10 +293,10 @@ static int pfe_eth_sysfs_init(struct net /* Initialize the default values */ /* - * By default, packets without conntrack will use this default high + * By default, packets without conntrack will use this default low * priority queue */ - priv->default_priority = 15; + priv->default_priority = 0; /* Create our sysfs files */ err = device_create_file(&ndev->dev, &dev_attr_default_priority); @@ -1566,10 +1566,17 @@ static int pfe_eth_might_stop_tx(struct unsigned int n_segs) { ktime_t kt; + int tried = 0; +try_again: if (unlikely((__hif_tx_avail(&pfe->hif) < n_desc) || - (hif_lib_tx_avail(&priv->client, queuenum) < n_desc) || + (hif_lib_tx_avail(&priv->client, queuenum) < n_desc) || (hif_lib_tx_credit_avail(pfe, priv->id, queuenum) < n_segs))) { + if (!tried) { + __hif_lib_update_credit(&priv->client, queuenum); + tried = 1; + goto try_again; + } #ifdef PFE_ETH_TX_STATS if (__hif_tx_avail(&pfe->hif) < n_desc) { priv->stop_queue_hif[queuenum]++; @@ -1692,8 +1699,10 @@ static void pfe_eth_flush_tx(struct pfe_ netif_info(priv, tx_done, priv->ndev, "%s\n", __func__); - for (ii = 0; ii < emac_txq_cnt; ii++) + for (ii = 0; ii < emac_txq_cnt; ii++) { pfe_eth_flush_txQ(priv, ii, 0, 0); + __hif_lib_update_credit(&priv->client, ii); + } } void pfe_tx_get_req_desc(struct sk_buff *skb, unsigned int *n_desc, unsigned int --- a/drivers/staging/fsl_ppfe/pfe_hif_lib.c +++ b/drivers/staging/fsl_ppfe/pfe_hif_lib.c @@ -34,7 +34,10 @@ unsigned int lro_mode; unsigned int page_mode; -unsigned int tx_qos; +unsigned int tx_qos = 1; +module_param(tx_qos, uint, 0444); +MODULE_PARM_DESC(tx_qos, "0: disable ,\n" + "1: enable (default), guarantee no packet drop at TMU level\n"); unsigned int pfe_pkt_size; unsigned int pfe_pkt_headroom; unsigned int emac_txq_cnt; @@ -576,7 +579,7 @@ void __hif_lib_update_credit(struct hif_ if (tx_qos) { tmu_tx_packets = be32_to_cpu(pe_dmem_read(TMU0_ID + - client->id, TMU_DM_TX_TRANS, 4)); + client->id, (TMU_DM_TX_TRANS + (queue * 4)), 4)); /* tx_packets counter overflowed */ if (tmu_tx_packets >