Skip to contentSkip to conversation

net: sxgbe: add ethtool related functions support Samsung sxgbe

PATCH Superseded Byungho An 1 participant 1 message Mar 13, 2014

Subsystems (3)

v2 of 14 Superseded Latest is v14 →

lore
Share & tools
lore

Byungho An

author
#0 lore raw

PATCH v2 6/7 net: sxgbe: add ethtool related functions support Samsung sxgbe

From: Vipul Pandya <[email protected]>

This patch adds ethtool related functions.

---
 drivers/net/ethernet/samsung/sxgbe_common.h  |   28 +-
 drivers/net/ethernet/samsung/sxgbe_ethtool.c |  509 +++++++++++++++++++++++++-
 drivers/net/ethernet/samsung/sxgbe_main.c    |   14 +-
 drivers/net/ethernet/samsung/sxgbe_reg.h     |    6 +
 4 files changed, 538 insertions(+), 19 deletions(-)
drivers/net/ethernet/samsung/sxgbe_common.h +25 -3
index b029181..1f65194 100644
@@ -42,8 +42,12 @@ struct sxgbe_mtl_ops;
 #define SXGBE_RX_QUEUES   16
 
 /* Max/Min RI Watchdog Timer count value */
-#define SXGBE_MAX_DMA_RIWT	0xff
-#define SXGBE_MIN_DMA_RIWT	0x20
+/* Calculated based how much time does it take to fill 256KB Rx memory
+ * at 10Gb speed at 156MHz clock rate and considered little less then
+ * the actual value.
+ */
+#define SXGBE_MAX_DMA_RIWT	0x70
+#define SXGBE_MIN_DMA_RIWT	0x01
 
 /* Tx coalesce parameters */
 #define SXGBE_COAL_TX_TIMER	40000
