Skip to contentSkip to conversation

net: sxgbe: add EEE(Energy Efficient Ethernet) for Samsung sxgbe

PATCH In review Byungho An 1 participant 1 message Mar 25, 2014

Subsystems (4)
lore
Share & tools
lore

Byungho An

author maintainer
#0 lore raw

PATCH v14 4/7 net: sxgbe: add EEE(Energy Efficient Ethernet) for Samsung sxgbe

From: Girish K S <[email protected]>

Added support for the EEE(Energy Efficient Ethernet) in 10G ethernet driver.

---
 drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h  |   53 +++++++
 drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c    |   86 +++++++++-
 drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c |   47 ++++++
 drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c    |  165 +++++++++++++++++++-
 .../net/ethernet/samsung/sxgbe/sxgbe_platform.c    |    6 +
 drivers/net/ethernet/samsung/sxgbe/sxgbe_reg.h     |    5 +
 6 files changed, 360 insertions(+), 2 deletions(-)
drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h +53 -0
index cf7ed07..7293c4c 100644
@@ -118,6 +118,33 @@ struct sxgbe_mtl_ops;
 #define RX_PTP_SIGNAL		0x0A
 #define RX_PTP_RESV_MSG		0x0F
 
+/* EEE-LPI mode  flags*/
+#define TX_ENTRY_LPI_MODE	0x10
+#define TX_EXIT_LPI_MODE	0x20
+#define RX_ENTRY_LPI_MODE	0x40
+#define RX_EXIT_LPI_MODE	0x80
+
+/* EEE-LPI Interrupt status flag */
+#define LPI_INT_STATUS		BIT(5)
+
+/* EEE-LPI Default timer values */
+#define LPI_LINK_STATUS_TIMER	0x3E8
+#define LPI_MAC_WAIT_TIMER	0x00
+
+/* EEE-LPI Control and status definitions */
+#define LPI_CTRL_STATUS_TXA	BIT(19)
+#define LPI_CTRL_STATUS_PLSDIS	BIT(18)
+#define LPI_CTRL_STATUS_PLS	BIT(17)
+#define LPI_CTRL_STATUS_LPIEN	BIT(16)
+#define LPI_CTRL_STATUS_TXRSTP	BIT(11)
+#define LPI_CTRL_STATUS_RXRSTP	BIT(10)
+#define LPI_CTRL_STATUS_RLPIST	BIT(9)
+#define LPI_CTRL_STATUS_TLPIST	BIT(8)
+#define LPI_CTRL_STATUS_RLPIEX	BIT(3)
+#define LPI_CTRL_STATUS_RLPIEN	BIT(2)
+#define LPI_CTRL_STATUS_TLPIEX	BIT(1)
+#define LPI_CTRL_STATUS_TLPIEN	BIT(0)
+
 enum dma_irq_status {
 	tx_hard_error	= BIT(0),
 	tx_bump_tc	= BIT(1),
@@ -202,6 +229,13 @@ struct sxgbe_extra_stats {
 	unsigned long rx_buffer_access_err;
 	unsigned long rx_data_transfer_err;
 
+	/* EEE-LPI stats */
+	unsigned long tx_lpi_entry_n;
+	unsigned long tx_lpi_exit_n;
+	unsigned long rx_lpi_entry_n;
+	unsigned long rx_lpi_exit_n;
+	unsigned long eee_wakeup_error_n;
+
 	/* RX specific */
 	/* L2 error */
 	unsigned long rx_code_gmii_err;
@@ -299,6 +333,13 @@ struct sxgbe_core_ops {
 				       unsigned char feature_index);
 	/* adjust SXGBE speed */
 	void (*set_speed)(void __iomem *ioaddr, unsigned char speed);
+
+	/* EEE-LPI specific operations */
+	void (*set_eee_mode)(void __iomem *ioaddr);
+	void (*reset_eee_mode)(void __iomem *ioaddr);
+	void (*set_eee_timer)(void __iomem *ioaddr, const int ls,
+			      const int tw);
+	void (*set_eee_pls)(void __iomem *ioaddr, const int link);
 };
 
 const struct sxgbe_core_ops *sxgbe_get_core_ops(void);
@@ -355,6 +396,8 @@ struct sxgbe_hw_features {
 	/* IEEE 1588-2008 */
 	unsigned int atime_stamp;
 
+	unsigned int eee;
+
 	unsigned int tx_csum_offload;
 	unsigned int rx_csum_offload;
 	unsigned int multi_macaddr;
@@ -438,6 +481,13 @@ struct sxgbe_priv_data {
 	/* tc control */
 	int tx_tc;
 	int rx_tc;
+	/* EEE-LPI specific members */
+	struct timer_list eee_ctrl_timer;
+	bool tx_path_in_lpi_mode;
+	int lpi_irq;
+	int eee_enabled;
+	int eee_active;
+	int tx_lpi_timer;
 };
 
 /* Function prototypes */
@@ -460,4 +510,7 @@ int sxgbe_restore(struct net_device *ndev);
 
 const struct sxgbe_mtl_ops *sxgbe_get_mtl_ops(void);
 
+void sxgbe_disable_eee_mode(struct sxgbe_priv_data * const priv);
+bool sxgbe_eee_init(struct sxgbe_priv_data * const priv);
+
 #endif /* __SXGBE_COMMON_H__ */
drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c +85 -1

108 lines not on this page · raw message

drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c +47 -0

57 lines not on this page · raw message

drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c +164 -1

250 lines not on this page · raw message

drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c +6 -0
index f5a9de7..94c2cd7 100644
@@ -145,6 +145,12 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
 		}
 	}
 
+	priv->lpi_irq = irq_of_parse_and_map(node, chan);
+	if (priv->lpi_irq <= 0) {
+		dev_err(dev, "sxgbe lpi irq parsing failed\n");
+		goto err_rx_irq_unmap;
+	}
+
 	platform_set_drvdata(pdev, priv->dev);
 
 	pr_debug("platform driver registration completed\n");
drivers/net/ethernet/samsung/sxgbe/sxgbe_reg.h +5 -0
index d1cd9ac..85a7b31 100644
@@ -25,6 +25,11 @@
 #define SXGBE_CORE_HASH_TABLE_REG5	0x0024
 #define SXGBE_CORE_HASH_TABLE_REG6	0x0028
 #define SXGBE_CORE_HASH_TABLE_REG7	0x002C
+
+/* EEE-LPI Registers */
+#define SXGBE_CORE_LPI_CTRL_STATUS	0x00D0
+#define SXGBE_CORE_LPI_TIMER_CTRL	0x00D4
+
 /* VLAN Specific Registers */
 #define SXGBE_CORE_VLAN_TAG_REG		0x0050
 #define SXGBE_CORE_VLAN_HASHTAB_REG	0x0058
Signature · 1 line
1.7.10.4