X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fopenwrt.git;a=blobdiff_plain;f=target%2Flinux%2Flayerscape%2Fpatches-4.9%2F706-fsl_ppfe-support-layercape.patch;h=068f0219d2711b80280ca672555f150123d35f52;hp=4104272eff4da9d4d77ea0a3e88017fd02c37981;hb=1a28100e68f4863ebc68625d5c6123ef0e5de8db;hpb=3a0fa1e7b860c600256f102d07356964821e7d7e diff --git a/target/linux/layerscape/patches-4.9/706-fsl_ppfe-support-layercape.patch b/target/linux/layerscape/patches-4.9/706-fsl_ppfe-support-layercape.patch index 4104272eff..068f0219d2 100644 --- a/target/linux/layerscape/patches-4.9/706-fsl_ppfe-support-layercape.patch +++ b/target/linux/layerscape/patches-4.9/706-fsl_ppfe-support-layercape.patch @@ -1,9 +1,9 @@ -From 8b7935a883d42187716fe486c83352f24d01ddcd Mon Sep 17 00:00:00 2001 +From 8089957ac5ac5f4f8436b1052dda7840f3bff3ea Mon Sep 17 00:00:00 2001 From: Yangbo Lu -Date: Thu, 19 Oct 2017 12:48:19 +0800 -Subject: [PATCH] fsl_ppfe: support layercape +Date: Wed, 17 Jan 2018 15:14:12 +0800 +Subject: [PATCH 12/30] fsl_ppfe: support layercape -This is a integrated patch for layerscape pfe support. +This is an integrated patch for layerscape pfe support. Calvin Johnson Signed-off-by: Yangbo Lu @@ -25,15 +25,15 @@ Signed-off-by: Yangbo Lu drivers/staging/fsl_ppfe/pfe_ctrl.h | 112 + drivers/staging/fsl_ppfe/pfe_debugfs.c | 111 + drivers/staging/fsl_ppfe/pfe_debugfs.h | 25 + - drivers/staging/fsl_ppfe/pfe_eth.c | 2434 ++++++++++++++++++++ + drivers/staging/fsl_ppfe/pfe_eth.c | 2474 ++++++++++++++++++++ drivers/staging/fsl_ppfe/pfe_eth.h | 184 ++ drivers/staging/fsl_ppfe/pfe_firmware.c | 314 +++ drivers/staging/fsl_ppfe/pfe_firmware.h | 32 + drivers/staging/fsl_ppfe/pfe_hal.c | 1516 ++++++++++++ drivers/staging/fsl_ppfe/pfe_hif.c | 1072 +++++++++ drivers/staging/fsl_ppfe/pfe_hif.h | 211 ++ - drivers/staging/fsl_ppfe/pfe_hif_lib.c | 601 +++++ - drivers/staging/fsl_ppfe/pfe_hif_lib.h | 239 ++ + drivers/staging/fsl_ppfe/pfe_hif_lib.c | 637 +++++ + drivers/staging/fsl_ppfe/pfe_hif_lib.h | 240 ++ drivers/staging/fsl_ppfe/pfe_hw.c | 176 ++ drivers/staging/fsl_ppfe/pfe_hw.h | 27 + drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c | 394 ++++ @@ -42,7 +42,7 @@ Signed-off-by: Yangbo Lu drivers/staging/fsl_ppfe/pfe_perfmon.h | 38 + drivers/staging/fsl_ppfe/pfe_sysfs.c | 818 +++++++ drivers/staging/fsl_ppfe/pfe_sysfs.h | 29 + - 34 files changed, 10366 insertions(+) + 34 files changed, 10443 insertions(+) create mode 100644 drivers/staging/fsl_ppfe/Kconfig create mode 100644 drivers/staging/fsl_ppfe/Makefile create mode 100644 drivers/staging/fsl_ppfe/TODO @@ -2159,7 +2159,7 @@ Signed-off-by: Yangbo Lu +#endif /* _PFE_DEBUGFS_H_ */ --- /dev/null +++ b/drivers/staging/fsl_ppfe/pfe_eth.c -@@ -0,0 +1,2434 @@ +@@ -0,0 +1,2474 @@ +/* + * Copyright 2015-2016 Freescale Semiconductor, Inc. + * Copyright 2017 NXP @@ -2455,10 +2455,10 @@ Signed-off-by: Yangbo Lu + /* 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); @@ -2739,7 +2739,9 @@ Signed-off-by: Yangbo Lu + if (!phydev) + return -ENODEV; + -+ return phy_ethtool_ksettings_get(phydev, cmd); ++ phy_ethtool_ksettings_get(phydev, cmd); ++ ++ return 0; +} + +/* @@ -3083,7 +3085,8 @@ Signed-off-by: Yangbo Lu + struct ls1012a_mdio_platform_data *minfo) +{ + struct mii_bus *bus; -+ int rc; ++ int rc, ii; ++ struct phy_device *phydev; + + netif_info(priv, drv, priv->ndev, "%s\n", __func__); + pr_info("%s\n", __func__); @@ -3122,6 +3125,31 @@ Signed-off-by: Yangbo Lu + } + + priv->mii_bus = bus; ++ ++ /* For clause 45 we need to call get_phy_device() with it's ++ * 3rd argument as true and then register the phy device ++ * via phy_device_register() ++ */ ++ ++ if (priv->einfo->mii_config == PHY_INTERFACE_MODE_2500SGMII) { ++ for (ii = 0; ii < NUM_GEMAC_SUPPORT; ii++) { ++ phydev = get_phy_device(priv->mii_bus, ++ priv->einfo->phy_id + ii, true); ++ if (!phydev || IS_ERR(phydev)) { ++ rc = -EIO; ++ netdev_err(priv->ndev, "fail to get device\n"); ++ goto err1; ++ } ++ rc = phy_device_register(phydev); ++ if (rc) { ++ phy_device_free(phydev); ++ netdev_err(priv->ndev, ++ "phy_device_register() failed\n"); ++ goto err1; ++ } ++ } ++ } ++ + pfe_eth_mdio_reset(bus); + + return 0; @@ -3307,8 +3335,9 @@ Signed-off-by: Yangbo Lu + struct pfe_eth_priv_s *priv = pfe->eth.eth_priv[0]; + int sgmii_2500 = 0; + struct mii_bus *bus = priv->mii_bus; ++ u16 value = 0; + -+ if (priv->einfo->mii_config == PHY_INTERFACE_MODE_SGMII_2500) ++ if (priv->einfo->mii_config == PHY_INTERFACE_MODE_2500SGMII) + sgmii_2500 = 1; + + netif_info(priv, drv, ndev, "%s\n", __func__); @@ -3324,14 +3353,16 @@ Signed-off-by: Yangbo Lu + pfe_eth_mdio_write(bus, 0, 0x4, 0x4001); + pfe_eth_mdio_write(bus, 0, 0x12, 0xa120); + pfe_eth_mdio_write(bus, 0, 0x13, 0x7); ++ /* Autonegotiation need to be disabled for 2.5G SGMII mode*/ ++ value = 0x0140; ++ pfe_eth_mdio_write(bus, 0, 0x0, value); + } else { + pfe_eth_mdio_write(bus, 0, 0x14, 0xb); + pfe_eth_mdio_write(bus, 0, 0x4, 0x1a1); + pfe_eth_mdio_write(bus, 0, 0x12, 0x400); + pfe_eth_mdio_write(bus, 0, 0x13, 0x0); ++ pfe_eth_mdio_write(bus, 0, 0x0, 0x1140); + } -+ -+ pfe_eth_mdio_write(bus, 0, 0x0, 0x1140); +} + +/* @@ -3357,7 +3388,7 @@ Signed-off-by: Yangbo Lu + netif_info(priv, drv, ndev, "%s: %s\n", __func__, phy_id); + interface = priv->einfo->mii_config; + if ((interface == PHY_INTERFACE_MODE_SGMII) || -+ (interface == PHY_INTERFACE_MODE_SGMII_2500)) { ++ (interface == PHY_INTERFACE_MODE_2500SGMII)) { + /*Configure SGMII PCS */ + if (pfe->scfg) { + /*Config MDIO from serdes */ @@ -3725,10 +3756,17 @@ Signed-off-by: Yangbo Lu + 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]++; @@ -3851,8 +3889,10 @@ Signed-off-by: Yangbo Lu + + 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 @@ -7943,7 +7983,7 @@ Signed-off-by: Yangbo Lu +#endif /* _PFE_HIF_H_ */ --- /dev/null +++ b/drivers/staging/fsl_ppfe/pfe_hif_lib.c -@@ -0,0 +1,601 @@ +@@ -0,0 +1,637 @@ +/* + * Copyright 2015-2016 Freescale Semiconductor, Inc. + * Copyright 2017 NXP @@ -7980,7 +8020,10 @@ Signed-off-by: Yangbo Lu + +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; @@ -8511,6 +8554,39 @@ Signed-off-by: Yangbo Lu + } +} + ++/* __hif_lib_update_credit ++ * ++ * @param[in] client hif client context ++ * @param[in] queue queue number in match with TMU ++ */ ++void __hif_lib_update_credit(struct hif_client_s *client, unsigned int queue) ++{ ++ unsigned int tmu_tx_packets, tmp; ++ ++ if (tx_qos) { ++ tmu_tx_packets = be32_to_cpu(pe_dmem_read(TMU0_ID + ++ client->id, (TMU_DM_TX_TRANS + (queue * 4)), 4)); ++ ++ /* tx_packets counter overflowed */ ++ if (tmu_tx_packets > ++ pfe->tmu_credit.tx_packets[client->id][queue]) { ++ tmp = UINT_MAX - tmu_tx_packets + ++ pfe->tmu_credit.tx_packets[client->id][queue]; ++ ++ pfe->tmu_credit.tx_credit[client->id][queue] = ++ pfe->tmu_credit.tx_credit_max[client->id][queue] - tmp; ++ } else { ++ /* TMU tx <= pfe_eth tx, normal case or both OF since ++ * last time ++ */ ++ pfe->tmu_credit.tx_credit[client->id][queue] = ++ pfe->tmu_credit.tx_credit_max[client->id][queue] - ++ (pfe->tmu_credit.tx_packets[client->id][queue] - ++ tmu_tx_packets); ++ } ++ } ++} ++ +int pfe_hif_lib_init(struct pfe *pfe) +{ + int rc; @@ -8547,7 +8623,7 @@ Signed-off-by: Yangbo Lu +} --- /dev/null +++ b/drivers/staging/fsl_ppfe/pfe_hif_lib.h -@@ -0,0 +1,239 @@ +@@ -0,0 +1,240 @@ +/* + * Copyright 2015-2016 Freescale Semiconductor, Inc. + * Copyright 2017 NXP @@ -8735,6 +8811,7 @@ Signed-off-by: Yangbo Lu +void *hif_lib_receive_pkt(struct hif_client_s *client, int qno, int *len, int + *ofst, unsigned int *rx_ctrl, + unsigned int *desc_ctrl, void **priv_data); ++void __hif_lib_update_credit(struct hif_client_s *client, unsigned int queue); +void hif_lib_set_rx_cpu_affinity(struct hif_client_s *client, int cpu_id); +void hif_lib_set_tx_queue_nocpy(struct hif_client_s *client, int qno, int + enable);