@@ -203,6 +207,20 @@ enum dma_irq_status {
 #define SXGBE_FOR_EACH_QUEUE(max_queues, queue_num)			\
 	for (queue_num = 0; queue_num < max_queues; queue_num++)
 
+#define DRV_VERSION "1.0.0"
+
+#define SXGBE_MAX_RX_CHANNELS	16
+#define SXGBE_MAX_TX_CHANNELS	16
+
+#define START_MAC_REG_OFFSET	0x0000
+#define MAX_MAC_REG_OFFSET	0x0DFC
+#define START_MTL_REG_OFFSET	0x1000
+#define MAX_MTL_REG_OFFSET	0x18FC
+#define START_DMA_REG_OFFSET	0x3000
+#define MAX_DMA_REG_OFFSET	0x38FC
+
+#define REG_SPACE_SIZE		0x2000
+
 /* sxgbe statistics counters */
 struct sxgbe_extra_stats {
 	/* TX/RX IRQ events */
@@ -484,7 +502,8 @@ struct sxgbe_priv_data {
 	int oldlink;
 	int speed;
 	int oldduplex;
-	unsigned int flow_ctrl;
+	u8 rx_pause;
+	u8 tx_pause;
 	unsigned int pause;
 	struct mii_bus *mii;
 	int mii_irq[PHY_MAX_ADDR];
@@ -504,6 +523,7 @@ struct sxgbe_priv_data {
 	u32 adv_ts;
 	int use_riwt;
 	spinlock_t ptp_lock;
+	struct ptp_clock *ptp_clock;
 
 	/* EEE-LPI specific members */
 	struct timer_list eee_ctrl_timer;
@@ -542,4 +562,6 @@ 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);
 
+int sxgbe_set_flow_ctrl(struct sxgbe_priv_data *priv, int rx, int tx);
+
 #endif /* __SXGBE_COMMON_H__ */
drivers/net/ethernet/samsung/sxgbe_ethtool.c +502 -7

548 lines not on this page · raw message

drivers/net/ethernet/samsung/sxgbe_main.c +5 -9
index 21a06ae..5482e3d 100644
@@ -59,7 +59,6 @@ static int debug = -1;
 static int sxgbe_phyaddr = -1;
 static int dma_txsize = DMA_TX_SIZE;
 static int dma_rxsize = DMA_RX_SIZE;
-static int flow_ctrl = SXGBE_FLOW_OFF;
 static int pause = SXGBE_PAUSE_TIME;
 static int tx_tc = TC_DEFAULT;
 static int rx_tc = TC_DEFAULT;
@@ -71,7 +70,6 @@ module_param(debug, int, S_IRUGO | S_IWUSR);
 module_param(sxgbe_phyaddr, int, S_IRUGO);
 module_param(dma_txsize, int, S_IRUGO | S_IWUSR);
 module_param(dma_rxsize, int, S_IRUGO | S_IWUSR);
-module_param(flow_ctrl, int, S_IRUGO | S_IWUSR);
 module_param(pause, int, S_IRUGO | S_IWUSR);
 module_param(tx_tc, int, S_IRUGO | S_IWUSR);
 module_param(rx_tc, int, S_IRUGO | S_IWUSR);
@@ -105,10 +103,6 @@ static void sxgbe_verify_args(void)
 		dma_txsize = DMA_TX_SIZE;
 	if (unlikely((buf_sz < DMA_BUFFER_SIZE) || (buf_sz > BUF_SIZE_16KiB)))
 		buf_sz = DMA_BUFFER_SIZE;
-	if (unlikely(flow_ctrl > 1))
-		flow_ctrl = SXGBE_FLOW_AUTO;
-	else if (likely(flow_ctrl < 0))
-		flow_ctrl = SXGBE_FLOW_OFF;
 	if (unlikely((pause < 0) || (pause > 0xffff)))
 		pause = SXGBE_PAUSE_TIME;
 	if (unlikely(eee_timer < 0))
@@ -2204,9 +2198,6 @@ struct sxgbe_priv_data *sxgbe_dvr_probe(struct device *device,
 
 	priv->msg_enable = netif_msg_init(debug, default_msg_level);
 
-	if (flow_ctrl)
-		priv->flow_ctrl = SXGBE_FLOW_AUTO;	/* RX/TX pause on */
-
 	/* Enable TCP segmentation offload for all DMA channels */
 	if (priv->hw_cap.tcpseg_offload) {
 		SXGBE_FOR_EACH_QUEUE(SXGBE_TX_QUEUES, queue_num) {
@@ -2220,6 +2211,11 @@ struct sxgbe_priv_data *sxgbe_dvr_probe(struct device *device,
 		priv->rxcsum_insertion = true;
 	}
 
+	/* Initialise pause frame settings */
+	priv->rx_pause = 1;
+	priv->tx_pause = 1;
+	sxgbe_set_flow_ctrl(priv, priv->rx_pause, priv->tx_pause);
+
 	/* Rx Watchdog is available, enable depend on platform data */
 	if (!priv->plat->riwt_off) {
 		priv->use_riwt = 1;
drivers/net/ethernet/samsung/sxgbe_reg.h +6 -0
index bd85923..ed1226d 100644
@@ -195,6 +195,12 @@
 #define SXGBE_CORE_RSS_ADD_REG		0x0C88
 #define SXGBE_CORE_RSS_DATA_REG		0x0C8C
 
+/* RSS control register bits */
+#define SXGBE_CORE_RSS_CTL_UDP4TE	BIT(3)
+#define SXGBE_CORE_RSS_CTL_TCP4TE	BIT(2)
+#define SXGBE_CORE_RSS_CTL_IP2TE	BIT(1)
+#define SXGBE_CORE_RSS_CTL_RSSE		BIT(0)
+
 /* IEEE 1588 registers */
 #define SXGBE_CORE_TSTAMP_CTL_REG	0x0D00
 #define SXGBE_CORE_SUBSEC_INC_REG	0x0D04
Signature · 1 line
1.7.10.4