From 5fe8cfe356d2dbf6f9d7e213614d6be9ad0ac592 Mon Sep 17 00:00:00 2001 From: Kavi Akhila-B46177 Date: Thu, 2 Nov 2017 12:05:35 +0530 Subject: 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 diff --git a/drivers/staging/fsl_ppfe/pfe_eth.c b/drivers/staging/fsl_ppfe/pfe_eth.c index a6d1fb7..7d4493f 100644 --- 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_device *ndev) /* 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); @@ -1594,10 +1594,17 @@ static int pfe_eth_might_stop_tx(struct pfe_eth_priv_s *priv, int queuenum, 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]++; @@ -1720,8 +1727,10 @@ static void pfe_eth_flush_tx(struct pfe_eth_priv_s *priv) 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 diff --git a/drivers/staging/fsl_ppfe/pfe_hif_lib.c b/drivers/staging/fsl_ppfe/pfe_hif_lib.c index 2ec47bf..eeab4ff 100644 --- 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_client_s *client, unsigned int queue) 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 > -- cgit v0.10.2