18c2ecf20Sopenharmony_ci/* Synopsys DesignWare Core Enterprise Ethernet (XLGMAC) Driver
28c2ecf20Sopenharmony_ci *
38c2ecf20Sopenharmony_ci * Copyright (c) 2017 Synopsys, Inc. (www.synopsys.com)
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * This program is dual-licensed; you may select either version 2 of
68c2ecf20Sopenharmony_ci * the GNU General Public License ("GPL") or BSD license ("BSD").
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * This Synopsys DWC XLGMAC software driver and associated documentation
98c2ecf20Sopenharmony_ci * (hereinafter the "Software") is an unsupported proprietary work of
108c2ecf20Sopenharmony_ci * Synopsys, Inc. unless otherwise expressly agreed to in writing between
118c2ecf20Sopenharmony_ci * Synopsys and you. The Software IS NOT an item of Licensed Software or a
128c2ecf20Sopenharmony_ci * Licensed Product under any End User Software License Agreement or
138c2ecf20Sopenharmony_ci * Agreement for Licensed Products with Synopsys or any supplement thereto.
148c2ecf20Sopenharmony_ci * Synopsys is a registered trademark of Synopsys, Inc. Other names included
158c2ecf20Sopenharmony_ci * in the SOFTWARE may be the trademarks of their respective owners.
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#include <linux/kernel.h>
198c2ecf20Sopenharmony_ci#include <linux/module.h>
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#include "dwc-xlgmac.h"
228c2ecf20Sopenharmony_ci#include "dwc-xlgmac-reg.h"
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciMODULE_LICENSE("Dual BSD/GPL");
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistatic int debug = -1;
278c2ecf20Sopenharmony_cimodule_param(debug, int, 0644);
288c2ecf20Sopenharmony_ciMODULE_PARM_DESC(debug, "DWC ethernet debug level (0=none,...,16=all)");
298c2ecf20Sopenharmony_cistatic const u32 default_msg_level = (NETIF_MSG_LINK | NETIF_MSG_IFDOWN |
308c2ecf20Sopenharmony_ci				      NETIF_MSG_IFUP);
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_cistatic unsigned char dev_addr[6] = {0, 0x55, 0x7b, 0xb5, 0x7d, 0xf7};
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistatic void xlgmac_read_mac_addr(struct xlgmac_pdata *pdata)
358c2ecf20Sopenharmony_ci{
368c2ecf20Sopenharmony_ci	struct net_device *netdev = pdata->netdev;
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci	/* Currently it uses a static mac address for test */
398c2ecf20Sopenharmony_ci	memcpy(pdata->mac_addr, dev_addr, netdev->addr_len);
408c2ecf20Sopenharmony_ci}
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_cistatic void xlgmac_default_config(struct xlgmac_pdata *pdata)
438c2ecf20Sopenharmony_ci{
448c2ecf20Sopenharmony_ci	pdata->tx_osp_mode = DMA_OSP_ENABLE;
458c2ecf20Sopenharmony_ci	pdata->tx_sf_mode = MTL_TSF_ENABLE;
468c2ecf20Sopenharmony_ci	pdata->rx_sf_mode = MTL_RSF_DISABLE;
478c2ecf20Sopenharmony_ci	pdata->pblx8 = DMA_PBL_X8_ENABLE;
488c2ecf20Sopenharmony_ci	pdata->tx_pbl = DMA_PBL_32;
498c2ecf20Sopenharmony_ci	pdata->rx_pbl = DMA_PBL_32;
508c2ecf20Sopenharmony_ci	pdata->tx_threshold = MTL_TX_THRESHOLD_128;
518c2ecf20Sopenharmony_ci	pdata->rx_threshold = MTL_RX_THRESHOLD_128;
528c2ecf20Sopenharmony_ci	pdata->tx_pause = 1;
538c2ecf20Sopenharmony_ci	pdata->rx_pause = 1;
548c2ecf20Sopenharmony_ci	pdata->phy_speed = SPEED_25000;
558c2ecf20Sopenharmony_ci	pdata->sysclk_rate = XLGMAC_SYSCLOCK;
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	strlcpy(pdata->drv_name, XLGMAC_DRV_NAME, sizeof(pdata->drv_name));
588c2ecf20Sopenharmony_ci	strlcpy(pdata->drv_ver, XLGMAC_DRV_VERSION, sizeof(pdata->drv_ver));
598c2ecf20Sopenharmony_ci}
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistatic void xlgmac_init_all_ops(struct xlgmac_pdata *pdata)
628c2ecf20Sopenharmony_ci{
638c2ecf20Sopenharmony_ci	xlgmac_init_desc_ops(&pdata->desc_ops);
648c2ecf20Sopenharmony_ci	xlgmac_init_hw_ops(&pdata->hw_ops);
658c2ecf20Sopenharmony_ci}
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_cistatic int xlgmac_init(struct xlgmac_pdata *pdata)
688c2ecf20Sopenharmony_ci{
698c2ecf20Sopenharmony_ci	struct xlgmac_hw_ops *hw_ops = &pdata->hw_ops;
708c2ecf20Sopenharmony_ci	struct net_device *netdev = pdata->netdev;
718c2ecf20Sopenharmony_ci	unsigned int i;
728c2ecf20Sopenharmony_ci	int ret;
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	/* Set default configuration data */
758c2ecf20Sopenharmony_ci	xlgmac_default_config(pdata);
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	/* Set irq, base_addr, MAC address, */
788c2ecf20Sopenharmony_ci	netdev->irq = pdata->dev_irq;
798c2ecf20Sopenharmony_ci	netdev->base_addr = (unsigned long)pdata->mac_regs;
808c2ecf20Sopenharmony_ci	xlgmac_read_mac_addr(pdata);
818c2ecf20Sopenharmony_ci	memcpy(netdev->dev_addr, pdata->mac_addr, netdev->addr_len);
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	/* Set all the function pointers */
848c2ecf20Sopenharmony_ci	xlgmac_init_all_ops(pdata);
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	/* Issue software reset to device */
878c2ecf20Sopenharmony_ci	hw_ops->exit(pdata);
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	/* Populate the hardware features */
908c2ecf20Sopenharmony_ci	xlgmac_get_all_hw_features(pdata);
918c2ecf20Sopenharmony_ci	xlgmac_print_all_hw_features(pdata);
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	/* TODO: Set the PHY mode to XLGMII */
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	/* Set the DMA mask */
968c2ecf20Sopenharmony_ci	ret = dma_set_mask_and_coherent(pdata->dev,
978c2ecf20Sopenharmony_ci					DMA_BIT_MASK(pdata->hw_feat.dma_width));
988c2ecf20Sopenharmony_ci	if (ret) {
998c2ecf20Sopenharmony_ci		dev_err(pdata->dev, "dma_set_mask_and_coherent failed\n");
1008c2ecf20Sopenharmony_ci		return ret;
1018c2ecf20Sopenharmony_ci	}
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci	/* Channel and ring params initializtion
1048c2ecf20Sopenharmony_ci	 *  pdata->channel_count;
1058c2ecf20Sopenharmony_ci	 *  pdata->tx_ring_count;
1068c2ecf20Sopenharmony_ci	 *  pdata->rx_ring_count;
1078c2ecf20Sopenharmony_ci	 *  pdata->tx_desc_count;
1088c2ecf20Sopenharmony_ci	 *  pdata->rx_desc_count;
1098c2ecf20Sopenharmony_ci	 */
1108c2ecf20Sopenharmony_ci	BUILD_BUG_ON_NOT_POWER_OF_2(XLGMAC_TX_DESC_CNT);
1118c2ecf20Sopenharmony_ci	pdata->tx_desc_count = XLGMAC_TX_DESC_CNT;
1128c2ecf20Sopenharmony_ci	if (pdata->tx_desc_count & (pdata->tx_desc_count - 1)) {
1138c2ecf20Sopenharmony_ci		dev_err(pdata->dev, "tx descriptor count (%d) is not valid\n",
1148c2ecf20Sopenharmony_ci			pdata->tx_desc_count);
1158c2ecf20Sopenharmony_ci		ret = -EINVAL;
1168c2ecf20Sopenharmony_ci		return ret;
1178c2ecf20Sopenharmony_ci	}
1188c2ecf20Sopenharmony_ci	BUILD_BUG_ON_NOT_POWER_OF_2(XLGMAC_RX_DESC_CNT);
1198c2ecf20Sopenharmony_ci	pdata->rx_desc_count = XLGMAC_RX_DESC_CNT;
1208c2ecf20Sopenharmony_ci	if (pdata->rx_desc_count & (pdata->rx_desc_count - 1)) {
1218c2ecf20Sopenharmony_ci		dev_err(pdata->dev, "rx descriptor count (%d) is not valid\n",
1228c2ecf20Sopenharmony_ci			pdata->rx_desc_count);
1238c2ecf20Sopenharmony_ci		ret = -EINVAL;
1248c2ecf20Sopenharmony_ci		return ret;
1258c2ecf20Sopenharmony_ci	}
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	pdata->tx_ring_count = min_t(unsigned int, num_online_cpus(),
1288c2ecf20Sopenharmony_ci				     pdata->hw_feat.tx_ch_cnt);
1298c2ecf20Sopenharmony_ci	pdata->tx_ring_count = min_t(unsigned int, pdata->tx_ring_count,
1308c2ecf20Sopenharmony_ci				     pdata->hw_feat.tx_q_cnt);
1318c2ecf20Sopenharmony_ci	pdata->tx_q_count = pdata->tx_ring_count;
1328c2ecf20Sopenharmony_ci	ret = netif_set_real_num_tx_queues(netdev, pdata->tx_q_count);
1338c2ecf20Sopenharmony_ci	if (ret) {
1348c2ecf20Sopenharmony_ci		dev_err(pdata->dev, "error setting real tx queue count\n");
1358c2ecf20Sopenharmony_ci		return ret;
1368c2ecf20Sopenharmony_ci	}
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci	pdata->rx_ring_count = min_t(unsigned int,
1398c2ecf20Sopenharmony_ci				     netif_get_num_default_rss_queues(),
1408c2ecf20Sopenharmony_ci				     pdata->hw_feat.rx_ch_cnt);
1418c2ecf20Sopenharmony_ci	pdata->rx_ring_count = min_t(unsigned int, pdata->rx_ring_count,
1428c2ecf20Sopenharmony_ci				     pdata->hw_feat.rx_q_cnt);
1438c2ecf20Sopenharmony_ci	pdata->rx_q_count = pdata->rx_ring_count;
1448c2ecf20Sopenharmony_ci	ret = netif_set_real_num_rx_queues(netdev, pdata->rx_q_count);
1458c2ecf20Sopenharmony_ci	if (ret) {
1468c2ecf20Sopenharmony_ci		dev_err(pdata->dev, "error setting real rx queue count\n");
1478c2ecf20Sopenharmony_ci		return ret;
1488c2ecf20Sopenharmony_ci	}
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	pdata->channel_count =
1518c2ecf20Sopenharmony_ci		max_t(unsigned int, pdata->tx_ring_count, pdata->rx_ring_count);
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci	/* Initialize RSS hash key and lookup table */
1548c2ecf20Sopenharmony_ci	netdev_rss_key_fill(pdata->rss_key, sizeof(pdata->rss_key));
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci	for (i = 0; i < XLGMAC_RSS_MAX_TABLE_SIZE; i++)
1578c2ecf20Sopenharmony_ci		pdata->rss_table[i] = XLGMAC_SET_REG_BITS(
1588c2ecf20Sopenharmony_ci					pdata->rss_table[i],
1598c2ecf20Sopenharmony_ci					MAC_RSSDR_DMCH_POS,
1608c2ecf20Sopenharmony_ci					MAC_RSSDR_DMCH_LEN,
1618c2ecf20Sopenharmony_ci					i % pdata->rx_ring_count);
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci	pdata->rss_options = XLGMAC_SET_REG_BITS(
1648c2ecf20Sopenharmony_ci				pdata->rss_options,
1658c2ecf20Sopenharmony_ci				MAC_RSSCR_IP2TE_POS,
1668c2ecf20Sopenharmony_ci				MAC_RSSCR_IP2TE_LEN, 1);
1678c2ecf20Sopenharmony_ci	pdata->rss_options = XLGMAC_SET_REG_BITS(
1688c2ecf20Sopenharmony_ci				pdata->rss_options,
1698c2ecf20Sopenharmony_ci				MAC_RSSCR_TCP4TE_POS,
1708c2ecf20Sopenharmony_ci				MAC_RSSCR_TCP4TE_LEN, 1);
1718c2ecf20Sopenharmony_ci	pdata->rss_options = XLGMAC_SET_REG_BITS(
1728c2ecf20Sopenharmony_ci				pdata->rss_options,
1738c2ecf20Sopenharmony_ci				MAC_RSSCR_UDP4TE_POS,
1748c2ecf20Sopenharmony_ci				MAC_RSSCR_UDP4TE_LEN, 1);
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci	/* Set device operations */
1778c2ecf20Sopenharmony_ci	netdev->netdev_ops = xlgmac_get_netdev_ops();
1788c2ecf20Sopenharmony_ci	netdev->ethtool_ops = xlgmac_get_ethtool_ops();
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci	/* Set device features */
1818c2ecf20Sopenharmony_ci	if (pdata->hw_feat.tso) {
1828c2ecf20Sopenharmony_ci		netdev->hw_features = NETIF_F_TSO;
1838c2ecf20Sopenharmony_ci		netdev->hw_features |= NETIF_F_TSO6;
1848c2ecf20Sopenharmony_ci		netdev->hw_features |= NETIF_F_SG;
1858c2ecf20Sopenharmony_ci		netdev->hw_features |= NETIF_F_IP_CSUM;
1868c2ecf20Sopenharmony_ci		netdev->hw_features |= NETIF_F_IPV6_CSUM;
1878c2ecf20Sopenharmony_ci	} else if (pdata->hw_feat.tx_coe) {
1888c2ecf20Sopenharmony_ci		netdev->hw_features = NETIF_F_IP_CSUM;
1898c2ecf20Sopenharmony_ci		netdev->hw_features |= NETIF_F_IPV6_CSUM;
1908c2ecf20Sopenharmony_ci	}
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci	if (pdata->hw_feat.rx_coe) {
1938c2ecf20Sopenharmony_ci		netdev->hw_features |= NETIF_F_RXCSUM;
1948c2ecf20Sopenharmony_ci		netdev->hw_features |= NETIF_F_GRO;
1958c2ecf20Sopenharmony_ci	}
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci	if (pdata->hw_feat.rss)
1988c2ecf20Sopenharmony_ci		netdev->hw_features |= NETIF_F_RXHASH;
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci	netdev->vlan_features |= netdev->hw_features;
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci	netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX;
2038c2ecf20Sopenharmony_ci	if (pdata->hw_feat.sa_vlan_ins)
2048c2ecf20Sopenharmony_ci		netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_TX;
2058c2ecf20Sopenharmony_ci	if (pdata->hw_feat.vlhash)
2068c2ecf20Sopenharmony_ci		netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci	netdev->features |= netdev->hw_features;
2098c2ecf20Sopenharmony_ci	pdata->netdev_features = netdev->features;
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci	netdev->priv_flags |= IFF_UNICAST_FLT;
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci	/* Use default watchdog timeout */
2148c2ecf20Sopenharmony_ci	netdev->watchdog_timeo = 0;
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci	/* Tx coalesce parameters initialization */
2178c2ecf20Sopenharmony_ci	pdata->tx_usecs = XLGMAC_INIT_DMA_TX_USECS;
2188c2ecf20Sopenharmony_ci	pdata->tx_frames = XLGMAC_INIT_DMA_TX_FRAMES;
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci	/* Rx coalesce parameters initialization */
2218c2ecf20Sopenharmony_ci	pdata->rx_riwt = hw_ops->usec_to_riwt(pdata, XLGMAC_INIT_DMA_RX_USECS);
2228c2ecf20Sopenharmony_ci	pdata->rx_usecs = XLGMAC_INIT_DMA_RX_USECS;
2238c2ecf20Sopenharmony_ci	pdata->rx_frames = XLGMAC_INIT_DMA_RX_FRAMES;
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci	return 0;
2268c2ecf20Sopenharmony_ci}
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ciint xlgmac_drv_probe(struct device *dev, struct xlgmac_resources *res)
2298c2ecf20Sopenharmony_ci{
2308c2ecf20Sopenharmony_ci	struct xlgmac_pdata *pdata;
2318c2ecf20Sopenharmony_ci	struct net_device *netdev;
2328c2ecf20Sopenharmony_ci	int ret;
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci	netdev = alloc_etherdev_mq(sizeof(struct xlgmac_pdata),
2358c2ecf20Sopenharmony_ci				   XLGMAC_MAX_DMA_CHANNELS);
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci	if (!netdev) {
2388c2ecf20Sopenharmony_ci		dev_err(dev, "alloc_etherdev failed\n");
2398c2ecf20Sopenharmony_ci		return -ENOMEM;
2408c2ecf20Sopenharmony_ci	}
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci	SET_NETDEV_DEV(netdev, dev);
2438c2ecf20Sopenharmony_ci	dev_set_drvdata(dev, netdev);
2448c2ecf20Sopenharmony_ci	pdata = netdev_priv(netdev);
2458c2ecf20Sopenharmony_ci	pdata->dev = dev;
2468c2ecf20Sopenharmony_ci	pdata->netdev = netdev;
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci	pdata->dev_irq = res->irq;
2498c2ecf20Sopenharmony_ci	pdata->mac_regs = res->addr;
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci	mutex_init(&pdata->rss_mutex);
2528c2ecf20Sopenharmony_ci	pdata->msg_enable = netif_msg_init(debug, default_msg_level);
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci	ret = xlgmac_init(pdata);
2558c2ecf20Sopenharmony_ci	if (ret) {
2568c2ecf20Sopenharmony_ci		dev_err(dev, "xlgmac init failed\n");
2578c2ecf20Sopenharmony_ci		goto err_free_netdev;
2588c2ecf20Sopenharmony_ci	}
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci	ret = register_netdev(netdev);
2618c2ecf20Sopenharmony_ci	if (ret) {
2628c2ecf20Sopenharmony_ci		dev_err(dev, "net device registration failed\n");
2638c2ecf20Sopenharmony_ci		goto err_free_netdev;
2648c2ecf20Sopenharmony_ci	}
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci	return 0;
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_cierr_free_netdev:
2698c2ecf20Sopenharmony_ci	free_netdev(netdev);
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci	return ret;
2728c2ecf20Sopenharmony_ci}
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ciint xlgmac_drv_remove(struct device *dev)
2758c2ecf20Sopenharmony_ci{
2768c2ecf20Sopenharmony_ci	struct net_device *netdev = dev_get_drvdata(dev);
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci	unregister_netdev(netdev);
2798c2ecf20Sopenharmony_ci	free_netdev(netdev);
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci	return 0;
2828c2ecf20Sopenharmony_ci}
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_civoid xlgmac_dump_tx_desc(struct xlgmac_pdata *pdata,
2858c2ecf20Sopenharmony_ci			 struct xlgmac_ring *ring,
2868c2ecf20Sopenharmony_ci			 unsigned int idx,
2878c2ecf20Sopenharmony_ci			 unsigned int count,
2888c2ecf20Sopenharmony_ci			 unsigned int flag)
2898c2ecf20Sopenharmony_ci{
2908c2ecf20Sopenharmony_ci	struct xlgmac_desc_data *desc_data;
2918c2ecf20Sopenharmony_ci	struct xlgmac_dma_desc *dma_desc;
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci	while (count--) {
2948c2ecf20Sopenharmony_ci		desc_data = XLGMAC_GET_DESC_DATA(ring, idx);
2958c2ecf20Sopenharmony_ci		dma_desc = desc_data->dma_desc;
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci		netdev_dbg(pdata->netdev, "TX: dma_desc=%p, dma_desc_addr=%pad\n",
2988c2ecf20Sopenharmony_ci			   desc_data->dma_desc, &desc_data->dma_desc_addr);
2998c2ecf20Sopenharmony_ci		netdev_dbg(pdata->netdev,
3008c2ecf20Sopenharmony_ci			   "TX_NORMAL_DESC[%d %s] = %08x:%08x:%08x:%08x\n", idx,
3018c2ecf20Sopenharmony_ci			   (flag == 1) ? "QUEUED FOR TX" : "TX BY DEVICE",
3028c2ecf20Sopenharmony_ci			   le32_to_cpu(dma_desc->desc0),
3038c2ecf20Sopenharmony_ci			   le32_to_cpu(dma_desc->desc1),
3048c2ecf20Sopenharmony_ci			   le32_to_cpu(dma_desc->desc2),
3058c2ecf20Sopenharmony_ci			   le32_to_cpu(dma_desc->desc3));
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci		idx++;
3088c2ecf20Sopenharmony_ci	}
3098c2ecf20Sopenharmony_ci}
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_civoid xlgmac_dump_rx_desc(struct xlgmac_pdata *pdata,
3128c2ecf20Sopenharmony_ci			 struct xlgmac_ring *ring,
3138c2ecf20Sopenharmony_ci			 unsigned int idx)
3148c2ecf20Sopenharmony_ci{
3158c2ecf20Sopenharmony_ci	struct xlgmac_desc_data *desc_data;
3168c2ecf20Sopenharmony_ci	struct xlgmac_dma_desc *dma_desc;
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci	desc_data = XLGMAC_GET_DESC_DATA(ring, idx);
3198c2ecf20Sopenharmony_ci	dma_desc = desc_data->dma_desc;
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci	netdev_dbg(pdata->netdev, "RX: dma_desc=%p, dma_desc_addr=%pad\n",
3228c2ecf20Sopenharmony_ci		   desc_data->dma_desc, &desc_data->dma_desc_addr);
3238c2ecf20Sopenharmony_ci	netdev_dbg(pdata->netdev,
3248c2ecf20Sopenharmony_ci		   "RX_NORMAL_DESC[%d RX BY DEVICE] = %08x:%08x:%08x:%08x\n",
3258c2ecf20Sopenharmony_ci		   idx,
3268c2ecf20Sopenharmony_ci		   le32_to_cpu(dma_desc->desc0),
3278c2ecf20Sopenharmony_ci		   le32_to_cpu(dma_desc->desc1),
3288c2ecf20Sopenharmony_ci		   le32_to_cpu(dma_desc->desc2),
3298c2ecf20Sopenharmony_ci		   le32_to_cpu(dma_desc->desc3));
3308c2ecf20Sopenharmony_ci}
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_civoid xlgmac_print_pkt(struct net_device *netdev,
3338c2ecf20Sopenharmony_ci		      struct sk_buff *skb, bool tx_rx)
3348c2ecf20Sopenharmony_ci{
3358c2ecf20Sopenharmony_ci	struct ethhdr *eth = (struct ethhdr *)skb->data;
3368c2ecf20Sopenharmony_ci	unsigned char buffer[128];
3378c2ecf20Sopenharmony_ci	unsigned int i;
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci	netdev_dbg(netdev, "\n************** SKB dump ****************\n");
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci	netdev_dbg(netdev, "%s packet of %d bytes\n",
3428c2ecf20Sopenharmony_ci		   (tx_rx ? "TX" : "RX"), skb->len);
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci	netdev_dbg(netdev, "Dst MAC addr: %pM\n", eth->h_dest);
3458c2ecf20Sopenharmony_ci	netdev_dbg(netdev, "Src MAC addr: %pM\n", eth->h_source);
3468c2ecf20Sopenharmony_ci	netdev_dbg(netdev, "Protocol: %#06hx\n", ntohs(eth->h_proto));
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci	for (i = 0; i < skb->len; i += 32) {
3498c2ecf20Sopenharmony_ci		unsigned int len = min(skb->len - i, 32U);
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci		hex_dump_to_buffer(&skb->data[i], len, 32, 1,
3528c2ecf20Sopenharmony_ci				   buffer, sizeof(buffer), false);
3538c2ecf20Sopenharmony_ci		netdev_dbg(netdev, "  %#06x: %s\n", i, buffer);
3548c2ecf20Sopenharmony_ci	}
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ci	netdev_dbg(netdev, "\n************** SKB dump ****************\n");
3578c2ecf20Sopenharmony_ci}
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_civoid xlgmac_get_all_hw_features(struct xlgmac_pdata *pdata)
3608c2ecf20Sopenharmony_ci{
3618c2ecf20Sopenharmony_ci	struct xlgmac_hw_features *hw_feat = &pdata->hw_feat;
3628c2ecf20Sopenharmony_ci	unsigned int mac_hfr0, mac_hfr1, mac_hfr2;
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci	mac_hfr0 = readl(pdata->mac_regs + MAC_HWF0R);
3658c2ecf20Sopenharmony_ci	mac_hfr1 = readl(pdata->mac_regs + MAC_HWF1R);
3668c2ecf20Sopenharmony_ci	mac_hfr2 = readl(pdata->mac_regs + MAC_HWF2R);
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci	memset(hw_feat, 0, sizeof(*hw_feat));
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_ci	hw_feat->version = readl(pdata->mac_regs + MAC_VR);
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci	/* Hardware feature register 0 */
3738c2ecf20Sopenharmony_ci	hw_feat->phyifsel    = XLGMAC_GET_REG_BITS(mac_hfr0,
3748c2ecf20Sopenharmony_ci						MAC_HWF0R_PHYIFSEL_POS,
3758c2ecf20Sopenharmony_ci						MAC_HWF0R_PHYIFSEL_LEN);
3768c2ecf20Sopenharmony_ci	hw_feat->vlhash      = XLGMAC_GET_REG_BITS(mac_hfr0,
3778c2ecf20Sopenharmony_ci						MAC_HWF0R_VLHASH_POS,
3788c2ecf20Sopenharmony_ci						MAC_HWF0R_VLHASH_LEN);
3798c2ecf20Sopenharmony_ci	hw_feat->sma         = XLGMAC_GET_REG_BITS(mac_hfr0,
3808c2ecf20Sopenharmony_ci						MAC_HWF0R_SMASEL_POS,
3818c2ecf20Sopenharmony_ci						MAC_HWF0R_SMASEL_LEN);
3828c2ecf20Sopenharmony_ci	hw_feat->rwk         = XLGMAC_GET_REG_BITS(mac_hfr0,
3838c2ecf20Sopenharmony_ci						MAC_HWF0R_RWKSEL_POS,
3848c2ecf20Sopenharmony_ci						MAC_HWF0R_RWKSEL_LEN);
3858c2ecf20Sopenharmony_ci	hw_feat->mgk         = XLGMAC_GET_REG_BITS(mac_hfr0,
3868c2ecf20Sopenharmony_ci						MAC_HWF0R_MGKSEL_POS,
3878c2ecf20Sopenharmony_ci						MAC_HWF0R_MGKSEL_LEN);
3888c2ecf20Sopenharmony_ci	hw_feat->mmc         = XLGMAC_GET_REG_BITS(mac_hfr0,
3898c2ecf20Sopenharmony_ci						MAC_HWF0R_MMCSEL_POS,
3908c2ecf20Sopenharmony_ci						MAC_HWF0R_MMCSEL_LEN);
3918c2ecf20Sopenharmony_ci	hw_feat->aoe         = XLGMAC_GET_REG_BITS(mac_hfr0,
3928c2ecf20Sopenharmony_ci						MAC_HWF0R_ARPOFFSEL_POS,
3938c2ecf20Sopenharmony_ci						MAC_HWF0R_ARPOFFSEL_LEN);
3948c2ecf20Sopenharmony_ci	hw_feat->ts          = XLGMAC_GET_REG_BITS(mac_hfr0,
3958c2ecf20Sopenharmony_ci						MAC_HWF0R_TSSEL_POS,
3968c2ecf20Sopenharmony_ci						MAC_HWF0R_TSSEL_LEN);
3978c2ecf20Sopenharmony_ci	hw_feat->eee         = XLGMAC_GET_REG_BITS(mac_hfr0,
3988c2ecf20Sopenharmony_ci						MAC_HWF0R_EEESEL_POS,
3998c2ecf20Sopenharmony_ci						MAC_HWF0R_EEESEL_LEN);
4008c2ecf20Sopenharmony_ci	hw_feat->tx_coe      = XLGMAC_GET_REG_BITS(mac_hfr0,
4018c2ecf20Sopenharmony_ci						MAC_HWF0R_TXCOESEL_POS,
4028c2ecf20Sopenharmony_ci						MAC_HWF0R_TXCOESEL_LEN);
4038c2ecf20Sopenharmony_ci	hw_feat->rx_coe      = XLGMAC_GET_REG_BITS(mac_hfr0,
4048c2ecf20Sopenharmony_ci						MAC_HWF0R_RXCOESEL_POS,
4058c2ecf20Sopenharmony_ci						MAC_HWF0R_RXCOESEL_LEN);
4068c2ecf20Sopenharmony_ci	hw_feat->addn_mac    = XLGMAC_GET_REG_BITS(mac_hfr0,
4078c2ecf20Sopenharmony_ci						MAC_HWF0R_ADDMACADRSEL_POS,
4088c2ecf20Sopenharmony_ci						MAC_HWF0R_ADDMACADRSEL_LEN);
4098c2ecf20Sopenharmony_ci	hw_feat->ts_src      = XLGMAC_GET_REG_BITS(mac_hfr0,
4108c2ecf20Sopenharmony_ci						MAC_HWF0R_TSSTSSEL_POS,
4118c2ecf20Sopenharmony_ci						MAC_HWF0R_TSSTSSEL_LEN);
4128c2ecf20Sopenharmony_ci	hw_feat->sa_vlan_ins = XLGMAC_GET_REG_BITS(mac_hfr0,
4138c2ecf20Sopenharmony_ci						MAC_HWF0R_SAVLANINS_POS,
4148c2ecf20Sopenharmony_ci						MAC_HWF0R_SAVLANINS_LEN);
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_ci	/* Hardware feature register 1 */
4178c2ecf20Sopenharmony_ci	hw_feat->rx_fifo_size  = XLGMAC_GET_REG_BITS(mac_hfr1,
4188c2ecf20Sopenharmony_ci						MAC_HWF1R_RXFIFOSIZE_POS,
4198c2ecf20Sopenharmony_ci						MAC_HWF1R_RXFIFOSIZE_LEN);
4208c2ecf20Sopenharmony_ci	hw_feat->tx_fifo_size  = XLGMAC_GET_REG_BITS(mac_hfr1,
4218c2ecf20Sopenharmony_ci						MAC_HWF1R_TXFIFOSIZE_POS,
4228c2ecf20Sopenharmony_ci						MAC_HWF1R_TXFIFOSIZE_LEN);
4238c2ecf20Sopenharmony_ci	hw_feat->adv_ts_hi     = XLGMAC_GET_REG_BITS(mac_hfr1,
4248c2ecf20Sopenharmony_ci						MAC_HWF1R_ADVTHWORD_POS,
4258c2ecf20Sopenharmony_ci						MAC_HWF1R_ADVTHWORD_LEN);
4268c2ecf20Sopenharmony_ci	hw_feat->dma_width     = XLGMAC_GET_REG_BITS(mac_hfr1,
4278c2ecf20Sopenharmony_ci						MAC_HWF1R_ADDR64_POS,
4288c2ecf20Sopenharmony_ci						MAC_HWF1R_ADDR64_LEN);
4298c2ecf20Sopenharmony_ci	hw_feat->dcb           = XLGMAC_GET_REG_BITS(mac_hfr1,
4308c2ecf20Sopenharmony_ci						MAC_HWF1R_DCBEN_POS,
4318c2ecf20Sopenharmony_ci						MAC_HWF1R_DCBEN_LEN);
4328c2ecf20Sopenharmony_ci	hw_feat->sph           = XLGMAC_GET_REG_BITS(mac_hfr1,
4338c2ecf20Sopenharmony_ci						MAC_HWF1R_SPHEN_POS,
4348c2ecf20Sopenharmony_ci						MAC_HWF1R_SPHEN_LEN);
4358c2ecf20Sopenharmony_ci	hw_feat->tso           = XLGMAC_GET_REG_BITS(mac_hfr1,
4368c2ecf20Sopenharmony_ci						MAC_HWF1R_TSOEN_POS,
4378c2ecf20Sopenharmony_ci						MAC_HWF1R_TSOEN_LEN);
4388c2ecf20Sopenharmony_ci	hw_feat->dma_debug     = XLGMAC_GET_REG_BITS(mac_hfr1,
4398c2ecf20Sopenharmony_ci						MAC_HWF1R_DBGMEMA_POS,
4408c2ecf20Sopenharmony_ci						MAC_HWF1R_DBGMEMA_LEN);
4418c2ecf20Sopenharmony_ci	hw_feat->rss           = XLGMAC_GET_REG_BITS(mac_hfr1,
4428c2ecf20Sopenharmony_ci						MAC_HWF1R_RSSEN_POS,
4438c2ecf20Sopenharmony_ci						MAC_HWF1R_RSSEN_LEN);
4448c2ecf20Sopenharmony_ci	hw_feat->tc_cnt	       = XLGMAC_GET_REG_BITS(mac_hfr1,
4458c2ecf20Sopenharmony_ci						MAC_HWF1R_NUMTC_POS,
4468c2ecf20Sopenharmony_ci						MAC_HWF1R_NUMTC_LEN);
4478c2ecf20Sopenharmony_ci	hw_feat->hash_table_size = XLGMAC_GET_REG_BITS(mac_hfr1,
4488c2ecf20Sopenharmony_ci						MAC_HWF1R_HASHTBLSZ_POS,
4498c2ecf20Sopenharmony_ci						MAC_HWF1R_HASHTBLSZ_LEN);
4508c2ecf20Sopenharmony_ci	hw_feat->l3l4_filter_num = XLGMAC_GET_REG_BITS(mac_hfr1,
4518c2ecf20Sopenharmony_ci						MAC_HWF1R_L3L4FNUM_POS,
4528c2ecf20Sopenharmony_ci						MAC_HWF1R_L3L4FNUM_LEN);
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci	/* Hardware feature register 2 */
4558c2ecf20Sopenharmony_ci	hw_feat->rx_q_cnt     = XLGMAC_GET_REG_BITS(mac_hfr2,
4568c2ecf20Sopenharmony_ci						MAC_HWF2R_RXQCNT_POS,
4578c2ecf20Sopenharmony_ci						MAC_HWF2R_RXQCNT_LEN);
4588c2ecf20Sopenharmony_ci	hw_feat->tx_q_cnt     = XLGMAC_GET_REG_BITS(mac_hfr2,
4598c2ecf20Sopenharmony_ci						MAC_HWF2R_TXQCNT_POS,
4608c2ecf20Sopenharmony_ci						MAC_HWF2R_TXQCNT_LEN);
4618c2ecf20Sopenharmony_ci	hw_feat->rx_ch_cnt    = XLGMAC_GET_REG_BITS(mac_hfr2,
4628c2ecf20Sopenharmony_ci						MAC_HWF2R_RXCHCNT_POS,
4638c2ecf20Sopenharmony_ci						MAC_HWF2R_RXCHCNT_LEN);
4648c2ecf20Sopenharmony_ci	hw_feat->tx_ch_cnt    = XLGMAC_GET_REG_BITS(mac_hfr2,
4658c2ecf20Sopenharmony_ci						MAC_HWF2R_TXCHCNT_POS,
4668c2ecf20Sopenharmony_ci						MAC_HWF2R_TXCHCNT_LEN);
4678c2ecf20Sopenharmony_ci	hw_feat->pps_out_num  = XLGMAC_GET_REG_BITS(mac_hfr2,
4688c2ecf20Sopenharmony_ci						MAC_HWF2R_PPSOUTNUM_POS,
4698c2ecf20Sopenharmony_ci						MAC_HWF2R_PPSOUTNUM_LEN);
4708c2ecf20Sopenharmony_ci	hw_feat->aux_snap_num = XLGMAC_GET_REG_BITS(mac_hfr2,
4718c2ecf20Sopenharmony_ci						MAC_HWF2R_AUXSNAPNUM_POS,
4728c2ecf20Sopenharmony_ci						MAC_HWF2R_AUXSNAPNUM_LEN);
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_ci	/* Translate the Hash Table size into actual number */
4758c2ecf20Sopenharmony_ci	switch (hw_feat->hash_table_size) {
4768c2ecf20Sopenharmony_ci	case 0:
4778c2ecf20Sopenharmony_ci		break;
4788c2ecf20Sopenharmony_ci	case 1:
4798c2ecf20Sopenharmony_ci		hw_feat->hash_table_size = 64;
4808c2ecf20Sopenharmony_ci		break;
4818c2ecf20Sopenharmony_ci	case 2:
4828c2ecf20Sopenharmony_ci		hw_feat->hash_table_size = 128;
4838c2ecf20Sopenharmony_ci		break;
4848c2ecf20Sopenharmony_ci	case 3:
4858c2ecf20Sopenharmony_ci		hw_feat->hash_table_size = 256;
4868c2ecf20Sopenharmony_ci		break;
4878c2ecf20Sopenharmony_ci	}
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_ci	/* Translate the address width setting into actual number */
4908c2ecf20Sopenharmony_ci	switch (hw_feat->dma_width) {
4918c2ecf20Sopenharmony_ci	case 0:
4928c2ecf20Sopenharmony_ci		hw_feat->dma_width = 32;
4938c2ecf20Sopenharmony_ci		break;
4948c2ecf20Sopenharmony_ci	case 1:
4958c2ecf20Sopenharmony_ci		hw_feat->dma_width = 40;
4968c2ecf20Sopenharmony_ci		break;
4978c2ecf20Sopenharmony_ci	case 2:
4988c2ecf20Sopenharmony_ci		hw_feat->dma_width = 48;
4998c2ecf20Sopenharmony_ci		break;
5008c2ecf20Sopenharmony_ci	default:
5018c2ecf20Sopenharmony_ci		hw_feat->dma_width = 32;
5028c2ecf20Sopenharmony_ci	}
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_ci	/* The Queue, Channel and TC counts are zero based so increment them
5058c2ecf20Sopenharmony_ci	 * to get the actual number
5068c2ecf20Sopenharmony_ci	 */
5078c2ecf20Sopenharmony_ci	hw_feat->rx_q_cnt++;
5088c2ecf20Sopenharmony_ci	hw_feat->tx_q_cnt++;
5098c2ecf20Sopenharmony_ci	hw_feat->rx_ch_cnt++;
5108c2ecf20Sopenharmony_ci	hw_feat->tx_ch_cnt++;
5118c2ecf20Sopenharmony_ci	hw_feat->tc_cnt++;
5128c2ecf20Sopenharmony_ci}
5138c2ecf20Sopenharmony_ci
5148c2ecf20Sopenharmony_civoid xlgmac_print_all_hw_features(struct xlgmac_pdata *pdata)
5158c2ecf20Sopenharmony_ci{
5168c2ecf20Sopenharmony_ci	char __maybe_unused *str = NULL;
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_ci	XLGMAC_PR("\n");
5198c2ecf20Sopenharmony_ci	XLGMAC_PR("=====================================================\n");
5208c2ecf20Sopenharmony_ci	XLGMAC_PR("\n");
5218c2ecf20Sopenharmony_ci	XLGMAC_PR("HW support following features\n");
5228c2ecf20Sopenharmony_ci	XLGMAC_PR("\n");
5238c2ecf20Sopenharmony_ci	/* HW Feature Register0 */
5248c2ecf20Sopenharmony_ci	XLGMAC_PR("VLAN Hash Filter Selected                   : %s\n",
5258c2ecf20Sopenharmony_ci		  pdata->hw_feat.vlhash ? "YES" : "NO");
5268c2ecf20Sopenharmony_ci	XLGMAC_PR("SMA (MDIO) Interface                        : %s\n",
5278c2ecf20Sopenharmony_ci		  pdata->hw_feat.sma ? "YES" : "NO");
5288c2ecf20Sopenharmony_ci	XLGMAC_PR("PMT Remote Wake-up Packet Enable            : %s\n",
5298c2ecf20Sopenharmony_ci		  pdata->hw_feat.rwk ? "YES" : "NO");
5308c2ecf20Sopenharmony_ci	XLGMAC_PR("PMT Magic Packet Enable                     : %s\n",
5318c2ecf20Sopenharmony_ci		  pdata->hw_feat.mgk ? "YES" : "NO");
5328c2ecf20Sopenharmony_ci	XLGMAC_PR("RMON/MMC Module Enable                      : %s\n",
5338c2ecf20Sopenharmony_ci		  pdata->hw_feat.mmc ? "YES" : "NO");
5348c2ecf20Sopenharmony_ci	XLGMAC_PR("ARP Offload Enabled                         : %s\n",
5358c2ecf20Sopenharmony_ci		  pdata->hw_feat.aoe ? "YES" : "NO");
5368c2ecf20Sopenharmony_ci	XLGMAC_PR("IEEE 1588-2008 Timestamp Enabled            : %s\n",
5378c2ecf20Sopenharmony_ci		  pdata->hw_feat.ts ? "YES" : "NO");
5388c2ecf20Sopenharmony_ci	XLGMAC_PR("Energy Efficient Ethernet Enabled           : %s\n",
5398c2ecf20Sopenharmony_ci		  pdata->hw_feat.eee ? "YES" : "NO");
5408c2ecf20Sopenharmony_ci	XLGMAC_PR("Transmit Checksum Offload Enabled           : %s\n",
5418c2ecf20Sopenharmony_ci		  pdata->hw_feat.tx_coe ? "YES" : "NO");
5428c2ecf20Sopenharmony_ci	XLGMAC_PR("Receive Checksum Offload Enabled            : %s\n",
5438c2ecf20Sopenharmony_ci		  pdata->hw_feat.rx_coe ? "YES" : "NO");
5448c2ecf20Sopenharmony_ci	XLGMAC_PR("Additional MAC Addresses 1-31 Selected      : %s\n",
5458c2ecf20Sopenharmony_ci		  pdata->hw_feat.addn_mac ? "YES" : "NO");
5468c2ecf20Sopenharmony_ci
5478c2ecf20Sopenharmony_ci	switch (pdata->hw_feat.ts_src) {
5488c2ecf20Sopenharmony_ci	case 0:
5498c2ecf20Sopenharmony_ci		str = "RESERVED";
5508c2ecf20Sopenharmony_ci		break;
5518c2ecf20Sopenharmony_ci	case 1:
5528c2ecf20Sopenharmony_ci		str = "INTERNAL";
5538c2ecf20Sopenharmony_ci		break;
5548c2ecf20Sopenharmony_ci	case 2:
5558c2ecf20Sopenharmony_ci		str = "EXTERNAL";
5568c2ecf20Sopenharmony_ci		break;
5578c2ecf20Sopenharmony_ci	case 3:
5588c2ecf20Sopenharmony_ci		str = "BOTH";
5598c2ecf20Sopenharmony_ci		break;
5608c2ecf20Sopenharmony_ci	}
5618c2ecf20Sopenharmony_ci	XLGMAC_PR("Timestamp System Time Source                : %s\n", str);
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_ci	XLGMAC_PR("Source Address or VLAN Insertion Enable     : %s\n",
5648c2ecf20Sopenharmony_ci		  pdata->hw_feat.sa_vlan_ins ? "YES" : "NO");
5658c2ecf20Sopenharmony_ci
5668c2ecf20Sopenharmony_ci	/* HW Feature Register1 */
5678c2ecf20Sopenharmony_ci	switch (pdata->hw_feat.rx_fifo_size) {
5688c2ecf20Sopenharmony_ci	case 0:
5698c2ecf20Sopenharmony_ci		str = "128 bytes";
5708c2ecf20Sopenharmony_ci		break;
5718c2ecf20Sopenharmony_ci	case 1:
5728c2ecf20Sopenharmony_ci		str = "256 bytes";
5738c2ecf20Sopenharmony_ci		break;
5748c2ecf20Sopenharmony_ci	case 2:
5758c2ecf20Sopenharmony_ci		str = "512 bytes";
5768c2ecf20Sopenharmony_ci		break;
5778c2ecf20Sopenharmony_ci	case 3:
5788c2ecf20Sopenharmony_ci		str = "1 KBytes";
5798c2ecf20Sopenharmony_ci		break;
5808c2ecf20Sopenharmony_ci	case 4:
5818c2ecf20Sopenharmony_ci		str = "2 KBytes";
5828c2ecf20Sopenharmony_ci		break;
5838c2ecf20Sopenharmony_ci	case 5:
5848c2ecf20Sopenharmony_ci		str = "4 KBytes";
5858c2ecf20Sopenharmony_ci		break;
5868c2ecf20Sopenharmony_ci	case 6:
5878c2ecf20Sopenharmony_ci		str = "8 KBytes";
5888c2ecf20Sopenharmony_ci		break;
5898c2ecf20Sopenharmony_ci	case 7:
5908c2ecf20Sopenharmony_ci		str = "16 KBytes";
5918c2ecf20Sopenharmony_ci		break;
5928c2ecf20Sopenharmony_ci	case 8:
5938c2ecf20Sopenharmony_ci		str = "32 kBytes";
5948c2ecf20Sopenharmony_ci		break;
5958c2ecf20Sopenharmony_ci	case 9:
5968c2ecf20Sopenharmony_ci		str = "64 KBytes";
5978c2ecf20Sopenharmony_ci		break;
5988c2ecf20Sopenharmony_ci	case 10:
5998c2ecf20Sopenharmony_ci		str = "128 KBytes";
6008c2ecf20Sopenharmony_ci		break;
6018c2ecf20Sopenharmony_ci	case 11:
6028c2ecf20Sopenharmony_ci		str = "256 KBytes";
6038c2ecf20Sopenharmony_ci		break;
6048c2ecf20Sopenharmony_ci	default:
6058c2ecf20Sopenharmony_ci		str = "RESERVED";
6068c2ecf20Sopenharmony_ci	}
6078c2ecf20Sopenharmony_ci	XLGMAC_PR("MTL Receive FIFO Size                       : %s\n", str);
6088c2ecf20Sopenharmony_ci
6098c2ecf20Sopenharmony_ci	switch (pdata->hw_feat.tx_fifo_size) {
6108c2ecf20Sopenharmony_ci	case 0:
6118c2ecf20Sopenharmony_ci		str = "128 bytes";
6128c2ecf20Sopenharmony_ci		break;
6138c2ecf20Sopenharmony_ci	case 1:
6148c2ecf20Sopenharmony_ci		str = "256 bytes";
6158c2ecf20Sopenharmony_ci		break;
6168c2ecf20Sopenharmony_ci	case 2:
6178c2ecf20Sopenharmony_ci		str = "512 bytes";
6188c2ecf20Sopenharmony_ci		break;
6198c2ecf20Sopenharmony_ci	case 3:
6208c2ecf20Sopenharmony_ci		str = "1 KBytes";
6218c2ecf20Sopenharmony_ci		break;
6228c2ecf20Sopenharmony_ci	case 4:
6238c2ecf20Sopenharmony_ci		str = "2 KBytes";
6248c2ecf20Sopenharmony_ci		break;
6258c2ecf20Sopenharmony_ci	case 5:
6268c2ecf20Sopenharmony_ci		str = "4 KBytes";
6278c2ecf20Sopenharmony_ci		break;
6288c2ecf20Sopenharmony_ci	case 6:
6298c2ecf20Sopenharmony_ci		str = "8 KBytes";
6308c2ecf20Sopenharmony_ci		break;
6318c2ecf20Sopenharmony_ci	case 7:
6328c2ecf20Sopenharmony_ci		str = "16 KBytes";
6338c2ecf20Sopenharmony_ci		break;
6348c2ecf20Sopenharmony_ci	case 8:
6358c2ecf20Sopenharmony_ci		str = "32 kBytes";
6368c2ecf20Sopenharmony_ci		break;
6378c2ecf20Sopenharmony_ci	case 9:
6388c2ecf20Sopenharmony_ci		str = "64 KBytes";
6398c2ecf20Sopenharmony_ci		break;
6408c2ecf20Sopenharmony_ci	case 10:
6418c2ecf20Sopenharmony_ci		str = "128 KBytes";
6428c2ecf20Sopenharmony_ci		break;
6438c2ecf20Sopenharmony_ci	case 11:
6448c2ecf20Sopenharmony_ci		str = "256 KBytes";
6458c2ecf20Sopenharmony_ci		break;
6468c2ecf20Sopenharmony_ci	default:
6478c2ecf20Sopenharmony_ci		str = "RESERVED";
6488c2ecf20Sopenharmony_ci	}
6498c2ecf20Sopenharmony_ci	XLGMAC_PR("MTL Transmit FIFO Size                      : %s\n", str);
6508c2ecf20Sopenharmony_ci
6518c2ecf20Sopenharmony_ci	XLGMAC_PR("IEEE 1588 High Word Register Enable         : %s\n",
6528c2ecf20Sopenharmony_ci		  pdata->hw_feat.adv_ts_hi ? "YES" : "NO");
6538c2ecf20Sopenharmony_ci	XLGMAC_PR("Address width                               : %u\n",
6548c2ecf20Sopenharmony_ci		  pdata->hw_feat.dma_width);
6558c2ecf20Sopenharmony_ci	XLGMAC_PR("DCB Feature Enable                          : %s\n",
6568c2ecf20Sopenharmony_ci		  pdata->hw_feat.dcb ? "YES" : "NO");
6578c2ecf20Sopenharmony_ci	XLGMAC_PR("Split Header Feature Enable                 : %s\n",
6588c2ecf20Sopenharmony_ci		  pdata->hw_feat.sph ? "YES" : "NO");
6598c2ecf20Sopenharmony_ci	XLGMAC_PR("TCP Segmentation Offload Enable             : %s\n",
6608c2ecf20Sopenharmony_ci		  pdata->hw_feat.tso ? "YES" : "NO");
6618c2ecf20Sopenharmony_ci	XLGMAC_PR("DMA Debug Registers Enabled                 : %s\n",
6628c2ecf20Sopenharmony_ci		  pdata->hw_feat.dma_debug ? "YES" : "NO");
6638c2ecf20Sopenharmony_ci	XLGMAC_PR("RSS Feature Enabled                         : %s\n",
6648c2ecf20Sopenharmony_ci		  pdata->hw_feat.rss ? "YES" : "NO");
6658c2ecf20Sopenharmony_ci	XLGMAC_PR("Number of Traffic classes                   : %u\n",
6668c2ecf20Sopenharmony_ci		  (pdata->hw_feat.tc_cnt));
6678c2ecf20Sopenharmony_ci	XLGMAC_PR("Hash Table Size                             : %u\n",
6688c2ecf20Sopenharmony_ci		  pdata->hw_feat.hash_table_size);
6698c2ecf20Sopenharmony_ci	XLGMAC_PR("Total number of L3 or L4 Filters            : %u\n",
6708c2ecf20Sopenharmony_ci		  pdata->hw_feat.l3l4_filter_num);
6718c2ecf20Sopenharmony_ci
6728c2ecf20Sopenharmony_ci	/* HW Feature Register2 */
6738c2ecf20Sopenharmony_ci	XLGMAC_PR("Number of MTL Receive Queues                : %u\n",
6748c2ecf20Sopenharmony_ci		  pdata->hw_feat.rx_q_cnt);
6758c2ecf20Sopenharmony_ci	XLGMAC_PR("Number of MTL Transmit Queues               : %u\n",
6768c2ecf20Sopenharmony_ci		  pdata->hw_feat.tx_q_cnt);
6778c2ecf20Sopenharmony_ci	XLGMAC_PR("Number of DMA Receive Channels              : %u\n",
6788c2ecf20Sopenharmony_ci		  pdata->hw_feat.rx_ch_cnt);
6798c2ecf20Sopenharmony_ci	XLGMAC_PR("Number of DMA Transmit Channels             : %u\n",
6808c2ecf20Sopenharmony_ci		  pdata->hw_feat.tx_ch_cnt);
6818c2ecf20Sopenharmony_ci
6828c2ecf20Sopenharmony_ci	switch (pdata->hw_feat.pps_out_num) {
6838c2ecf20Sopenharmony_ci	case 0:
6848c2ecf20Sopenharmony_ci		str = "No PPS output";
6858c2ecf20Sopenharmony_ci		break;
6868c2ecf20Sopenharmony_ci	case 1:
6878c2ecf20Sopenharmony_ci		str = "1 PPS output";
6888c2ecf20Sopenharmony_ci		break;
6898c2ecf20Sopenharmony_ci	case 2:
6908c2ecf20Sopenharmony_ci		str = "2 PPS output";
6918c2ecf20Sopenharmony_ci		break;
6928c2ecf20Sopenharmony_ci	case 3:
6938c2ecf20Sopenharmony_ci		str = "3 PPS output";
6948c2ecf20Sopenharmony_ci		break;
6958c2ecf20Sopenharmony_ci	case 4:
6968c2ecf20Sopenharmony_ci		str = "4 PPS output";
6978c2ecf20Sopenharmony_ci		break;
6988c2ecf20Sopenharmony_ci	default:
6998c2ecf20Sopenharmony_ci		str = "RESERVED";
7008c2ecf20Sopenharmony_ci	}
7018c2ecf20Sopenharmony_ci	XLGMAC_PR("Number of PPS Outputs                       : %s\n", str);
7028c2ecf20Sopenharmony_ci
7038c2ecf20Sopenharmony_ci	switch (pdata->hw_feat.aux_snap_num) {
7048c2ecf20Sopenharmony_ci	case 0:
7058c2ecf20Sopenharmony_ci		str = "No auxiliary input";
7068c2ecf20Sopenharmony_ci		break;
7078c2ecf20Sopenharmony_ci	case 1:
7088c2ecf20Sopenharmony_ci		str = "1 auxiliary input";
7098c2ecf20Sopenharmony_ci		break;
7108c2ecf20Sopenharmony_ci	case 2:
7118c2ecf20Sopenharmony_ci		str = "2 auxiliary input";
7128c2ecf20Sopenharmony_ci		break;
7138c2ecf20Sopenharmony_ci	case 3:
7148c2ecf20Sopenharmony_ci		str = "3 auxiliary input";
7158c2ecf20Sopenharmony_ci		break;
7168c2ecf20Sopenharmony_ci	case 4:
7178c2ecf20Sopenharmony_ci		str = "4 auxiliary input";
7188c2ecf20Sopenharmony_ci		break;
7198c2ecf20Sopenharmony_ci	default:
7208c2ecf20Sopenharmony_ci		str = "RESERVED";
7218c2ecf20Sopenharmony_ci	}
7228c2ecf20Sopenharmony_ci	XLGMAC_PR("Number of Auxiliary Snapshot Inputs         : %s", str);
7238c2ecf20Sopenharmony_ci
7248c2ecf20Sopenharmony_ci	XLGMAC_PR("\n");
7258c2ecf20Sopenharmony_ci	XLGMAC_PR("=====================================================\n");
7268c2ecf20Sopenharmony_ci	XLGMAC_PR("\n");
7278c2ecf20Sopenharmony_ci}
728