All of lore.kernel.org
 help / color / mirror / Atom feed
* [net-next PATCH v2 00/10] Add support for netcp driver on K2G SoC
@ 2018-03-27 16:31 ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

K2G SoC is another variant of Keystone family of SoCs. This patch
series add support for NetCP driver on this SoC. The QMSS found on
K2G SoC is a cut down version of the QMSS found on other keystone
devices with less number of queues, internal link ram etc. The patch
series has 2 patch sets that goes into the drivers/soc and the
rest has to be applied to net sub system. Please review and merge
if this looks good.

Thanks

The boot logs on K2G ICE board (tftp boot over Ethernet)
is at https://pastebin.ubuntu.com/p/VQTv3c2XBS/

The boot logs on K2G GP board (tftp boot over Ethernet)
is at https://pastebin.ubuntu.com/p/6Vh55DW8vT/

This series applies to net-next master branch.

Change history:
  v2 - Addressed following comments on initial version
       - split patch 3/5 to multiple patches from Andrew Lunn

Murali Karicheri (10):
  soc: ti: K2G: enhancement to support QMSS in NSS
  soc: ti: K2G: provide APIs to support driver probe deferral
  net: netcp: ethss: make call to gbe_sgmii_config() conditional
  net: netcp: ethss: add support for handling sgmii link interface
  net: netcp: ethss: use rgmii link status for 2u cpsw hardware
  net: netcp: ethss: map vlan priorities to zero flow
  net: netcp: ethss: re-use stats handling code for 2u hardware
  net: netcp: ethss: use of_get_phy_mode() to support different RGMII
    modes
  Revert "net: netcp: remove dead code from the driver"
  net: netcp: support probe deferral

 .../bindings/soc/ti/keystone-navigator-qmss.txt    |  7 ++
 drivers/net/ethernet/ti/netcp.h                    |  2 +
 drivers/net/ethernet/ti/netcp_core.c               | 13 +++
 drivers/net/ethernet/ti/netcp_ethss.c              | 75 ++++++++++++++---
 drivers/soc/ti/knav_dma.c                          |  8 ++
 drivers/soc/ti/knav_qmss.h                         |  6 ++
 drivers/soc/ti/knav_qmss_queue.c                   | 98 +++++++++++++++++-----
 include/linux/soc/ti/knav_dma.h                    | 12 +++
 include/linux/soc/ti/knav_qmss.h                   |  1 +
 9 files changed, 189 insertions(+), 33 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 00/10] Add support for netcp driver on K2G SoC
@ 2018-03-27 16:31 ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

K2G SoC is another variant of Keystone family of SoCs. This patch
series add support for NetCP driver on this SoC. The QMSS found on
K2G SoC is a cut down version of the QMSS found on other keystone
devices with less number of queues, internal link ram etc. The patch
series has 2 patch sets that goes into the drivers/soc and the
rest has to be applied to net sub system. Please review and merge
if this looks good.

Thanks

The boot logs on K2G ICE board (tftp boot over Ethernet)
is at https://pastebin.ubuntu.com/p/VQTv3c2XBS/

The boot logs on K2G GP board (tftp boot over Ethernet)
is at https://pastebin.ubuntu.com/p/6Vh55DW8vT/

This series applies to net-next master branch.

Change history:
  v2 - Addressed following comments on initial version
       - split patch 3/5 to multiple patches from Andrew Lunn

Murali Karicheri (10):
  soc: ti: K2G: enhancement to support QMSS in NSS
  soc: ti: K2G: provide APIs to support driver probe deferral
  net: netcp: ethss: make call to gbe_sgmii_config() conditional
  net: netcp: ethss: add support for handling sgmii link interface
  net: netcp: ethss: use rgmii link status for 2u cpsw hardware
  net: netcp: ethss: map vlan priorities to zero flow
  net: netcp: ethss: re-use stats handling code for 2u hardware
  net: netcp: ethss: use of_get_phy_mode() to support different RGMII
    modes
  Revert "net: netcp: remove dead code from the driver"
  net: netcp: support probe deferral

 .../bindings/soc/ti/keystone-navigator-qmss.txt    |  7 ++
 drivers/net/ethernet/ti/netcp.h                    |  2 +
 drivers/net/ethernet/ti/netcp_core.c               | 13 +++
 drivers/net/ethernet/ti/netcp_ethss.c              | 75 ++++++++++++++---
 drivers/soc/ti/knav_dma.c                          |  8 ++
 drivers/soc/ti/knav_qmss.h                         |  6 ++
 drivers/soc/ti/knav_qmss_queue.c                   | 98 +++++++++++++++++-----
 include/linux/soc/ti/knav_dma.h                    | 12 +++
 include/linux/soc/ti/knav_qmss.h                   |  1 +
 9 files changed, 189 insertions(+), 33 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 00/10] Add support for netcp driver on K2G SoC
@ 2018-03-27 16:31 ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: linux-arm-kernel

K2G SoC is another variant of Keystone family of SoCs. This patch
series add support for NetCP driver on this SoC. The QMSS found on
K2G SoC is a cut down version of the QMSS found on other keystone
devices with less number of queues, internal link ram etc. The patch
series has 2 patch sets that goes into the drivers/soc and the
rest has to be applied to net sub system. Please review and merge
if this looks good.

Thanks

The boot logs on K2G ICE board (tftp boot over Ethernet)
is at https://pastebin.ubuntu.com/p/VQTv3c2XBS/

The boot logs on K2G GP board (tftp boot over Ethernet)
is at https://pastebin.ubuntu.com/p/6Vh55DW8vT/

This series applies to net-next master branch.

Change history:
  v2 - Addressed following comments on initial version
       - split patch 3/5 to multiple patches from Andrew Lunn

Murali Karicheri (10):
  soc: ti: K2G: enhancement to support QMSS in NSS
  soc: ti: K2G: provide APIs to support driver probe deferral
  net: netcp: ethss: make call to gbe_sgmii_config() conditional
  net: netcp: ethss: add support for handling sgmii link interface
  net: netcp: ethss: use rgmii link status for 2u cpsw hardware
  net: netcp: ethss: map vlan priorities to zero flow
  net: netcp: ethss: re-use stats handling code for 2u hardware
  net: netcp: ethss: use of_get_phy_mode() to support different RGMII
    modes
  Revert "net: netcp: remove dead code from the driver"
  net: netcp: support probe deferral

 .../bindings/soc/ti/keystone-navigator-qmss.txt    |  7 ++
 drivers/net/ethernet/ti/netcp.h                    |  2 +
 drivers/net/ethernet/ti/netcp_core.c               | 13 +++
 drivers/net/ethernet/ti/netcp_ethss.c              | 75 ++++++++++++++---
 drivers/soc/ti/knav_dma.c                          |  8 ++
 drivers/soc/ti/knav_qmss.h                         |  6 ++
 drivers/soc/ti/knav_qmss_queue.c                   | 98 +++++++++++++++++-----
 include/linux/soc/ti/knav_dma.h                    | 12 +++
 include/linux/soc/ti/knav_qmss.h                   |  1 +
 9 files changed, 189 insertions(+), 33 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 01/10] soc: ti: K2G: enhancement to support QMSS in NSS
  2018-03-27 16:31 ` Murali Karicheri
  (?)
@ 2018-03-27 16:31   ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

Navigator Subsystem (NSS) available on K2G SoC has a cut down
version of QMSS with less number of queues, internal linking ram
with lesser number of buffers etc.  It doesn't have status and
explicit push register space as in QMSS available on other K2 SoCs.
So define reg indices specific to QMSS on K2G. This patch introduces
"keystone-navigator-qmss-l" compatibility to identify QMSS on
K2G NSS (QMSS Lite) and to customize the dts handling code. Per
Device manual, descriptors with index less than or equal to
regions0_size is in region 0 in the case of QMSS where as for
QMSS Lite, descriptors with index less than regions0_size is in
region 0. So update the size accordingly in the regions0_size bits
of the linking ram size 0 register.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
---
 .../bindings/soc/ti/keystone-navigator-qmss.txt    |  7 ++
 drivers/soc/ti/knav_qmss.h                         |  6 ++
 drivers/soc/ti/knav_qmss_queue.c                   | 90 ++++++++++++++++------
 3 files changed, 81 insertions(+), 22 deletions(-)

diff --git a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
index 77cd42c..1b0878a 100644
--- a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
+++ b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
@@ -18,6 +18,7 @@ pool management.
 
 Required properties:
 - compatible	: Must be "ti,keystone-navigator-qmss";
+		: Must be "ti,keystone-navigator-qmss-l" for NSS Lite
 - clocks	: phandle to the reference clock for this device.
 - queue-range	: <start number> total range of queue numbers for the device.
 - linkram0	: <address size> for internal link ram, where size is the total
@@ -39,6 +40,12 @@ Required properties:
 			  - Descriptor memory setup region.
 			  - Queue Management/Queue Proxy region for queue Push.
 			  - Queue Management/Queue Proxy region for queue Pop.
+
+For NSS lite, following QMSS reg indexes are used in that order
+			  - Queue Peek region.
+			  - Queue configuration region.
+			  - Queue Management/Queue Proxy region for queue Push/Pop.
+
 - queue-pools	: child node classifying the queue ranges into pools.
 		  Queue ranges are grouped into 3 type of pools:
 		  - qpend	    : pool of qpend(interruptible) queues
diff --git a/drivers/soc/ti/knav_qmss.h b/drivers/soc/ti/knav_qmss.h
index 905b974..5fa1ce6 100644
--- a/drivers/soc/ti/knav_qmss.h
+++ b/drivers/soc/ti/knav_qmss.h
@@ -292,6 +292,11 @@ struct knav_queue {
 	struct list_head		list;
 };
 
+enum qmss_version {
+	QMSS,
+	QMSS_LITE,
+};
+
 struct knav_device {
 	struct device				*dev;
 	unsigned				base_id;
@@ -305,6 +310,7 @@ struct knav_device {
 	struct list_head			pools;
 	struct list_head			pdsps;
 	struct list_head			qmgrs;
+	enum qmss_version			version;
 };
 
 struct knav_range_ops {
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index 77d6b5c..5b2c4e9 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -42,6 +42,15 @@
 #define KNAV_QUEUE_PUSH_REG_INDEX	4
 #define KNAV_QUEUE_POP_REG_INDEX	5
 
+/* Queue manager register indices in DTS for QMSS in NSS lite.
+ * There are no status and vbusm push registers on this version
+ * QMSS. Push registers are same as pop, So all indices above 1
+ * are to be re-defined
+ */
+#define KNAV_L_QUEUE_CONFIG_REG_INDEX	1
+#define KNAV_L_QUEUE_REGION_REG_INDEX	2
+#define KNAV_L_QUEUE_PUSH_REG_INDEX	3
+
 /* PDSP register indices in DTS */
 #define KNAV_QUEUE_PDSP_IRAM_REG_INDEX	0
 #define KNAV_QUEUE_PDSP_REGS_REG_INDEX	1
@@ -1169,8 +1178,12 @@ static int knav_queue_setup_link_ram(struct knav_device *kdev)
 		dev_dbg(kdev->dev, "linkram0: dma:%pad, virt:%p, size:%x\n",
 			&block->dma, block->virt, block->size);
 		writel_relaxed((u32)block->dma, &qmgr->reg_config->link_ram_base0);
-		writel_relaxed(block->size, &qmgr->reg_config->link_ram_size0);
-
+		if (kdev->version == QMSS_LITE)
+			writel_relaxed(block->size,
+				       &qmgr->reg_config->link_ram_size0);
+		else
+			writel_relaxed(block->size - 1,
+				       &qmgr->reg_config->link_ram_size0);
 		block++;
 		if (!block->size)
 			continue;
@@ -1387,42 +1400,64 @@ static int knav_queue_init_qmgrs(struct knav_device *kdev,
 		qmgr->reg_peek =
 			knav_queue_map_reg(kdev, child,
 					   KNAV_QUEUE_PEEK_REG_INDEX);
-		qmgr->reg_status =
-			knav_queue_map_reg(kdev, child,
-					   KNAV_QUEUE_STATUS_REG_INDEX);
+
+		if (kdev->version == QMSS) {
+			qmgr->reg_status =
+				knav_queue_map_reg(kdev, child,
+						   KNAV_QUEUE_STATUS_REG_INDEX);
+		}
+
 		qmgr->reg_config =
 			knav_queue_map_reg(kdev, child,
+					   (kdev->version == QMSS_LITE) ?
+					   KNAV_L_QUEUE_CONFIG_REG_INDEX :
 					   KNAV_QUEUE_CONFIG_REG_INDEX);
 		qmgr->reg_region =
 			knav_queue_map_reg(kdev, child,
+					   (kdev->version == QMSS_LITE) ?
+					   KNAV_L_QUEUE_REGION_REG_INDEX :
 					   KNAV_QUEUE_REGION_REG_INDEX);
+
 		qmgr->reg_push =
 			knav_queue_map_reg(kdev, child,
-					   KNAV_QUEUE_PUSH_REG_INDEX);
-		qmgr->reg_pop =
-			knav_queue_map_reg(kdev, child,
-					   KNAV_QUEUE_POP_REG_INDEX);
+					   (kdev->version == QMSS_LITE) ?
+					    KNAV_L_QUEUE_PUSH_REG_INDEX :
+					    KNAV_QUEUE_PUSH_REG_INDEX);
+
+		if (kdev->version == QMSS) {
+			qmgr->reg_pop =
+				knav_queue_map_reg(kdev, child,
+						   KNAV_QUEUE_POP_REG_INDEX);
+		}
 
-		if (IS_ERR(qmgr->reg_peek) || IS_ERR(qmgr->reg_status) ||
+		if (IS_ERR(qmgr->reg_peek) ||
+		    ((kdev->version == QMSS) &&
+		    (IS_ERR(qmgr->reg_status) || IS_ERR(qmgr->reg_pop))) ||
 		    IS_ERR(qmgr->reg_config) || IS_ERR(qmgr->reg_region) ||
-		    IS_ERR(qmgr->reg_push) || IS_ERR(qmgr->reg_pop)) {
+		    IS_ERR(qmgr->reg_push)) {
 			dev_err(dev, "failed to map qmgr regs\n");
+			if (kdev->version == QMSS) {
+				if (!IS_ERR(qmgr->reg_status))
+					devm_iounmap(dev, qmgr->reg_status);
+				if (!IS_ERR(qmgr->reg_pop))
+					devm_iounmap(dev, qmgr->reg_pop);
+			}
 			if (!IS_ERR(qmgr->reg_peek))
 				devm_iounmap(dev, qmgr->reg_peek);
-			if (!IS_ERR(qmgr->reg_status))
-				devm_iounmap(dev, qmgr->reg_status);
 			if (!IS_ERR(qmgr->reg_config))
 				devm_iounmap(dev, qmgr->reg_config);
 			if (!IS_ERR(qmgr->reg_region))
 				devm_iounmap(dev, qmgr->reg_region);
 			if (!IS_ERR(qmgr->reg_push))
 				devm_iounmap(dev, qmgr->reg_push);
-			if (!IS_ERR(qmgr->reg_pop))
-				devm_iounmap(dev, qmgr->reg_pop);
 			devm_kfree(dev, qmgr);
 			continue;
 		}
 
+		/* Use same push register for pop as well */
+		if (kdev->version == QMSS_LITE)
+			qmgr->reg_pop = qmgr->reg_push;
+
 		list_add_tail(&qmgr->list, &kdev->qmgrs);
 		dev_info(dev, "added qmgr start queue %d, num of queues %d, reg_peek %p, reg_status %p, reg_config %p, reg_region %p, reg_push %p, reg_pop %p\n",
 			 qmgr->start_queue, qmgr->num_queues,
@@ -1681,10 +1716,24 @@ static int knav_queue_init_queues(struct knav_device *kdev)
 	return 0;
 }
 
+/* Match table for of_platform binding */
+static const struct of_device_id keystone_qmss_of_match[] = {
+	{
+		.compatible = "ti,keystone-navigator-qmss",
+	},
+	{
+		.compatible = "ti,keystone-navigator-qmss-l",
+		.data	= (void *)QMSS_LITE,
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
+
 static int knav_queue_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct device_node *qmgrs, *queue_pools, *regions, *pdsps;
+	const struct of_device_id *match;
 	struct device *dev = &pdev->dev;
 	u32 temp[2];
 	int ret;
@@ -1700,6 +1749,10 @@ static int knav_queue_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	match = of_match_device(of_match_ptr(keystone_qmss_of_match), dev);
+	if (match && match->data)
+		kdev->version = QMSS_LITE;
+
 	platform_set_drvdata(pdev, kdev);
 	kdev->dev = dev;
 	INIT_LIST_HEAD(&kdev->queue_ranges);
@@ -1815,13 +1868,6 @@ static int knav_queue_remove(struct platform_device *pdev)
 	return 0;
 }
 
-/* Match table for of_platform binding */
-static struct of_device_id keystone_qmss_of_match[] = {
-	{ .compatible = "ti,keystone-navigator-qmss", },
-	{},
-};
-MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
-
 static struct platform_driver keystone_qmss_driver = {
 	.probe		= knav_queue_probe,
 	.remove		= knav_queue_remove,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 01/10] soc: ti: K2G: enhancement to support QMSS in NSS
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

Navigator Subsystem (NSS) available on K2G SoC has a cut down
version of QMSS with less number of queues, internal linking ram
with lesser number of buffers etc.  It doesn't have status and
explicit push register space as in QMSS available on other K2 SoCs.
So define reg indices specific to QMSS on K2G. This patch introduces
"keystone-navigator-qmss-l" compatibility to identify QMSS on
K2G NSS (QMSS Lite) and to customize the dts handling code. Per
Device manual, descriptors with index less than or equal to
regions0_size is in region 0 in the case of QMSS where as for
QMSS Lite, descriptors with index less than regions0_size is in
region 0. So update the size accordingly in the regions0_size bits
of the linking ram size 0 register.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
---
 .../bindings/soc/ti/keystone-navigator-qmss.txt    |  7 ++
 drivers/soc/ti/knav_qmss.h                         |  6 ++
 drivers/soc/ti/knav_qmss_queue.c                   | 90 ++++++++++++++++------
 3 files changed, 81 insertions(+), 22 deletions(-)

diff --git a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
index 77cd42c..1b0878a 100644
--- a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
+++ b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
@@ -18,6 +18,7 @@ pool management.
 
 Required properties:
 - compatible	: Must be "ti,keystone-navigator-qmss";
+		: Must be "ti,keystone-navigator-qmss-l" for NSS Lite
 - clocks	: phandle to the reference clock for this device.
 - queue-range	: <start number> total range of queue numbers for the device.
 - linkram0	: <address size> for internal link ram, where size is the total
@@ -39,6 +40,12 @@ Required properties:
 			  - Descriptor memory setup region.
 			  - Queue Management/Queue Proxy region for queue Push.
 			  - Queue Management/Queue Proxy region for queue Pop.
+
+For NSS lite, following QMSS reg indexes are used in that order
+			  - Queue Peek region.
+			  - Queue configuration region.
+			  - Queue Management/Queue Proxy region for queue Push/Pop.
+
 - queue-pools	: child node classifying the queue ranges into pools.
 		  Queue ranges are grouped into 3 type of pools:
 		  - qpend	    : pool of qpend(interruptible) queues
diff --git a/drivers/soc/ti/knav_qmss.h b/drivers/soc/ti/knav_qmss.h
index 905b974..5fa1ce6 100644
--- a/drivers/soc/ti/knav_qmss.h
+++ b/drivers/soc/ti/knav_qmss.h
@@ -292,6 +292,11 @@ struct knav_queue {
 	struct list_head		list;
 };
 
+enum qmss_version {
+	QMSS,
+	QMSS_LITE,
+};
+
 struct knav_device {
 	struct device				*dev;
 	unsigned				base_id;
@@ -305,6 +310,7 @@ struct knav_device {
 	struct list_head			pools;
 	struct list_head			pdsps;
 	struct list_head			qmgrs;
+	enum qmss_version			version;
 };
 
 struct knav_range_ops {
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index 77d6b5c..5b2c4e9 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -42,6 +42,15 @@
 #define KNAV_QUEUE_PUSH_REG_INDEX	4
 #define KNAV_QUEUE_POP_REG_INDEX	5
 
+/* Queue manager register indices in DTS for QMSS in NSS lite.
+ * There are no status and vbusm push registers on this version
+ * QMSS. Push registers are same as pop, So all indices above 1
+ * are to be re-defined
+ */
+#define KNAV_L_QUEUE_CONFIG_REG_INDEX	1
+#define KNAV_L_QUEUE_REGION_REG_INDEX	2
+#define KNAV_L_QUEUE_PUSH_REG_INDEX	3
+
 /* PDSP register indices in DTS */
 #define KNAV_QUEUE_PDSP_IRAM_REG_INDEX	0
 #define KNAV_QUEUE_PDSP_REGS_REG_INDEX	1
@@ -1169,8 +1178,12 @@ static int knav_queue_setup_link_ram(struct knav_device *kdev)
 		dev_dbg(kdev->dev, "linkram0: dma:%pad, virt:%p, size:%x\n",
 			&block->dma, block->virt, block->size);
 		writel_relaxed((u32)block->dma, &qmgr->reg_config->link_ram_base0);
-		writel_relaxed(block->size, &qmgr->reg_config->link_ram_size0);
-
+		if (kdev->version == QMSS_LITE)
+			writel_relaxed(block->size,
+				       &qmgr->reg_config->link_ram_size0);
+		else
+			writel_relaxed(block->size - 1,
+				       &qmgr->reg_config->link_ram_size0);
 		block++;
 		if (!block->size)
 			continue;
@@ -1387,42 +1400,64 @@ static int knav_queue_init_qmgrs(struct knav_device *kdev,
 		qmgr->reg_peek =
 			knav_queue_map_reg(kdev, child,
 					   KNAV_QUEUE_PEEK_REG_INDEX);
-		qmgr->reg_status =
-			knav_queue_map_reg(kdev, child,
-					   KNAV_QUEUE_STATUS_REG_INDEX);
+
+		if (kdev->version == QMSS) {
+			qmgr->reg_status =
+				knav_queue_map_reg(kdev, child,
+						   KNAV_QUEUE_STATUS_REG_INDEX);
+		}
+
 		qmgr->reg_config =
 			knav_queue_map_reg(kdev, child,
+					   (kdev->version == QMSS_LITE) ?
+					   KNAV_L_QUEUE_CONFIG_REG_INDEX :
 					   KNAV_QUEUE_CONFIG_REG_INDEX);
 		qmgr->reg_region =
 			knav_queue_map_reg(kdev, child,
+					   (kdev->version == QMSS_LITE) ?
+					   KNAV_L_QUEUE_REGION_REG_INDEX :
 					   KNAV_QUEUE_REGION_REG_INDEX);
+
 		qmgr->reg_push =
 			knav_queue_map_reg(kdev, child,
-					   KNAV_QUEUE_PUSH_REG_INDEX);
-		qmgr->reg_pop =
-			knav_queue_map_reg(kdev, child,
-					   KNAV_QUEUE_POP_REG_INDEX);
+					   (kdev->version == QMSS_LITE) ?
+					    KNAV_L_QUEUE_PUSH_REG_INDEX :
+					    KNAV_QUEUE_PUSH_REG_INDEX);
+
+		if (kdev->version == QMSS) {
+			qmgr->reg_pop =
+				knav_queue_map_reg(kdev, child,
+						   KNAV_QUEUE_POP_REG_INDEX);
+		}
 
-		if (IS_ERR(qmgr->reg_peek) || IS_ERR(qmgr->reg_status) ||
+		if (IS_ERR(qmgr->reg_peek) ||
+		    ((kdev->version == QMSS) &&
+		    (IS_ERR(qmgr->reg_status) || IS_ERR(qmgr->reg_pop))) ||
 		    IS_ERR(qmgr->reg_config) || IS_ERR(qmgr->reg_region) ||
-		    IS_ERR(qmgr->reg_push) || IS_ERR(qmgr->reg_pop)) {
+		    IS_ERR(qmgr->reg_push)) {
 			dev_err(dev, "failed to map qmgr regs\n");
+			if (kdev->version == QMSS) {
+				if (!IS_ERR(qmgr->reg_status))
+					devm_iounmap(dev, qmgr->reg_status);
+				if (!IS_ERR(qmgr->reg_pop))
+					devm_iounmap(dev, qmgr->reg_pop);
+			}
 			if (!IS_ERR(qmgr->reg_peek))
 				devm_iounmap(dev, qmgr->reg_peek);
-			if (!IS_ERR(qmgr->reg_status))
-				devm_iounmap(dev, qmgr->reg_status);
 			if (!IS_ERR(qmgr->reg_config))
 				devm_iounmap(dev, qmgr->reg_config);
 			if (!IS_ERR(qmgr->reg_region))
 				devm_iounmap(dev, qmgr->reg_region);
 			if (!IS_ERR(qmgr->reg_push))
 				devm_iounmap(dev, qmgr->reg_push);
-			if (!IS_ERR(qmgr->reg_pop))
-				devm_iounmap(dev, qmgr->reg_pop);
 			devm_kfree(dev, qmgr);
 			continue;
 		}
 
+		/* Use same push register for pop as well */
+		if (kdev->version == QMSS_LITE)
+			qmgr->reg_pop = qmgr->reg_push;
+
 		list_add_tail(&qmgr->list, &kdev->qmgrs);
 		dev_info(dev, "added qmgr start queue %d, num of queues %d, reg_peek %p, reg_status %p, reg_config %p, reg_region %p, reg_push %p, reg_pop %p\n",
 			 qmgr->start_queue, qmgr->num_queues,
@@ -1681,10 +1716,24 @@ static int knav_queue_init_queues(struct knav_device *kdev)
 	return 0;
 }
 
+/* Match table for of_platform binding */
+static const struct of_device_id keystone_qmss_of_match[] = {
+	{
+		.compatible = "ti,keystone-navigator-qmss",
+	},
+	{
+		.compatible = "ti,keystone-navigator-qmss-l",
+		.data	= (void *)QMSS_LITE,
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
+
 static int knav_queue_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct device_node *qmgrs, *queue_pools, *regions, *pdsps;
+	const struct of_device_id *match;
 	struct device *dev = &pdev->dev;
 	u32 temp[2];
 	int ret;
@@ -1700,6 +1749,10 @@ static int knav_queue_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	match = of_match_device(of_match_ptr(keystone_qmss_of_match), dev);
+	if (match && match->data)
+		kdev->version = QMSS_LITE;
+
 	platform_set_drvdata(pdev, kdev);
 	kdev->dev = dev;
 	INIT_LIST_HEAD(&kdev->queue_ranges);
@@ -1815,13 +1868,6 @@ static int knav_queue_remove(struct platform_device *pdev)
 	return 0;
 }
 
-/* Match table for of_platform binding */
-static struct of_device_id keystone_qmss_of_match[] = {
-	{ .compatible = "ti,keystone-navigator-qmss", },
-	{},
-};
-MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
-
 static struct platform_driver keystone_qmss_driver = {
 	.probe		= knav_queue_probe,
 	.remove		= knav_queue_remove,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 01/10] soc: ti: K2G: enhancement to support QMSS in NSS
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: linux-arm-kernel

Navigator Subsystem (NSS) available on K2G SoC has a cut down
version of QMSS with less number of queues, internal linking ram
with lesser number of buffers etc.  It doesn't have status and
explicit push register space as in QMSS available on other K2 SoCs.
So define reg indices specific to QMSS on K2G. This patch introduces
"keystone-navigator-qmss-l" compatibility to identify QMSS on
K2G NSS (QMSS Lite) and to customize the dts handling code. Per
Device manual, descriptors with index less than or equal to
regions0_size is in region 0 in the case of QMSS where as for
QMSS Lite, descriptors with index less than regions0_size is in
region 0. So update the size accordingly in the regions0_size bits
of the linking ram size 0 register.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
---
 .../bindings/soc/ti/keystone-navigator-qmss.txt    |  7 ++
 drivers/soc/ti/knav_qmss.h                         |  6 ++
 drivers/soc/ti/knav_qmss_queue.c                   | 90 ++++++++++++++++------
 3 files changed, 81 insertions(+), 22 deletions(-)

diff --git a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
index 77cd42c..1b0878a 100644
--- a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
+++ b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
@@ -18,6 +18,7 @@ pool management.
 
 Required properties:
 - compatible	: Must be "ti,keystone-navigator-qmss";
+		: Must be "ti,keystone-navigator-qmss-l" for NSS Lite
 - clocks	: phandle to the reference clock for this device.
 - queue-range	: <start number> total range of queue numbers for the device.
 - linkram0	: <address size> for internal link ram, where size is the total
@@ -39,6 +40,12 @@ Required properties:
 			  - Descriptor memory setup region.
 			  - Queue Management/Queue Proxy region for queue Push.
 			  - Queue Management/Queue Proxy region for queue Pop.
+
+For NSS lite, following QMSS reg indexes are used in that order
+			  - Queue Peek region.
+			  - Queue configuration region.
+			  - Queue Management/Queue Proxy region for queue Push/Pop.
+
 - queue-pools	: child node classifying the queue ranges into pools.
 		  Queue ranges are grouped into 3 type of pools:
 		  - qpend	    : pool of qpend(interruptible) queues
diff --git a/drivers/soc/ti/knav_qmss.h b/drivers/soc/ti/knav_qmss.h
index 905b974..5fa1ce6 100644
--- a/drivers/soc/ti/knav_qmss.h
+++ b/drivers/soc/ti/knav_qmss.h
@@ -292,6 +292,11 @@ struct knav_queue {
 	struct list_head		list;
 };
 
+enum qmss_version {
+	QMSS,
+	QMSS_LITE,
+};
+
 struct knav_device {
 	struct device				*dev;
 	unsigned				base_id;
@@ -305,6 +310,7 @@ struct knav_device {
 	struct list_head			pools;
 	struct list_head			pdsps;
 	struct list_head			qmgrs;
+	enum qmss_version			version;
 };
 
 struct knav_range_ops {
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index 77d6b5c..5b2c4e9 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -42,6 +42,15 @@
 #define KNAV_QUEUE_PUSH_REG_INDEX	4
 #define KNAV_QUEUE_POP_REG_INDEX	5
 
+/* Queue manager register indices in DTS for QMSS in NSS lite.
+ * There are no status and vbusm push registers on this version
+ * QMSS. Push registers are same as pop, So all indices above 1
+ * are to be re-defined
+ */
+#define KNAV_L_QUEUE_CONFIG_REG_INDEX	1
+#define KNAV_L_QUEUE_REGION_REG_INDEX	2
+#define KNAV_L_QUEUE_PUSH_REG_INDEX	3
+
 /* PDSP register indices in DTS */
 #define KNAV_QUEUE_PDSP_IRAM_REG_INDEX	0
 #define KNAV_QUEUE_PDSP_REGS_REG_INDEX	1
@@ -1169,8 +1178,12 @@ static int knav_queue_setup_link_ram(struct knav_device *kdev)
 		dev_dbg(kdev->dev, "linkram0: dma:%pad, virt:%p, size:%x\n",
 			&block->dma, block->virt, block->size);
 		writel_relaxed((u32)block->dma, &qmgr->reg_config->link_ram_base0);
-		writel_relaxed(block->size, &qmgr->reg_config->link_ram_size0);
-
+		if (kdev->version == QMSS_LITE)
+			writel_relaxed(block->size,
+				       &qmgr->reg_config->link_ram_size0);
+		else
+			writel_relaxed(block->size - 1,
+				       &qmgr->reg_config->link_ram_size0);
 		block++;
 		if (!block->size)
 			continue;
@@ -1387,42 +1400,64 @@ static int knav_queue_init_qmgrs(struct knav_device *kdev,
 		qmgr->reg_peek =
 			knav_queue_map_reg(kdev, child,
 					   KNAV_QUEUE_PEEK_REG_INDEX);
-		qmgr->reg_status =
-			knav_queue_map_reg(kdev, child,
-					   KNAV_QUEUE_STATUS_REG_INDEX);
+
+		if (kdev->version == QMSS) {
+			qmgr->reg_status =
+				knav_queue_map_reg(kdev, child,
+						   KNAV_QUEUE_STATUS_REG_INDEX);
+		}
+
 		qmgr->reg_config =
 			knav_queue_map_reg(kdev, child,
+					   (kdev->version == QMSS_LITE) ?
+					   KNAV_L_QUEUE_CONFIG_REG_INDEX :
 					   KNAV_QUEUE_CONFIG_REG_INDEX);
 		qmgr->reg_region =
 			knav_queue_map_reg(kdev, child,
+					   (kdev->version == QMSS_LITE) ?
+					   KNAV_L_QUEUE_REGION_REG_INDEX :
 					   KNAV_QUEUE_REGION_REG_INDEX);
+
 		qmgr->reg_push =
 			knav_queue_map_reg(kdev, child,
-					   KNAV_QUEUE_PUSH_REG_INDEX);
-		qmgr->reg_pop =
-			knav_queue_map_reg(kdev, child,
-					   KNAV_QUEUE_POP_REG_INDEX);
+					   (kdev->version == QMSS_LITE) ?
+					    KNAV_L_QUEUE_PUSH_REG_INDEX :
+					    KNAV_QUEUE_PUSH_REG_INDEX);
+
+		if (kdev->version == QMSS) {
+			qmgr->reg_pop =
+				knav_queue_map_reg(kdev, child,
+						   KNAV_QUEUE_POP_REG_INDEX);
+		}
 
-		if (IS_ERR(qmgr->reg_peek) || IS_ERR(qmgr->reg_status) ||
+		if (IS_ERR(qmgr->reg_peek) ||
+		    ((kdev->version == QMSS) &&
+		    (IS_ERR(qmgr->reg_status) || IS_ERR(qmgr->reg_pop))) ||
 		    IS_ERR(qmgr->reg_config) || IS_ERR(qmgr->reg_region) ||
-		    IS_ERR(qmgr->reg_push) || IS_ERR(qmgr->reg_pop)) {
+		    IS_ERR(qmgr->reg_push)) {
 			dev_err(dev, "failed to map qmgr regs\n");
+			if (kdev->version == QMSS) {
+				if (!IS_ERR(qmgr->reg_status))
+					devm_iounmap(dev, qmgr->reg_status);
+				if (!IS_ERR(qmgr->reg_pop))
+					devm_iounmap(dev, qmgr->reg_pop);
+			}
 			if (!IS_ERR(qmgr->reg_peek))
 				devm_iounmap(dev, qmgr->reg_peek);
-			if (!IS_ERR(qmgr->reg_status))
-				devm_iounmap(dev, qmgr->reg_status);
 			if (!IS_ERR(qmgr->reg_config))
 				devm_iounmap(dev, qmgr->reg_config);
 			if (!IS_ERR(qmgr->reg_region))
 				devm_iounmap(dev, qmgr->reg_region);
 			if (!IS_ERR(qmgr->reg_push))
 				devm_iounmap(dev, qmgr->reg_push);
-			if (!IS_ERR(qmgr->reg_pop))
-				devm_iounmap(dev, qmgr->reg_pop);
 			devm_kfree(dev, qmgr);
 			continue;
 		}
 
+		/* Use same push register for pop as well */
+		if (kdev->version == QMSS_LITE)
+			qmgr->reg_pop = qmgr->reg_push;
+
 		list_add_tail(&qmgr->list, &kdev->qmgrs);
 		dev_info(dev, "added qmgr start queue %d, num of queues %d, reg_peek %p, reg_status %p, reg_config %p, reg_region %p, reg_push %p, reg_pop %p\n",
 			 qmgr->start_queue, qmgr->num_queues,
@@ -1681,10 +1716,24 @@ static int knav_queue_init_queues(struct knav_device *kdev)
 	return 0;
 }
 
+/* Match table for of_platform binding */
+static const struct of_device_id keystone_qmss_of_match[] = {
+	{
+		.compatible = "ti,keystone-navigator-qmss",
+	},
+	{
+		.compatible = "ti,keystone-navigator-qmss-l",
+		.data	= (void *)QMSS_LITE,
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
+
 static int knav_queue_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct device_node *qmgrs, *queue_pools, *regions, *pdsps;
+	const struct of_device_id *match;
 	struct device *dev = &pdev->dev;
 	u32 temp[2];
 	int ret;
@@ -1700,6 +1749,10 @@ static int knav_queue_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	match = of_match_device(of_match_ptr(keystone_qmss_of_match), dev);
+	if (match && match->data)
+		kdev->version = QMSS_LITE;
+
 	platform_set_drvdata(pdev, kdev);
 	kdev->dev = dev;
 	INIT_LIST_HEAD(&kdev->queue_ranges);
@@ -1815,13 +1868,6 @@ static int knav_queue_remove(struct platform_device *pdev)
 	return 0;
 }
 
-/* Match table for of_platform binding */
-static struct of_device_id keystone_qmss_of_match[] = {
-	{ .compatible = "ti,keystone-navigator-qmss", },
-	{},
-};
-MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
-
 static struct platform_driver keystone_qmss_driver = {
 	.probe		= knav_queue_probe,
 	.remove		= knav_queue_remove,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 02/10] soc: ti: K2G: provide APIs to support driver probe deferral
  2018-03-27 16:31 ` Murali Karicheri
  (?)
@ 2018-03-27 16:31   ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

This patch provide APIs to allow client drivers to support
probe deferral. On K2G SoC, devices can be probed only
after the ti_sci_pm_domains driver is probed and ready.
As drivers may get probed at different order, any driver
that depends on knav dma and qmss drivers, for example
netcp network driver, needs to defer probe until
knav devices are probed and ready to service. To do this,
add an API to query the device ready status from the knav
dma and qmss devices.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/soc/ti/knav_dma.c        |  8 ++++++++
 drivers/soc/ti/knav_qmss_queue.c |  8 ++++++++
 include/linux/soc/ti/knav_dma.h  | 12 ++++++++++++
 include/linux/soc/ti/knav_qmss.h |  1 +
 4 files changed, 29 insertions(+)

diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c
index 026182d..224d7dd 100644
--- a/drivers/soc/ti/knav_dma.c
+++ b/drivers/soc/ti/knav_dma.c
@@ -134,6 +134,13 @@ struct knav_dma_chan {
 
 static struct knav_dma_pool_device *kdev;
 
+static bool device_ready;
+bool knav_dma_device_ready(void)
+{
+	return device_ready;
+}
+EXPORT_SYMBOL_GPL(knav_dma_device_ready);
+
 static bool check_config(struct knav_dma_chan *chan, struct knav_dma_cfg *cfg)
 {
 	if (!memcmp(&chan->cfg, cfg, sizeof(*cfg)))
@@ -773,6 +780,7 @@ static int knav_dma_probe(struct platform_device *pdev)
 	debugfs_create_file("knav_dma", S_IFREG | S_IRUGO, NULL, NULL,
 			    &knav_dma_debug_ops);
 
+	device_ready = true;
 	return ret;
 }
 
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index 5b2c4e9..f0e67aa 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -74,6 +74,13 @@
  */
 const char *knav_acc_firmwares[] = {"ks2_qmss_pdsp_acc48.bin"};
 
+static bool device_ready;
+bool knav_qmss_device_ready(void)
+{
+	return device_ready;
+}
+EXPORT_SYMBOL_GPL(knav_qmss_device_ready);
+
 /**
  * knav_queue_notify: qmss queue notfier call
  *
@@ -1849,6 +1856,7 @@ static int knav_queue_probe(struct platform_device *pdev)
 
 	debugfs_create_file("qmss", S_IFREG | S_IRUGO, NULL, NULL,
 			    &knav_queue_debug_ops);
+	device_ready = true;
 	return 0;
 
 err:
diff --git a/include/linux/soc/ti/knav_dma.h b/include/linux/soc/ti/knav_dma.h
index 66693bc..7127ec3 100644
--- a/include/linux/soc/ti/knav_dma.h
+++ b/include/linux/soc/ti/knav_dma.h
@@ -167,6 +167,8 @@ struct knav_dma_desc {
 void *knav_dma_open_channel(struct device *dev, const char *name,
 				struct knav_dma_cfg *config);
 void knav_dma_close_channel(void *channel);
+int knav_dma_get_flow(void *channel);
+bool knav_dma_device_ready(void);
 #else
 static inline void *knav_dma_open_channel(struct device *dev, const char *name,
 				struct knav_dma_cfg *config)
@@ -176,6 +178,16 @@ static inline void *knav_dma_open_channel(struct device *dev, const char *name,
 static inline void knav_dma_close_channel(void *channel)
 {}
 
+static inline int knav_dma_get_flow(void *channel)
+{
+	return -EINVAL;
+}
+
+static inline bool knav_dma_device_ready(void)
+{
+	return false;
+}
+
 #endif
 
 #endif /* __SOC_TI_KEYSTONE_NAVIGATOR_DMA_H__ */
diff --git a/include/linux/soc/ti/knav_qmss.h b/include/linux/soc/ti/knav_qmss.h
index 9f0ebb3b..9745df6 100644
--- a/include/linux/soc/ti/knav_qmss.h
+++ b/include/linux/soc/ti/knav_qmss.h
@@ -86,5 +86,6 @@ int knav_pool_desc_map(void *ph, void *desc, unsigned size,
 void *knav_pool_desc_unmap(void *ph, dma_addr_t dma, unsigned dma_sz);
 dma_addr_t knav_pool_desc_virt_to_dma(void *ph, void *virt);
 void *knav_pool_desc_dma_to_virt(void *ph, dma_addr_t dma);
+bool knav_qmss_device_ready(void);
 
 #endif /* __SOC_TI_KNAV_QMSS_H__ */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 02/10] soc: ti: K2G: provide APIs to support driver probe deferral
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

This patch provide APIs to allow client drivers to support
probe deferral. On K2G SoC, devices can be probed only
after the ti_sci_pm_domains driver is probed and ready.
As drivers may get probed at different order, any driver
that depends on knav dma and qmss drivers, for example
netcp network driver, needs to defer probe until
knav devices are probed and ready to service. To do this,
add an API to query the device ready status from the knav
dma and qmss devices.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/soc/ti/knav_dma.c        |  8 ++++++++
 drivers/soc/ti/knav_qmss_queue.c |  8 ++++++++
 include/linux/soc/ti/knav_dma.h  | 12 ++++++++++++
 include/linux/soc/ti/knav_qmss.h |  1 +
 4 files changed, 29 insertions(+)

diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c
index 026182d..224d7dd 100644
--- a/drivers/soc/ti/knav_dma.c
+++ b/drivers/soc/ti/knav_dma.c
@@ -134,6 +134,13 @@ struct knav_dma_chan {
 
 static struct knav_dma_pool_device *kdev;
 
+static bool device_ready;
+bool knav_dma_device_ready(void)
+{
+	return device_ready;
+}
+EXPORT_SYMBOL_GPL(knav_dma_device_ready);
+
 static bool check_config(struct knav_dma_chan *chan, struct knav_dma_cfg *cfg)
 {
 	if (!memcmp(&chan->cfg, cfg, sizeof(*cfg)))
@@ -773,6 +780,7 @@ static int knav_dma_probe(struct platform_device *pdev)
 	debugfs_create_file("knav_dma", S_IFREG | S_IRUGO, NULL, NULL,
 			    &knav_dma_debug_ops);
 
+	device_ready = true;
 	return ret;
 }
 
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index 5b2c4e9..f0e67aa 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -74,6 +74,13 @@
  */
 const char *knav_acc_firmwares[] = {"ks2_qmss_pdsp_acc48.bin"};
 
+static bool device_ready;
+bool knav_qmss_device_ready(void)
+{
+	return device_ready;
+}
+EXPORT_SYMBOL_GPL(knav_qmss_device_ready);
+
 /**
  * knav_queue_notify: qmss queue notfier call
  *
@@ -1849,6 +1856,7 @@ static int knav_queue_probe(struct platform_device *pdev)
 
 	debugfs_create_file("qmss", S_IFREG | S_IRUGO, NULL, NULL,
 			    &knav_queue_debug_ops);
+	device_ready = true;
 	return 0;
 
 err:
diff --git a/include/linux/soc/ti/knav_dma.h b/include/linux/soc/ti/knav_dma.h
index 66693bc..7127ec3 100644
--- a/include/linux/soc/ti/knav_dma.h
+++ b/include/linux/soc/ti/knav_dma.h
@@ -167,6 +167,8 @@ struct knav_dma_desc {
 void *knav_dma_open_channel(struct device *dev, const char *name,
 				struct knav_dma_cfg *config);
 void knav_dma_close_channel(void *channel);
+int knav_dma_get_flow(void *channel);
+bool knav_dma_device_ready(void);
 #else
 static inline void *knav_dma_open_channel(struct device *dev, const char *name,
 				struct knav_dma_cfg *config)
@@ -176,6 +178,16 @@ static inline void *knav_dma_open_channel(struct device *dev, const char *name,
 static inline void knav_dma_close_channel(void *channel)
 {}
 
+static inline int knav_dma_get_flow(void *channel)
+{
+	return -EINVAL;
+}
+
+static inline bool knav_dma_device_ready(void)
+{
+	return false;
+}
+
 #endif
 
 #endif /* __SOC_TI_KEYSTONE_NAVIGATOR_DMA_H__ */
diff --git a/include/linux/soc/ti/knav_qmss.h b/include/linux/soc/ti/knav_qmss.h
index 9f0ebb3b..9745df6 100644
--- a/include/linux/soc/ti/knav_qmss.h
+++ b/include/linux/soc/ti/knav_qmss.h
@@ -86,5 +86,6 @@ int knav_pool_desc_map(void *ph, void *desc, unsigned size,
 void *knav_pool_desc_unmap(void *ph, dma_addr_t dma, unsigned dma_sz);
 dma_addr_t knav_pool_desc_virt_to_dma(void *ph, void *virt);
 void *knav_pool_desc_dma_to_virt(void *ph, dma_addr_t dma);
+bool knav_qmss_device_ready(void);
 
 #endif /* __SOC_TI_KNAV_QMSS_H__ */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 02/10] soc: ti: K2G: provide APIs to support driver probe deferral
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: linux-arm-kernel

This patch provide APIs to allow client drivers to support
probe deferral. On K2G SoC, devices can be probed only
after the ti_sci_pm_domains driver is probed and ready.
As drivers may get probed at different order, any driver
that depends on knav dma and qmss drivers, for example
netcp network driver, needs to defer probe until
knav devices are probed and ready to service. To do this,
add an API to query the device ready status from the knav
dma and qmss devices.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/soc/ti/knav_dma.c        |  8 ++++++++
 drivers/soc/ti/knav_qmss_queue.c |  8 ++++++++
 include/linux/soc/ti/knav_dma.h  | 12 ++++++++++++
 include/linux/soc/ti/knav_qmss.h |  1 +
 4 files changed, 29 insertions(+)

diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c
index 026182d..224d7dd 100644
--- a/drivers/soc/ti/knav_dma.c
+++ b/drivers/soc/ti/knav_dma.c
@@ -134,6 +134,13 @@ struct knav_dma_chan {
 
 static struct knav_dma_pool_device *kdev;
 
+static bool device_ready;
+bool knav_dma_device_ready(void)
+{
+	return device_ready;
+}
+EXPORT_SYMBOL_GPL(knav_dma_device_ready);
+
 static bool check_config(struct knav_dma_chan *chan, struct knav_dma_cfg *cfg)
 {
 	if (!memcmp(&chan->cfg, cfg, sizeof(*cfg)))
@@ -773,6 +780,7 @@ static int knav_dma_probe(struct platform_device *pdev)
 	debugfs_create_file("knav_dma", S_IFREG | S_IRUGO, NULL, NULL,
 			    &knav_dma_debug_ops);
 
+	device_ready = true;
 	return ret;
 }
 
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index 5b2c4e9..f0e67aa 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -74,6 +74,13 @@
  */
 const char *knav_acc_firmwares[] = {"ks2_qmss_pdsp_acc48.bin"};
 
+static bool device_ready;
+bool knav_qmss_device_ready(void)
+{
+	return device_ready;
+}
+EXPORT_SYMBOL_GPL(knav_qmss_device_ready);
+
 /**
  * knav_queue_notify: qmss queue notfier call
  *
@@ -1849,6 +1856,7 @@ static int knav_queue_probe(struct platform_device *pdev)
 
 	debugfs_create_file("qmss", S_IFREG | S_IRUGO, NULL, NULL,
 			    &knav_queue_debug_ops);
+	device_ready = true;
 	return 0;
 
 err:
diff --git a/include/linux/soc/ti/knav_dma.h b/include/linux/soc/ti/knav_dma.h
index 66693bc..7127ec3 100644
--- a/include/linux/soc/ti/knav_dma.h
+++ b/include/linux/soc/ti/knav_dma.h
@@ -167,6 +167,8 @@ struct knav_dma_desc {
 void *knav_dma_open_channel(struct device *dev, const char *name,
 				struct knav_dma_cfg *config);
 void knav_dma_close_channel(void *channel);
+int knav_dma_get_flow(void *channel);
+bool knav_dma_device_ready(void);
 #else
 static inline void *knav_dma_open_channel(struct device *dev, const char *name,
 				struct knav_dma_cfg *config)
@@ -176,6 +178,16 @@ static inline void *knav_dma_open_channel(struct device *dev, const char *name,
 static inline void knav_dma_close_channel(void *channel)
 {}
 
+static inline int knav_dma_get_flow(void *channel)
+{
+	return -EINVAL;
+}
+
+static inline bool knav_dma_device_ready(void)
+{
+	return false;
+}
+
 #endif
 
 #endif /* __SOC_TI_KEYSTONE_NAVIGATOR_DMA_H__ */
diff --git a/include/linux/soc/ti/knav_qmss.h b/include/linux/soc/ti/knav_qmss.h
index 9f0ebb3b..9745df6 100644
--- a/include/linux/soc/ti/knav_qmss.h
+++ b/include/linux/soc/ti/knav_qmss.h
@@ -86,5 +86,6 @@ int knav_pool_desc_map(void *ph, void *desc, unsigned size,
 void *knav_pool_desc_unmap(void *ph, dma_addr_t dma, unsigned dma_sz);
 dma_addr_t knav_pool_desc_virt_to_dma(void *ph, void *virt);
 void *knav_pool_desc_dma_to_virt(void *ph, dma_addr_t dma);
+bool knav_qmss_device_ready(void);
 
 #endif /* __SOC_TI_KNAV_QMSS_H__ */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
  2018-03-27 16:31 ` Murali Karicheri
  (?)
@ 2018-03-27 16:31   ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

As a preparatory patch to add support for 2u cpsw hardware found on
K2G SoC, make call to gbe_sgmii_config() conditional. This is required
since 2u uses RGMII interface instead of SGMII and to allow for driver
re-use.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 56dbc0b..1dea891 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
 
 	void (*hndlr)(struct net_device *) = gbe_adjust_link;
 
-	gbe_sgmii_config(priv, slave);
+	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
+		gbe_sgmii_config(priv, slave);
 	gbe_port_reset(slave);
 	gbe_sgmii_rtreset(priv, slave, false);
 	gbe_port_config(priv, slave, priv->rx_packet_max);
@@ -3039,7 +3040,9 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
 			continue;
 		}
 
-		gbe_sgmii_config(gbe_dev, slave);
+		if ((gbe_dev->ss_version == GBE_SS_VERSION_14) ||
+		    IS_SS_ID_NU(gbe_dev))
+			gbe_sgmii_config(gbe_dev, slave);
 		gbe_port_reset(slave);
 		gbe_port_config(gbe_dev, slave, gbe_dev->rx_packet_max);
 		list_add_tail(&slave->slave_list, &gbe_dev->secondary_slaves);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

As a preparatory patch to add support for 2u cpsw hardware found on
K2G SoC, make call to gbe_sgmii_config() conditional. This is required
since 2u uses RGMII interface instead of SGMII and to allow for driver
re-use.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 56dbc0b..1dea891 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
 
 	void (*hndlr)(struct net_device *) = gbe_adjust_link;
 
-	gbe_sgmii_config(priv, slave);
+	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
+		gbe_sgmii_config(priv, slave);
 	gbe_port_reset(slave);
 	gbe_sgmii_rtreset(priv, slave, false);
 	gbe_port_config(priv, slave, priv->rx_packet_max);
@@ -3039,7 +3040,9 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
 			continue;
 		}
 
-		gbe_sgmii_config(gbe_dev, slave);
+		if ((gbe_dev->ss_version == GBE_SS_VERSION_14) ||
+		    IS_SS_ID_NU(gbe_dev))
+			gbe_sgmii_config(gbe_dev, slave);
 		gbe_port_reset(slave);
 		gbe_port_config(gbe_dev, slave, gbe_dev->rx_packet_max);
 		list_add_tail(&slave->slave_list, &gbe_dev->secondary_slaves);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: linux-arm-kernel

As a preparatory patch to add support for 2u cpsw hardware found on
K2G SoC, make call to gbe_sgmii_config() conditional. This is required
since 2u uses RGMII interface instead of SGMII and to allow for driver
re-use.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 56dbc0b..1dea891 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
 
 	void (*hndlr)(struct net_device *) = gbe_adjust_link;
 
-	gbe_sgmii_config(priv, slave);
+	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
+		gbe_sgmii_config(priv, slave);
 	gbe_port_reset(slave);
 	gbe_sgmii_rtreset(priv, slave, false);
 	gbe_port_config(priv, slave, priv->rx_packet_max);
@@ -3039,7 +3040,9 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
 			continue;
 		}
 
-		gbe_sgmii_config(gbe_dev, slave);
+		if ((gbe_dev->ss_version == GBE_SS_VERSION_14) ||
+		    IS_SS_ID_NU(gbe_dev))
+			gbe_sgmii_config(gbe_dev, slave);
 		gbe_port_reset(slave);
 		gbe_port_config(gbe_dev, slave, gbe_dev->rx_packet_max);
 		list_add_tail(&slave->slave_list, &gbe_dev->secondary_slaves);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 04/10] net: netcp: ethss: add support for handling sgmii link interface
  2018-03-27 16:31 ` Murali Karicheri
  (?)
@ 2018-03-27 16:31   ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

2u cpsw hardware on K2G uses sgmii link to interface with Phy. So add
support for this interface in the code so that drover can be re-used
for 2u hardware.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp.h       |  2 ++
 drivers/net/ethernet/ti/netcp_ethss.c | 18 ++++++++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp.h b/drivers/net/ethernet/ti/netcp.h
index 8900a6f..416f732 100644
--- a/drivers/net/ethernet/ti/netcp.h
+++ b/drivers/net/ethernet/ti/netcp.h
@@ -33,6 +33,8 @@
 #define SGMII_LINK_MAC_MAC_FORCED	2
 #define SGMII_LINK_MAC_FIBER		3
 #define SGMII_LINK_MAC_PHY_NO_MDIO	4
+#define RGMII_LINK_MAC_PHY		5
+#define RGMII_LINK_MAC_PHY_NO_MDIO	7
 #define XGMII_LINK_MAC_PHY		10
 #define XGMII_LINK_MAC_MAC_FORCED	11
 
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 1dea891..ab9d369 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -166,6 +166,9 @@
 #define	GBE_RXHOOK_ORDER			0
 #define GBE_DEFAULT_ALE_AGEOUT			30
 #define SLAVE_LINK_IS_XGMII(s) ((s)->link_interface >= XGMII_LINK_MAC_PHY)
+#define SLAVE_LINK_IS_RGMII(s) \
+	(((s)->link_interface >= RGMII_LINK_MAC_PHY) && \
+	 ((s)->link_interface <= RGMII_LINK_MAC_PHY_NO_MDIO))
 #define NETCP_LINK_STATE_INVALID		-1
 
 #define GBE_SET_REG_OFS(p, rb, rn) p->rb##_ofs.rn = \
@@ -2091,8 +2094,9 @@ static void netcp_ethss_link_state_action(struct gbe_priv *gbe_dev,
 				     ALE_PORT_STATE_FORWARD);
 
 		if (ndev && slave->open &&
-		    slave->link_interface != SGMII_LINK_MAC_PHY &&
-		    slave->link_interface != XGMII_LINK_MAC_PHY)
+		    ((slave->link_interface != SGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != RGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != XGMII_LINK_MAC_PHY)))
 			netif_carrier_on(ndev);
 	} else {
 		writel(mac_control, GBE_REG_ADDR(slave, emac_regs,
@@ -2101,8 +2105,9 @@ static void netcp_ethss_link_state_action(struct gbe_priv *gbe_dev,
 				     ALE_PORT_STATE,
 				     ALE_PORT_STATE_DISABLE);
 		if (ndev &&
-		    slave->link_interface != SGMII_LINK_MAC_PHY &&
-		    slave->link_interface != XGMII_LINK_MAC_PHY)
+		    ((slave->link_interface != SGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != RGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != XGMII_LINK_MAC_PHY)))
 			netif_carrier_off(ndev);
 	}
 
@@ -2914,6 +2919,7 @@ static int init_slave(struct gbe_priv *gbe_dev, struct gbe_slave *slave,
 
 	slave->open = false;
 	if ((slave->link_interface == SGMII_LINK_MAC_PHY) ||
+	    (slave->link_interface == RGMII_LINK_MAC_PHY) ||
 	    (slave->link_interface == XGMII_LINK_MAC_PHY))
 		slave->phy_node = of_parse_phandle(node, "phy-handle", 0);
 	slave->port_num = gbe_get_slave_port(gbe_dev, slave->slave_num);
@@ -3076,6 +3082,9 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
 	if (slave->link_interface == SGMII_LINK_MAC_PHY) {
 		phy_mode = PHY_INTERFACE_MODE_SGMII;
 		slave->phy_port_t = PORT_MII;
+	} else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
+		phy_mode = PHY_INTERFACE_MODE_RGMII;
+		slave->phy_port_t = PORT_MII;
 	} else {
 		phy_mode = PHY_INTERFACE_MODE_NA;
 		slave->phy_port_t = PORT_FIBRE;
@@ -3083,6 +3092,7 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
 
 	for_each_sec_slave(slave, gbe_dev) {
 		if ((slave->link_interface != SGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != RGMII_LINK_MAC_PHY) &&
 		    (slave->link_interface != XGMII_LINK_MAC_PHY))
 			continue;
 		slave->phy =
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 04/10] net: netcp: ethss: add support for handling sgmii link interface
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

2u cpsw hardware on K2G uses sgmii link to interface with Phy. So add
support for this interface in the code so that drover can be re-used
for 2u hardware.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp.h       |  2 ++
 drivers/net/ethernet/ti/netcp_ethss.c | 18 ++++++++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp.h b/drivers/net/ethernet/ti/netcp.h
index 8900a6f..416f732 100644
--- a/drivers/net/ethernet/ti/netcp.h
+++ b/drivers/net/ethernet/ti/netcp.h
@@ -33,6 +33,8 @@
 #define SGMII_LINK_MAC_MAC_FORCED	2
 #define SGMII_LINK_MAC_FIBER		3
 #define SGMII_LINK_MAC_PHY_NO_MDIO	4
+#define RGMII_LINK_MAC_PHY		5
+#define RGMII_LINK_MAC_PHY_NO_MDIO	7
 #define XGMII_LINK_MAC_PHY		10
 #define XGMII_LINK_MAC_MAC_FORCED	11
 
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 1dea891..ab9d369 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -166,6 +166,9 @@
 #define	GBE_RXHOOK_ORDER			0
 #define GBE_DEFAULT_ALE_AGEOUT			30
 #define SLAVE_LINK_IS_XGMII(s) ((s)->link_interface >= XGMII_LINK_MAC_PHY)
+#define SLAVE_LINK_IS_RGMII(s) \
+	(((s)->link_interface >= RGMII_LINK_MAC_PHY) && \
+	 ((s)->link_interface <= RGMII_LINK_MAC_PHY_NO_MDIO))
 #define NETCP_LINK_STATE_INVALID		-1
 
 #define GBE_SET_REG_OFS(p, rb, rn) p->rb##_ofs.rn = \
@@ -2091,8 +2094,9 @@ static void netcp_ethss_link_state_action(struct gbe_priv *gbe_dev,
 				     ALE_PORT_STATE_FORWARD);
 
 		if (ndev && slave->open &&
-		    slave->link_interface != SGMII_LINK_MAC_PHY &&
-		    slave->link_interface != XGMII_LINK_MAC_PHY)
+		    ((slave->link_interface != SGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != RGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != XGMII_LINK_MAC_PHY)))
 			netif_carrier_on(ndev);
 	} else {
 		writel(mac_control, GBE_REG_ADDR(slave, emac_regs,
@@ -2101,8 +2105,9 @@ static void netcp_ethss_link_state_action(struct gbe_priv *gbe_dev,
 				     ALE_PORT_STATE,
 				     ALE_PORT_STATE_DISABLE);
 		if (ndev &&
-		    slave->link_interface != SGMII_LINK_MAC_PHY &&
-		    slave->link_interface != XGMII_LINK_MAC_PHY)
+		    ((slave->link_interface != SGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != RGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != XGMII_LINK_MAC_PHY)))
 			netif_carrier_off(ndev);
 	}
 
@@ -2914,6 +2919,7 @@ static int init_slave(struct gbe_priv *gbe_dev, struct gbe_slave *slave,
 
 	slave->open = false;
 	if ((slave->link_interface == SGMII_LINK_MAC_PHY) ||
+	    (slave->link_interface == RGMII_LINK_MAC_PHY) ||
 	    (slave->link_interface == XGMII_LINK_MAC_PHY))
 		slave->phy_node = of_parse_phandle(node, "phy-handle", 0);
 	slave->port_num = gbe_get_slave_port(gbe_dev, slave->slave_num);
@@ -3076,6 +3082,9 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
 	if (slave->link_interface == SGMII_LINK_MAC_PHY) {
 		phy_mode = PHY_INTERFACE_MODE_SGMII;
 		slave->phy_port_t = PORT_MII;
+	} else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
+		phy_mode = PHY_INTERFACE_MODE_RGMII;
+		slave->phy_port_t = PORT_MII;
 	} else {
 		phy_mode = PHY_INTERFACE_MODE_NA;
 		slave->phy_port_t = PORT_FIBRE;
@@ -3083,6 +3092,7 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
 
 	for_each_sec_slave(slave, gbe_dev) {
 		if ((slave->link_interface != SGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != RGMII_LINK_MAC_PHY) &&
 		    (slave->link_interface != XGMII_LINK_MAC_PHY))
 			continue;
 		slave->phy =
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 04/10] net: netcp: ethss: add support for handling sgmii link interface
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: linux-arm-kernel

2u cpsw hardware on K2G uses sgmii link to interface with Phy. So add
support for this interface in the code so that drover can be re-used
for 2u hardware.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp.h       |  2 ++
 drivers/net/ethernet/ti/netcp_ethss.c | 18 ++++++++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp.h b/drivers/net/ethernet/ti/netcp.h
index 8900a6f..416f732 100644
--- a/drivers/net/ethernet/ti/netcp.h
+++ b/drivers/net/ethernet/ti/netcp.h
@@ -33,6 +33,8 @@
 #define SGMII_LINK_MAC_MAC_FORCED	2
 #define SGMII_LINK_MAC_FIBER		3
 #define SGMII_LINK_MAC_PHY_NO_MDIO	4
+#define RGMII_LINK_MAC_PHY		5
+#define RGMII_LINK_MAC_PHY_NO_MDIO	7
 #define XGMII_LINK_MAC_PHY		10
 #define XGMII_LINK_MAC_MAC_FORCED	11
 
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 1dea891..ab9d369 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -166,6 +166,9 @@
 #define	GBE_RXHOOK_ORDER			0
 #define GBE_DEFAULT_ALE_AGEOUT			30
 #define SLAVE_LINK_IS_XGMII(s) ((s)->link_interface >= XGMII_LINK_MAC_PHY)
+#define SLAVE_LINK_IS_RGMII(s) \
+	(((s)->link_interface >= RGMII_LINK_MAC_PHY) && \
+	 ((s)->link_interface <= RGMII_LINK_MAC_PHY_NO_MDIO))
 #define NETCP_LINK_STATE_INVALID		-1
 
 #define GBE_SET_REG_OFS(p, rb, rn) p->rb##_ofs.rn = \
@@ -2091,8 +2094,9 @@ static void netcp_ethss_link_state_action(struct gbe_priv *gbe_dev,
 				     ALE_PORT_STATE_FORWARD);
 
 		if (ndev && slave->open &&
-		    slave->link_interface != SGMII_LINK_MAC_PHY &&
-		    slave->link_interface != XGMII_LINK_MAC_PHY)
+		    ((slave->link_interface != SGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != RGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != XGMII_LINK_MAC_PHY)))
 			netif_carrier_on(ndev);
 	} else {
 		writel(mac_control, GBE_REG_ADDR(slave, emac_regs,
@@ -2101,8 +2105,9 @@ static void netcp_ethss_link_state_action(struct gbe_priv *gbe_dev,
 				     ALE_PORT_STATE,
 				     ALE_PORT_STATE_DISABLE);
 		if (ndev &&
-		    slave->link_interface != SGMII_LINK_MAC_PHY &&
-		    slave->link_interface != XGMII_LINK_MAC_PHY)
+		    ((slave->link_interface != SGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != RGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != XGMII_LINK_MAC_PHY)))
 			netif_carrier_off(ndev);
 	}
 
@@ -2914,6 +2919,7 @@ static int init_slave(struct gbe_priv *gbe_dev, struct gbe_slave *slave,
 
 	slave->open = false;
 	if ((slave->link_interface == SGMII_LINK_MAC_PHY) ||
+	    (slave->link_interface == RGMII_LINK_MAC_PHY) ||
 	    (slave->link_interface == XGMII_LINK_MAC_PHY))
 		slave->phy_node = of_parse_phandle(node, "phy-handle", 0);
 	slave->port_num = gbe_get_slave_port(gbe_dev, slave->slave_num);
@@ -3076,6 +3082,9 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
 	if (slave->link_interface == SGMII_LINK_MAC_PHY) {
 		phy_mode = PHY_INTERFACE_MODE_SGMII;
 		slave->phy_port_t = PORT_MII;
+	} else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
+		phy_mode = PHY_INTERFACE_MODE_RGMII;
+		slave->phy_port_t = PORT_MII;
 	} else {
 		phy_mode = PHY_INTERFACE_MODE_NA;
 		slave->phy_port_t = PORT_FIBRE;
@@ -3083,6 +3092,7 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
 
 	for_each_sec_slave(slave, gbe_dev) {
 		if ((slave->link_interface != SGMII_LINK_MAC_PHY) &&
+		    (slave->link_interface != RGMII_LINK_MAC_PHY) &&
 		    (slave->link_interface != XGMII_LINK_MAC_PHY))
 			continue;
 		slave->phy =
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 05/10] net: netcp: ethss: use rgmii link status for 2u cpsw hardware
  2018-03-27 16:31 ` Murali Karicheri
  (?)
@ 2018-03-27 16:31   ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

Introduce rgmii link status to handle link state events for 2u
cpsw hardware on K2G.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index ab9d369..078a1b8 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -552,6 +552,7 @@ struct gbe_ss_regs {
 struct gbe_ss_regs_ofs {
 	u16	id_ver;
 	u16	control;
+	u16	rgmii_status; /* 2U */
 };
 
 struct gbe_switch_regs {
@@ -2120,23 +2121,39 @@ static bool gbe_phy_link_status(struct gbe_slave *slave)
 	 return !slave->phy || slave->phy->link;
 }
 
+#define RGMII_REG_STATUS_LINK	BIT(0)
+
+static void netcp_2u_rgmii_get_port_link(struct gbe_priv *gbe_dev, bool *status)
+{
+	u32 val = 0;
+
+	val = readl(GBE_REG_ADDR(gbe_dev, ss_regs, rgmii_status));
+	*status = false;
+	if ((val & RGMII_REG_STATUS_LINK) != 0)
+		*status = true;
+}
+
 static void netcp_ethss_update_link_state(struct gbe_priv *gbe_dev,
 					  struct gbe_slave *slave,
 					  struct net_device *ndev)
 {
-	int sp = slave->slave_num;
-	int phy_link_state, sgmii_link_state = 1, link_state;
+	bool sw_link_state = true, phy_link_state;
+	int sp = slave->slave_num, link_state;
 
 	if (!slave->open)
 		return;
 
 	if (!SLAVE_LINK_IS_XGMII(slave)) {
-		sgmii_link_state =
+		if (SLAVE_LINK_IS_RGMII(slave))
+			netcp_2u_rgmii_get_port_link(gbe_dev,
+						     &sw_link_state);
+		else
+			sw_link_state =
 			netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);
 	}
 
 	phy_link_state = gbe_phy_link_status(slave);
-	link_state = phy_link_state & sgmii_link_state;
+	link_state = phy_link_state & sw_link_state;
 
 	if (atomic_xchg(&slave->link_state, link_state) != link_state)
 		netcp_ethss_link_state_action(gbe_dev, ndev, slave,
@@ -3432,6 +3449,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
 
 	/* Subsystem registers */
 	GBENU_SET_REG_OFS(gbe_dev, ss_regs, id_ver);
+	/* ok to set for MU, but used by 2U only */
+	GBENU_SET_REG_OFS(gbe_dev, ss_regs, rgmii_status);
 
 	/* Switch module registers */
 	GBENU_SET_REG_OFS(gbe_dev, switch_regs, id_ver);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 05/10] net: netcp: ethss: use rgmii link status for 2u cpsw hardware
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

Introduce rgmii link status to handle link state events for 2u
cpsw hardware on K2G.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index ab9d369..078a1b8 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -552,6 +552,7 @@ struct gbe_ss_regs {
 struct gbe_ss_regs_ofs {
 	u16	id_ver;
 	u16	control;
+	u16	rgmii_status; /* 2U */
 };
 
 struct gbe_switch_regs {
@@ -2120,23 +2121,39 @@ static bool gbe_phy_link_status(struct gbe_slave *slave)
 	 return !slave->phy || slave->phy->link;
 }
 
+#define RGMII_REG_STATUS_LINK	BIT(0)
+
+static void netcp_2u_rgmii_get_port_link(struct gbe_priv *gbe_dev, bool *status)
+{
+	u32 val = 0;
+
+	val = readl(GBE_REG_ADDR(gbe_dev, ss_regs, rgmii_status));
+	*status = false;
+	if ((val & RGMII_REG_STATUS_LINK) != 0)
+		*status = true;
+}
+
 static void netcp_ethss_update_link_state(struct gbe_priv *gbe_dev,
 					  struct gbe_slave *slave,
 					  struct net_device *ndev)
 {
-	int sp = slave->slave_num;
-	int phy_link_state, sgmii_link_state = 1, link_state;
+	bool sw_link_state = true, phy_link_state;
+	int sp = slave->slave_num, link_state;
 
 	if (!slave->open)
 		return;
 
 	if (!SLAVE_LINK_IS_XGMII(slave)) {
-		sgmii_link_state =
+		if (SLAVE_LINK_IS_RGMII(slave))
+			netcp_2u_rgmii_get_port_link(gbe_dev,
+						     &sw_link_state);
+		else
+			sw_link_state =
 			netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);
 	}
 
 	phy_link_state = gbe_phy_link_status(slave);
-	link_state = phy_link_state & sgmii_link_state;
+	link_state = phy_link_state & sw_link_state;
 
 	if (atomic_xchg(&slave->link_state, link_state) != link_state)
 		netcp_ethss_link_state_action(gbe_dev, ndev, slave,
@@ -3432,6 +3449,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
 
 	/* Subsystem registers */
 	GBENU_SET_REG_OFS(gbe_dev, ss_regs, id_ver);
+	/* ok to set for MU, but used by 2U only */
+	GBENU_SET_REG_OFS(gbe_dev, ss_regs, rgmii_status);
 
 	/* Switch module registers */
 	GBENU_SET_REG_OFS(gbe_dev, switch_regs, id_ver);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 05/10] net: netcp: ethss: use rgmii link status for 2u cpsw hardware
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: linux-arm-kernel

Introduce rgmii link status to handle link state events for 2u
cpsw hardware on K2G.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index ab9d369..078a1b8 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -552,6 +552,7 @@ struct gbe_ss_regs {
 struct gbe_ss_regs_ofs {
 	u16	id_ver;
 	u16	control;
+	u16	rgmii_status; /* 2U */
 };
 
 struct gbe_switch_regs {
@@ -2120,23 +2121,39 @@ static bool gbe_phy_link_status(struct gbe_slave *slave)
 	 return !slave->phy || slave->phy->link;
 }
 
+#define RGMII_REG_STATUS_LINK	BIT(0)
+
+static void netcp_2u_rgmii_get_port_link(struct gbe_priv *gbe_dev, bool *status)
+{
+	u32 val = 0;
+
+	val = readl(GBE_REG_ADDR(gbe_dev, ss_regs, rgmii_status));
+	*status = false;
+	if ((val & RGMII_REG_STATUS_LINK) != 0)
+		*status = true;
+}
+
 static void netcp_ethss_update_link_state(struct gbe_priv *gbe_dev,
 					  struct gbe_slave *slave,
 					  struct net_device *ndev)
 {
-	int sp = slave->slave_num;
-	int phy_link_state, sgmii_link_state = 1, link_state;
+	bool sw_link_state = true, phy_link_state;
+	int sp = slave->slave_num, link_state;
 
 	if (!slave->open)
 		return;
 
 	if (!SLAVE_LINK_IS_XGMII(slave)) {
-		sgmii_link_state =
+		if (SLAVE_LINK_IS_RGMII(slave))
+			netcp_2u_rgmii_get_port_link(gbe_dev,
+						     &sw_link_state);
+		else
+			sw_link_state =
 			netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);
 	}
 
 	phy_link_state = gbe_phy_link_status(slave);
-	link_state = phy_link_state & sgmii_link_state;
+	link_state = phy_link_state & sw_link_state;
 
 	if (atomic_xchg(&slave->link_state, link_state) != link_state)
 		netcp_ethss_link_state_action(gbe_dev, ndev, slave,
@@ -3432,6 +3449,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
 
 	/* Subsystem registers */
 	GBENU_SET_REG_OFS(gbe_dev, ss_regs, id_ver);
+	/* ok to set for MU, but used by 2U only */
+	GBENU_SET_REG_OFS(gbe_dev, ss_regs, rgmii_status);
 
 	/* Switch module registers */
 	GBENU_SET_REG_OFS(gbe_dev, switch_regs, id_ver);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 06/10] net: netcp: ethss: map vlan priorities to zero flow
  2018-03-27 16:31 ` Murali Karicheri
  (?)
@ 2018-03-27 16:31   ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

The driver currently support only vlan priority zero. So map the
vlan priorities to zero flow in hardware.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 078a1b8..828243d 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -595,6 +595,7 @@ struct gbe_port_regs {
 struct gbe_port_regs_ofs {
 	u16	port_vlan;
 	u16	tx_pri_map;
+	u16     rx_pri_map;
 	u16	sa_lo;
 	u16	sa_hi;
 	u16	ts_ctl;
@@ -2299,6 +2300,13 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
 	gbe_sgmii_rtreset(priv, slave, false);
 	gbe_port_config(priv, slave, priv->rx_packet_max);
 	gbe_set_slave_mac(slave, gbe_intf);
+	/* For NU & 2U switch, map the vlan priorities to zero
+	 * as we only configure to use priority 0
+	 */
+	if (IS_SS_ID_MU(priv))
+		writel(HOST_TX_PRI_MAP_DEFAULT,
+		       GBE_REG_ADDR(slave, port_regs, rx_pri_map));
+
 	/* enable forwarding */
 	cpsw_ale_control_set(priv->ale, slave->port_num,
 			     ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);
@@ -3000,6 +3008,7 @@ static int init_slave(struct gbe_priv *gbe_dev, struct gbe_slave *slave,
 		/* Initialize  slave port register offsets */
 		GBENU_SET_REG_OFS(slave, port_regs, port_vlan);
 		GBENU_SET_REG_OFS(slave, port_regs, tx_pri_map);
+		GBENU_SET_REG_OFS(slave, port_regs, rx_pri_map);
 		GBENU_SET_REG_OFS(slave, port_regs, sa_lo);
 		GBENU_SET_REG_OFS(slave, port_regs, sa_hi);
 		GBENU_SET_REG_OFS(slave, port_regs, ts_ctl);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 06/10] net: netcp: ethss: map vlan priorities to zero flow
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

The driver currently support only vlan priority zero. So map the
vlan priorities to zero flow in hardware.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 078a1b8..828243d 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -595,6 +595,7 @@ struct gbe_port_regs {
 struct gbe_port_regs_ofs {
 	u16	port_vlan;
 	u16	tx_pri_map;
+	u16     rx_pri_map;
 	u16	sa_lo;
 	u16	sa_hi;
 	u16	ts_ctl;
@@ -2299,6 +2300,13 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
 	gbe_sgmii_rtreset(priv, slave, false);
 	gbe_port_config(priv, slave, priv->rx_packet_max);
 	gbe_set_slave_mac(slave, gbe_intf);
+	/* For NU & 2U switch, map the vlan priorities to zero
+	 * as we only configure to use priority 0
+	 */
+	if (IS_SS_ID_MU(priv))
+		writel(HOST_TX_PRI_MAP_DEFAULT,
+		       GBE_REG_ADDR(slave, port_regs, rx_pri_map));
+
 	/* enable forwarding */
 	cpsw_ale_control_set(priv->ale, slave->port_num,
 			     ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);
@@ -3000,6 +3008,7 @@ static int init_slave(struct gbe_priv *gbe_dev, struct gbe_slave *slave,
 		/* Initialize  slave port register offsets */
 		GBENU_SET_REG_OFS(slave, port_regs, port_vlan);
 		GBENU_SET_REG_OFS(slave, port_regs, tx_pri_map);
+		GBENU_SET_REG_OFS(slave, port_regs, rx_pri_map);
 		GBENU_SET_REG_OFS(slave, port_regs, sa_lo);
 		GBENU_SET_REG_OFS(slave, port_regs, sa_hi);
 		GBENU_SET_REG_OFS(slave, port_regs, ts_ctl);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 06/10] net: netcp: ethss: map vlan priorities to zero flow
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: linux-arm-kernel

The driver currently support only vlan priority zero. So map the
vlan priorities to zero flow in hardware.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 078a1b8..828243d 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -595,6 +595,7 @@ struct gbe_port_regs {
 struct gbe_port_regs_ofs {
 	u16	port_vlan;
 	u16	tx_pri_map;
+	u16     rx_pri_map;
 	u16	sa_lo;
 	u16	sa_hi;
 	u16	ts_ctl;
@@ -2299,6 +2300,13 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
 	gbe_sgmii_rtreset(priv, slave, false);
 	gbe_port_config(priv, slave, priv->rx_packet_max);
 	gbe_set_slave_mac(slave, gbe_intf);
+	/* For NU & 2U switch, map the vlan priorities to zero
+	 * as we only configure to use priority 0
+	 */
+	if (IS_SS_ID_MU(priv))
+		writel(HOST_TX_PRI_MAP_DEFAULT,
+		       GBE_REG_ADDR(slave, port_regs, rx_pri_map));
+
 	/* enable forwarding */
 	cpsw_ale_control_set(priv->ale, slave->port_num,
 			     ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);
@@ -3000,6 +3008,7 @@ static int init_slave(struct gbe_priv *gbe_dev, struct gbe_slave *slave,
 		/* Initialize  slave port register offsets */
 		GBENU_SET_REG_OFS(slave, port_regs, port_vlan);
 		GBENU_SET_REG_OFS(slave, port_regs, tx_pri_map);
+		GBENU_SET_REG_OFS(slave, port_regs, rx_pri_map);
 		GBENU_SET_REG_OFS(slave, port_regs, sa_lo);
 		GBENU_SET_REG_OFS(slave, port_regs, sa_hi);
 		GBENU_SET_REG_OFS(slave, port_regs, ts_ctl);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 07/10] net: netcp: ethss: re-use stats handling code for 2u hardware
  2018-03-27 16:31 ` Murali Karicheri
  (?)
@ 2018-03-27 16:31   ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

The stats block in 2u cpsw hardware is similar to the one on nu
and hence handle it in a similar way by using a macro that includes
2u hardware as well.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 828243d..26ccddb 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -3394,7 +3394,7 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
 	gbe_dev->num_stats_mods = gbe_dev->max_num_ports;
 	gbe_dev->et_stats = gbenu_et_stats;
 
-	if (IS_SS_ID_NU(gbe_dev))
+	if (IS_SS_ID_MU(gbe_dev))
 		gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
 			(gbe_dev->max_num_slaves * GBENU_ET_STATS_PORT_SIZE);
 	else
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 07/10] net: netcp: ethss: re-use stats handling code for 2u hardware
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

The stats block in 2u cpsw hardware is similar to the one on nu
and hence handle it in a similar way by using a macro that includes
2u hardware as well.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 828243d..26ccddb 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -3394,7 +3394,7 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
 	gbe_dev->num_stats_mods = gbe_dev->max_num_ports;
 	gbe_dev->et_stats = gbenu_et_stats;
 
-	if (IS_SS_ID_NU(gbe_dev))
+	if (IS_SS_ID_MU(gbe_dev))
 		gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
 			(gbe_dev->max_num_slaves * GBENU_ET_STATS_PORT_SIZE);
 	else
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 07/10] net: netcp: ethss: re-use stats handling code for 2u hardware
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: linux-arm-kernel

The stats block in 2u cpsw hardware is similar to the one on nu
and hence handle it in a similar way by using a macro that includes
2u hardware as well.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 828243d..26ccddb 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -3394,7 +3394,7 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
 	gbe_dev->num_stats_mods = gbe_dev->max_num_ports;
 	gbe_dev->et_stats = gbenu_et_stats;
 
-	if (IS_SS_ID_NU(gbe_dev))
+	if (IS_SS_ID_MU(gbe_dev))
 		gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
 			(gbe_dev->max_num_slaves * GBENU_ET_STATS_PORT_SIZE);
 	else
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 08/10] net: netcp: ethss: use of_get_phy_mode() to support different RGMII modes
  2018-03-27 16:31 ` Murali Karicheri
  (?)
@ 2018-03-27 16:31   ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

The phy used for K2G allows for internal delays to be added optionally
to the clock circuitry based on board desing. To add this support,
enhance the driver to use of_get_phy_mode() to read the phy-mode from
the phy device and pass the same to phy through of_phy_connect().

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 26ccddb..df163ec 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -21,6 +21,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of_mdio.h>
+#include <linux/of_net.h>
 #include <linux/of_address.h>
 #include <linux/if_vlan.h>
 #include <linux/ptp_classify.h>
@@ -700,6 +701,7 @@ struct gbe_slave {
 	u32				link_interface;
 	u32				mac_control;
 	u8				phy_port_t;
+	struct device_node		*node;
 	struct device_node		*phy_node;
 	struct ts_ctl                   ts_ctl;
 	struct list_head		slave_list;
@@ -2317,6 +2319,15 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
 		has_phy = true;
 		phy_mode = PHY_INTERFACE_MODE_SGMII;
 		slave->phy_port_t = PORT_MII;
+	} else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
+		has_phy = true;
+		phy_mode = of_get_phy_mode(slave->node);
+		/* if phy-mode is not present, default to
+		 * PHY_INTERFACE_MODE_RGMII
+		 */
+		if (phy_mode < 0)
+			phy_mode = PHY_INTERFACE_MODE_RGMII;
+		slave->phy_port_t = PORT_MII;
 	} else if (slave->link_interface == XGMII_LINK_MAC_PHY) {
 		has_phy = true;
 		phy_mode = PHY_INTERFACE_MODE_NA;
@@ -2942,6 +2953,7 @@ static int init_slave(struct gbe_priv *gbe_dev, struct gbe_slave *slave,
 		slave->link_interface = SGMII_LINK_MAC_PHY;
 	}
 
+	slave->node = node;
 	slave->open = false;
 	if ((slave->link_interface == SGMII_LINK_MAC_PHY) ||
 	    (slave->link_interface == RGMII_LINK_MAC_PHY) ||
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 08/10] net: netcp: ethss: use of_get_phy_mode() to support different RGMII modes
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

The phy used for K2G allows for internal delays to be added optionally
to the clock circuitry based on board desing. To add this support,
enhance the driver to use of_get_phy_mode() to read the phy-mode from
the phy device and pass the same to phy through of_phy_connect().

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 26ccddb..df163ec 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -21,6 +21,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of_mdio.h>
+#include <linux/of_net.h>
 #include <linux/of_address.h>
 #include <linux/if_vlan.h>
 #include <linux/ptp_classify.h>
@@ -700,6 +701,7 @@ struct gbe_slave {
 	u32				link_interface;
 	u32				mac_control;
 	u8				phy_port_t;
+	struct device_node		*node;
 	struct device_node		*phy_node;
 	struct ts_ctl                   ts_ctl;
 	struct list_head		slave_list;
@@ -2317,6 +2319,15 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
 		has_phy = true;
 		phy_mode = PHY_INTERFACE_MODE_SGMII;
 		slave->phy_port_t = PORT_MII;
+	} else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
+		has_phy = true;
+		phy_mode = of_get_phy_mode(slave->node);
+		/* if phy-mode is not present, default to
+		 * PHY_INTERFACE_MODE_RGMII
+		 */
+		if (phy_mode < 0)
+			phy_mode = PHY_INTERFACE_MODE_RGMII;
+		slave->phy_port_t = PORT_MII;
 	} else if (slave->link_interface == XGMII_LINK_MAC_PHY) {
 		has_phy = true;
 		phy_mode = PHY_INTERFACE_MODE_NA;
@@ -2942,6 +2953,7 @@ static int init_slave(struct gbe_priv *gbe_dev, struct gbe_slave *slave,
 		slave->link_interface = SGMII_LINK_MAC_PHY;
 	}
 
+	slave->node = node;
 	slave->open = false;
 	if ((slave->link_interface == SGMII_LINK_MAC_PHY) ||
 	    (slave->link_interface == RGMII_LINK_MAC_PHY) ||
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 08/10] net: netcp: ethss: use of_get_phy_mode() to support different RGMII modes
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: linux-arm-kernel

The phy used for K2G allows for internal delays to be added optionally
to the clock circuitry based on board desing. To add this support,
enhance the driver to use of_get_phy_mode() to read the phy-mode from
the phy device and pass the same to phy through of_phy_connect().

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 26ccddb..df163ec 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -21,6 +21,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of_mdio.h>
+#include <linux/of_net.h>
 #include <linux/of_address.h>
 #include <linux/if_vlan.h>
 #include <linux/ptp_classify.h>
@@ -700,6 +701,7 @@ struct gbe_slave {
 	u32				link_interface;
 	u32				mac_control;
 	u8				phy_port_t;
+	struct device_node		*node;
 	struct device_node		*phy_node;
 	struct ts_ctl                   ts_ctl;
 	struct list_head		slave_list;
@@ -2317,6 +2319,15 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
 		has_phy = true;
 		phy_mode = PHY_INTERFACE_MODE_SGMII;
 		slave->phy_port_t = PORT_MII;
+	} else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
+		has_phy = true;
+		phy_mode = of_get_phy_mode(slave->node);
+		/* if phy-mode is not present, default to
+		 * PHY_INTERFACE_MODE_RGMII
+		 */
+		if (phy_mode < 0)
+			phy_mode = PHY_INTERFACE_MODE_RGMII;
+		slave->phy_port_t = PORT_MII;
 	} else if (slave->link_interface == XGMII_LINK_MAC_PHY) {
 		has_phy = true;
 		phy_mode = PHY_INTERFACE_MODE_NA;
@@ -2942,6 +2953,7 @@ static int init_slave(struct gbe_priv *gbe_dev, struct gbe_slave *slave,
 		slave->link_interface = SGMII_LINK_MAC_PHY;
 	}
 
+	slave->node = node;
 	slave->open = false;
 	if ((slave->link_interface == SGMII_LINK_MAC_PHY) ||
 	    (slave->link_interface == RGMII_LINK_MAC_PHY) ||
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 09/10] Revert "net: netcp: remove dead code from the driver"
  2018-03-27 16:31 ` Murali Karicheri
  (?)
@ 2018-03-27 16:31   ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

As the probe sequence is not guaranteed contrary to the assumption
of the commit 2d8e276a9030, same has to be reverted.

commit 2d8e276a9030 ("net: netcp: remove dead code from the driver")

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index f5a7eb2..9c51b25 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -2155,6 +2155,7 @@ static int netcp_probe(struct platform_device *pdev)
 	struct device_node *child, *interfaces;
 	struct netcp_device *netcp_device;
 	struct device *dev = &pdev->dev;
+	struct netcp_module *module;
 	int ret;
 
 	if (!node) {
@@ -2203,6 +2204,14 @@ static int netcp_probe(struct platform_device *pdev)
 	/* Add the device instance to the list */
 	list_add_tail(&netcp_device->device_list, &netcp_devices);
 
+	/* Probe & attach any modules already registered */
+	mutex_lock(&netcp_modules_lock);
+	for_each_netcp_module(module) {
+		ret = netcp_module_probe(netcp_device, module);
+		if (ret < 0)
+			dev_err(dev, "module(%s) probe failed\n", module->name);
+	}
+	mutex_unlock(&netcp_modules_lock);
 	return 0;
 
 probe_quit_interface:
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 09/10] Revert "net: netcp: remove dead code from the driver"
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

As the probe sequence is not guaranteed contrary to the assumption
of the commit 2d8e276a9030, same has to be reverted.

commit 2d8e276a9030 ("net: netcp: remove dead code from the driver")

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index f5a7eb2..9c51b25 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -2155,6 +2155,7 @@ static int netcp_probe(struct platform_device *pdev)
 	struct device_node *child, *interfaces;
 	struct netcp_device *netcp_device;
 	struct device *dev = &pdev->dev;
+	struct netcp_module *module;
 	int ret;
 
 	if (!node) {
@@ -2203,6 +2204,14 @@ static int netcp_probe(struct platform_device *pdev)
 	/* Add the device instance to the list */
 	list_add_tail(&netcp_device->device_list, &netcp_devices);
 
+	/* Probe & attach any modules already registered */
+	mutex_lock(&netcp_modules_lock);
+	for_each_netcp_module(module) {
+		ret = netcp_module_probe(netcp_device, module);
+		if (ret < 0)
+			dev_err(dev, "module(%s) probe failed\n", module->name);
+	}
+	mutex_unlock(&netcp_modules_lock);
 	return 0;
 
 probe_quit_interface:
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 09/10] Revert "net: netcp: remove dead code from the driver"
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: linux-arm-kernel

As the probe sequence is not guaranteed contrary to the assumption
of the commit 2d8e276a9030, same has to be reverted.

commit 2d8e276a9030 ("net: netcp: remove dead code from the driver")

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index f5a7eb2..9c51b25 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -2155,6 +2155,7 @@ static int netcp_probe(struct platform_device *pdev)
 	struct device_node *child, *interfaces;
 	struct netcp_device *netcp_device;
 	struct device *dev = &pdev->dev;
+	struct netcp_module *module;
 	int ret;
 
 	if (!node) {
@@ -2203,6 +2204,14 @@ static int netcp_probe(struct platform_device *pdev)
 	/* Add the device instance to the list */
 	list_add_tail(&netcp_device->device_list, &netcp_devices);
 
+	/* Probe & attach any modules already registered */
+	mutex_lock(&netcp_modules_lock);
+	for_each_netcp_module(module) {
+		ret = netcp_module_probe(netcp_device, module);
+		if (ret < 0)
+			dev_err(dev, "module(%s) probe failed\n", module->name);
+	}
+	mutex_unlock(&netcp_modules_lock);
 	return 0;
 
 probe_quit_interface:
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 10/10] net: netcp: support probe deferral
  2018-03-27 16:31 ` Murali Karicheri
  (?)
@ 2018-03-27 16:31   ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

The netcp driver shouldn't proceed until the knav qmss and dma
devices are ready. So return -EPROBE_DEFER if these devices are not
ready.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index 9c51b25..736f6f7 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -2158,6 +2158,10 @@ static int netcp_probe(struct platform_device *pdev)
 	struct netcp_module *module;
 	int ret;
 
+	if (!knav_dma_device_ready() ||
+	    !knav_qmss_device_ready())
+		return -EPROBE_DEFER;
+
 	if (!node) {
 		dev_err(dev, "could not find device info\n");
 		return -ENODEV;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 10/10] net: netcp: support probe deferral
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

The netcp driver shouldn't proceed until the knav qmss and dma
devices are ready. So return -EPROBE_DEFER if these devices are not
ready.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index 9c51b25..736f6f7 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -2158,6 +2158,10 @@ static int netcp_probe(struct platform_device *pdev)
 	struct netcp_module *module;
 	int ret;
 
+	if (!knav_dma_device_ready() ||
+	    !knav_qmss_device_ready())
+		return -EPROBE_DEFER;
+
 	if (!node) {
 		dev_err(dev, "could not find device info\n");
 		return -ENODEV;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 10/10] net: netcp: support probe deferral
@ 2018-03-27 16:31   ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 16:31 UTC (permalink / raw)
  To: linux-arm-kernel

The netcp driver shouldn't proceed until the knav qmss and dma
devices are ready. So return -EPROBE_DEFER if these devices are not
ready.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index 9c51b25..736f6f7 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -2158,6 +2158,10 @@ static int netcp_probe(struct platform_device *pdev)
 	struct netcp_module *module;
 	int ret;
 
+	if (!knav_dma_device_ready() ||
+	    !knav_qmss_device_ready())
+		return -EPROBE_DEFER;
+
 	if (!node) {
 		dev_err(dev, "could not find device info\n");
 		return -ENODEV;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
  2018-03-27 16:31   ` Murali Karicheri
@ 2018-03-27 17:13     ` Andrew Lunn
  -1 siblings, 0 replies; 70+ messages in thread
From: Andrew Lunn @ 2018-03-27 17:13 UTC (permalink / raw)
  To: Murali Karicheri
  Cc: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
> As a preparatory patch to add support for 2u cpsw hardware found on
> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
> since 2u uses RGMII interface instead of SGMII and to allow for driver
> re-use.
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> ---
>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
> index 56dbc0b..1dea891 100644
> --- a/drivers/net/ethernet/ti/netcp_ethss.c
> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>  
>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>  
> -	gbe_sgmii_config(priv, slave);
> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
> +		gbe_sgmii_config(priv, slave);

Hi Murali

So you have:

#define IS_SS_ID_NU(d) \
	(GBE_IDENT((d)->ss_version) == GBE_SS_ID_NU)


Does version 14 have a name? Could you add another IS_SS_ID_XX(d)
macro for it? That would make these statements more consistent.

	Andrew

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
@ 2018-03-27 17:13     ` Andrew Lunn
  0 siblings, 0 replies; 70+ messages in thread
From: Andrew Lunn @ 2018-03-27 17:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
> As a preparatory patch to add support for 2u cpsw hardware found on
> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
> since 2u uses RGMII interface instead of SGMII and to allow for driver
> re-use.
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> ---
>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
> index 56dbc0b..1dea891 100644
> --- a/drivers/net/ethernet/ti/netcp_ethss.c
> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>  
>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>  
> -	gbe_sgmii_config(priv, slave);
> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
> +		gbe_sgmii_config(priv, slave);

Hi Murali

So you have:

#define IS_SS_ID_NU(d) \
	(GBE_IDENT((d)->ss_version) == GBE_SS_ID_NU)


Does version 14 have a name? Could you add another IS_SS_ID_XX(d)
macro for it? That would make these statements more consistent.

	Andrew

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
  2018-03-27 16:31   ` Murali Karicheri
  (?)
@ 2018-03-27 17:18     ` Andrew Lunn
  -1 siblings, 0 replies; 70+ messages in thread
From: Andrew Lunn @ 2018-03-27 17:18 UTC (permalink / raw)
  To: Murali Karicheri
  Cc: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
> As a preparatory patch to add support for 2u cpsw hardware found on
> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
> since 2u uses RGMII interface instead of SGMII and to allow for driver
> re-use.
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> ---
>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
> index 56dbc0b..1dea891 100644
> --- a/drivers/net/ethernet/ti/netcp_ethss.c
> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>  
>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>  
> -	gbe_sgmii_config(priv, slave);
> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
> +		gbe_sgmii_config(priv, slave);

Or maybe:

   if (slave->phy_node == PHY_INTERFACE_MODE_SGMII)
   	gbe_sgmii_config(priv, slave);

	Andrew

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
@ 2018-03-27 17:18     ` Andrew Lunn
  0 siblings, 0 replies; 70+ messages in thread
From: Andrew Lunn @ 2018-03-27 17:18 UTC (permalink / raw)
  To: Murali Karicheri
  Cc: mark.rutland, devicetree, malat, netdev, linux-kernel, w-kwok2,
	robh+dt, ssantosh, davem, linux-arm-kernel

On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
> As a preparatory patch to add support for 2u cpsw hardware found on
> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
> since 2u uses RGMII interface instead of SGMII and to allow for driver
> re-use.
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> ---
>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
> index 56dbc0b..1dea891 100644
> --- a/drivers/net/ethernet/ti/netcp_ethss.c
> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>  
>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>  
> -	gbe_sgmii_config(priv, slave);
> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
> +		gbe_sgmii_config(priv, slave);

Or maybe:

   if (slave->phy_node == PHY_INTERFACE_MODE_SGMII)
   	gbe_sgmii_config(priv, slave);

	Andrew

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
@ 2018-03-27 17:18     ` Andrew Lunn
  0 siblings, 0 replies; 70+ messages in thread
From: Andrew Lunn @ 2018-03-27 17:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
> As a preparatory patch to add support for 2u cpsw hardware found on
> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
> since 2u uses RGMII interface instead of SGMII and to allow for driver
> re-use.
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> ---
>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
> index 56dbc0b..1dea891 100644
> --- a/drivers/net/ethernet/ti/netcp_ethss.c
> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>  
>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>  
> -	gbe_sgmii_config(priv, slave);
> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
> +		gbe_sgmii_config(priv, slave);

Or maybe:

   if (slave->phy_node == PHY_INTERFACE_MODE_SGMII)
   	gbe_sgmii_config(priv, slave);

	Andrew

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 05/10] net: netcp: ethss: use rgmii link status for 2u cpsw hardware
  2018-03-27 16:31   ` Murali Karicheri
@ 2018-03-27 17:29     ` Andrew Lunn
  -1 siblings, 0 replies; 70+ messages in thread
From: Andrew Lunn @ 2018-03-27 17:29 UTC (permalink / raw)
  To: Murali Karicheri
  Cc: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

On Tue, Mar 27, 2018 at 12:31:44PM -0400, Murali Karicheri wrote:
> Introduce rgmii link status to handle link state events for 2u
> cpsw hardware on K2G.
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> ---
>  drivers/net/ethernet/ti/netcp_ethss.c | 27 +++++++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
> index ab9d369..078a1b8 100644
> --- a/drivers/net/ethernet/ti/netcp_ethss.c
> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
> @@ -552,6 +552,7 @@ struct gbe_ss_regs {
>  struct gbe_ss_regs_ofs {
>  	u16	id_ver;
>  	u16	control;
> +	u16	rgmii_status; /* 2U */
>  };
>  
>  struct gbe_switch_regs {
> @@ -2120,23 +2121,39 @@ static bool gbe_phy_link_status(struct gbe_slave *slave)
>  	 return !slave->phy || slave->phy->link;
>  }
>  
> +#define RGMII_REG_STATUS_LINK	BIT(0)
> +
> +static void netcp_2u_rgmii_get_port_link(struct gbe_priv *gbe_dev, bool *status)
> +{
> +	u32 val = 0;
> +
> +	val = readl(GBE_REG_ADDR(gbe_dev, ss_regs, rgmii_status));
> +	*status = false;
> +	if ((val & RGMII_REG_STATUS_LINK) != 0)
> +		*status = true;

  *status = !!(val & RGMII_REG_STATUS_LINK);


> +}
> +
>  static void netcp_ethss_update_link_state(struct gbe_priv *gbe_dev,
>  					  struct gbe_slave *slave,
>  					  struct net_device *ndev)
>  {
> -	int sp = slave->slave_num;
> -	int phy_link_state, sgmii_link_state = 1, link_state;
> +	bool sw_link_state = true, phy_link_state;
> +	int sp = slave->slave_num, link_state;
>  
>  	if (!slave->open)
>  		return;
>  
>  	if (!SLAVE_LINK_IS_XGMII(slave)) {
> -		sgmii_link_state =
> +		if (SLAVE_LINK_IS_RGMII(slave))
> +			netcp_2u_rgmii_get_port_link(gbe_dev,
> +						     &sw_link_state);
> +		else
> +			sw_link_state =
>  			netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);

This would be more readable as

     if (SLAVE_LINK_IS_RGMII(slave))
		netcp_2u_rgmii_get_port_link(gbe_dev,
					     &sw_link_state);
     if (SLAVE_LINK_IS_SGMII(slave))
	sw_link_state = netcp_sgmii_get_port_link(
	   SGMII_BASE(gbe_dev, sp), sp);

   Andrew

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 05/10] net: netcp: ethss: use rgmii link status for 2u cpsw hardware
@ 2018-03-27 17:29     ` Andrew Lunn
  0 siblings, 0 replies; 70+ messages in thread
From: Andrew Lunn @ 2018-03-27 17:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Mar 27, 2018 at 12:31:44PM -0400, Murali Karicheri wrote:
> Introduce rgmii link status to handle link state events for 2u
> cpsw hardware on K2G.
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> ---
>  drivers/net/ethernet/ti/netcp_ethss.c | 27 +++++++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
> index ab9d369..078a1b8 100644
> --- a/drivers/net/ethernet/ti/netcp_ethss.c
> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
> @@ -552,6 +552,7 @@ struct gbe_ss_regs {
>  struct gbe_ss_regs_ofs {
>  	u16	id_ver;
>  	u16	control;
> +	u16	rgmii_status; /* 2U */
>  };
>  
>  struct gbe_switch_regs {
> @@ -2120,23 +2121,39 @@ static bool gbe_phy_link_status(struct gbe_slave *slave)
>  	 return !slave->phy || slave->phy->link;
>  }
>  
> +#define RGMII_REG_STATUS_LINK	BIT(0)
> +
> +static void netcp_2u_rgmii_get_port_link(struct gbe_priv *gbe_dev, bool *status)
> +{
> +	u32 val = 0;
> +
> +	val = readl(GBE_REG_ADDR(gbe_dev, ss_regs, rgmii_status));
> +	*status = false;
> +	if ((val & RGMII_REG_STATUS_LINK) != 0)
> +		*status = true;

  *status = !!(val & RGMII_REG_STATUS_LINK);


> +}
> +
>  static void netcp_ethss_update_link_state(struct gbe_priv *gbe_dev,
>  					  struct gbe_slave *slave,
>  					  struct net_device *ndev)
>  {
> -	int sp = slave->slave_num;
> -	int phy_link_state, sgmii_link_state = 1, link_state;
> +	bool sw_link_state = true, phy_link_state;
> +	int sp = slave->slave_num, link_state;
>  
>  	if (!slave->open)
>  		return;
>  
>  	if (!SLAVE_LINK_IS_XGMII(slave)) {
> -		sgmii_link_state =
> +		if (SLAVE_LINK_IS_RGMII(slave))
> +			netcp_2u_rgmii_get_port_link(gbe_dev,
> +						     &sw_link_state);
> +		else
> +			sw_link_state =
>  			netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);

This would be more readable as

     if (SLAVE_LINK_IS_RGMII(slave))
		netcp_2u_rgmii_get_port_link(gbe_dev,
					     &sw_link_state);
     if (SLAVE_LINK_IS_SGMII(slave))
	sw_link_state = netcp_sgmii_get_port_link(
	   SGMII_BASE(gbe_dev, sp), sp);

   Andrew

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 08/10] net: netcp: ethss: use of_get_phy_mode() to support different RGMII modes
  2018-03-27 16:31   ` Murali Karicheri
@ 2018-03-27 17:35     ` Andrew Lunn
  -1 siblings, 0 replies; 70+ messages in thread
From: Andrew Lunn @ 2018-03-27 17:35 UTC (permalink / raw)
  To: Murali Karicheri
  Cc: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

> +	} else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
> +		has_phy = true;
> +		phy_mode = of_get_phy_mode(slave->node);
> +		/* if phy-mode is not present, default to
> +		 * PHY_INTERFACE_MODE_RGMII
> +		 */
> +		if (phy_mode < 0)
> +			phy_mode = PHY_INTERFACE_MODE_RGMII;

Can only do RGMII? Maybe add a call here to
phy_interface_mode_is_rgmii() and return -EINVAL if DT contains
something which is not RGMII?

	  Andrew

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 08/10] net: netcp: ethss: use of_get_phy_mode() to support different RGMII modes
@ 2018-03-27 17:35     ` Andrew Lunn
  0 siblings, 0 replies; 70+ messages in thread
From: Andrew Lunn @ 2018-03-27 17:35 UTC (permalink / raw)
  To: linux-arm-kernel

> +	} else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
> +		has_phy = true;
> +		phy_mode = of_get_phy_mode(slave->node);
> +		/* if phy-mode is not present, default to
> +		 * PHY_INTERFACE_MODE_RGMII
> +		 */
> +		if (phy_mode < 0)
> +			phy_mode = PHY_INTERFACE_MODE_RGMII;

Can only do RGMII? Maybe add a call here to
phy_interface_mode_is_rgmii() and return -EINVAL if DT contains
something which is not RGMII?

	  Andrew

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
  2018-03-27 17:13     ` Andrew Lunn
  (?)
@ 2018-03-27 19:20       ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 19:20 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

On 03/27/2018 01:13 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
>> As a preparatory patch to add support for 2u cpsw hardware found on
>> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
>> since 2u uses RGMII interface instead of SGMII and to allow for driver
>> re-use.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index 56dbc0b..1dea891 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>>  
>>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>>  
>> -	gbe_sgmii_config(priv, slave);
>> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
>> +		gbe_sgmii_config(priv, slave);
> 
> Hi Murali
> 
> So you have:
> 
> #define IS_SS_ID_NU(d) \
> 	(GBE_IDENT((d)->ss_version) == GBE_SS_ID_NU)
> 
> 
> Does version 14 have a name? Could you add another IS_SS_ID_XX(d)
> macro for it? That would make these statements more consistent.
> 
unfortunately not being the first version :)

Probably we can add

#define IS_SS_ID_VER_14(d) \
	(GBE_IDENT((d)->ss_version) == GBE_SS_VERSION_14)

and replace all instances of (priv->ss_version == GBE_SS_VERSION_14) with
	if (IS_SS_ID_VER_14(priv)) or equivalent. 


> 	Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
@ 2018-03-27 19:20       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 19:20 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

On 03/27/2018 01:13 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
>> As a preparatory patch to add support for 2u cpsw hardware found on
>> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
>> since 2u uses RGMII interface instead of SGMII and to allow for driver
>> re-use.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index 56dbc0b..1dea891 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>>  
>>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>>  
>> -	gbe_sgmii_config(priv, slave);
>> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
>> +		gbe_sgmii_config(priv, slave);
> 
> Hi Murali
> 
> So you have:
> 
> #define IS_SS_ID_NU(d) \
> 	(GBE_IDENT((d)->ss_version) == GBE_SS_ID_NU)
> 
> 
> Does version 14 have a name? Could you add another IS_SS_ID_XX(d)
> macro for it? That would make these statements more consistent.
> 
unfortunately not being the first version :)

Probably we can add

#define IS_SS_ID_VER_14(d) \
	(GBE_IDENT((d)->ss_version) == GBE_SS_VERSION_14)

and replace all instances of (priv->ss_version == GBE_SS_VERSION_14) with
	if (IS_SS_ID_VER_14(priv)) or equivalent. 


> 	Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
@ 2018-03-27 19:20       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 19:20 UTC (permalink / raw)
  To: linux-arm-kernel

On 03/27/2018 01:13 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
>> As a preparatory patch to add support for 2u cpsw hardware found on
>> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
>> since 2u uses RGMII interface instead of SGMII and to allow for driver
>> re-use.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index 56dbc0b..1dea891 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>>  
>>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>>  
>> -	gbe_sgmii_config(priv, slave);
>> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
>> +		gbe_sgmii_config(priv, slave);
> 
> Hi Murali
> 
> So you have:
> 
> #define IS_SS_ID_NU(d) \
> 	(GBE_IDENT((d)->ss_version) == GBE_SS_ID_NU)
> 
> 
> Does version 14 have a name? Could you add another IS_SS_ID_XX(d)
> macro for it? That would make these statements more consistent.
> 
unfortunately not being the first version :)

Probably we can add

#define IS_SS_ID_VER_14(d) \
	(GBE_IDENT((d)->ss_version) == GBE_SS_VERSION_14)

and replace all instances of (priv->ss_version == GBE_SS_VERSION_14) with
	if (IS_SS_ID_VER_14(priv)) or equivalent. 


> 	Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
  2018-03-27 17:18     ` Andrew Lunn
  (?)
@ 2018-03-27 19:39       ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 19:39 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

On 03/27/2018 01:18 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
>> As a preparatory patch to add support for 2u cpsw hardware found on
>> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
>> since 2u uses RGMII interface instead of SGMII and to allow for driver
>> re-use.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index 56dbc0b..1dea891 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>>  
>>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>>  
>> -	gbe_sgmii_config(priv, slave);
>> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
>> +		gbe_sgmii_config(priv, slave);
> 
> Or maybe:
> 
>    if (slave->phy_node == PHY_INTERFACE_MODE_SGMII)
>    	gbe_sgmii_config(priv, slave);

Yeah. Based on my response to your other comment, this would become

if ((slave->link_interface == SGMII_LINK_MAC_PHY) &&
    (IS_SS_ID_VER_14(priv) || IS_SS_ID_NU(priv)))
	gbe_sgmii_config(priv, slave);

We can't solely depends on phy_mode here. Phy interface is one of several
interface possible. There is MAC_TO_MAC_FORCED, NO_MDIO etc. So we check the
link_interface above.

If we can agree, here is what will appear in v3

1) Add another patch to do conversion of priv->ss_version == GBE_SS_VERSION_14 check 
with a macro, IS_SS_ID_VER_14
2) modify this patch as above.

Murali
> 
> 	Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
@ 2018-03-27 19:39       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 19:39 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: mark.rutland, devicetree, malat, netdev, linux-kernel, w-kwok2,
	robh+dt, ssantosh, davem, linux-arm-kernel

On 03/27/2018 01:18 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
>> As a preparatory patch to add support for 2u cpsw hardware found on
>> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
>> since 2u uses RGMII interface instead of SGMII and to allow for driver
>> re-use.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index 56dbc0b..1dea891 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>>  
>>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>>  
>> -	gbe_sgmii_config(priv, slave);
>> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
>> +		gbe_sgmii_config(priv, slave);
> 
> Or maybe:
> 
>    if (slave->phy_node == PHY_INTERFACE_MODE_SGMII)
>    	gbe_sgmii_config(priv, slave);

Yeah. Based on my response to your other comment, this would become

if ((slave->link_interface == SGMII_LINK_MAC_PHY) &&
    (IS_SS_ID_VER_14(priv) || IS_SS_ID_NU(priv)))
	gbe_sgmii_config(priv, slave);

We can't solely depends on phy_mode here. Phy interface is one of several
interface possible. There is MAC_TO_MAC_FORCED, NO_MDIO etc. So we check the
link_interface above.

If we can agree, here is what will appear in v3

1) Add another patch to do conversion of priv->ss_version == GBE_SS_VERSION_14 check 
with a macro, IS_SS_ID_VER_14
2) modify this patch as above.

Murali
> 
> 	Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
@ 2018-03-27 19:39       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 19:39 UTC (permalink / raw)
  To: linux-arm-kernel

On 03/27/2018 01:18 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
>> As a preparatory patch to add support for 2u cpsw hardware found on
>> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
>> since 2u uses RGMII interface instead of SGMII and to allow for driver
>> re-use.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index 56dbc0b..1dea891 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>>  
>>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>>  
>> -	gbe_sgmii_config(priv, slave);
>> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
>> +		gbe_sgmii_config(priv, slave);
> 
> Or maybe:
> 
>    if (slave->phy_node == PHY_INTERFACE_MODE_SGMII)
>    	gbe_sgmii_config(priv, slave);

Yeah. Based on my response to your other comment, this would become

if ((slave->link_interface == SGMII_LINK_MAC_PHY) &&
    (IS_SS_ID_VER_14(priv) || IS_SS_ID_NU(priv)))
	gbe_sgmii_config(priv, slave);

We can't solely depends on phy_mode here. Phy interface is one of several
interface possible. There is MAC_TO_MAC_FORCED, NO_MDIO etc. So we check the
link_interface above.

If we can agree, here is what will appear in v3

1) Add another patch to do conversion of priv->ss_version == GBE_SS_VERSION_14 check 
with a macro, IS_SS_ID_VER_14
2) modify this patch as above.

Murali
> 
> 	Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 05/10] net: netcp: ethss: use rgmii link status for 2u cpsw hardware
  2018-03-27 17:29     ` Andrew Lunn
  (?)
@ 2018-03-27 21:07       ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 21:07 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

On 03/27/2018 01:29 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:44PM -0400, Murali Karicheri wrote:
>> Introduce rgmii link status to handle link state events for 2u
>> cpsw hardware on K2G.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 27 +++++++++++++++++++++++----
>>  1 file changed, 23 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index ab9d369..078a1b8 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -552,6 +552,7 @@ struct gbe_ss_regs {
>>  struct gbe_ss_regs_ofs {
>>  	u16	id_ver;
>>  	u16	control;
>> +	u16	rgmii_status; /* 2U */
>>  };
>>  
>>  struct gbe_switch_regs {
>> @@ -2120,23 +2121,39 @@ static bool gbe_phy_link_status(struct gbe_slave *slave)
>>  	 return !slave->phy || slave->phy->link;
>>  }
>>  
>> +#define RGMII_REG_STATUS_LINK	BIT(0)
>> +
>> +static void netcp_2u_rgmii_get_port_link(struct gbe_priv *gbe_dev, bool *status)
>> +{
>> +	u32 val = 0;
>> +
>> +	val = readl(GBE_REG_ADDR(gbe_dev, ss_regs, rgmii_status));
>> +	*status = false;
>> +	if ((val & RGMII_REG_STATUS_LINK) != 0)
>> +		*status = true;
> 
>   *status = !!(val & RGMII_REG_STATUS_LINK);
> 
> 
>> +}
>> +
>>  static void netcp_ethss_update_link_state(struct gbe_priv *gbe_dev,
>>  					  struct gbe_slave *slave,
>>  					  struct net_device *ndev)
>>  {
>> -	int sp = slave->slave_num;
>> -	int phy_link_state, sgmii_link_state = 1, link_state;
>> +	bool sw_link_state = true, phy_link_state;
>> +	int sp = slave->slave_num, link_state;
>>  
>>  	if (!slave->open)
>>  		return;
>>  
>>  	if (!SLAVE_LINK_IS_XGMII(slave)) {
>> -		sgmii_link_state =
>> +		if (SLAVE_LINK_IS_RGMII(slave))
>> +			netcp_2u_rgmii_get_port_link(gbe_dev,
>> +						     &sw_link_state);
>> +		else
>> +			sw_link_state =
>>  			netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);
> 
> This would be more readable as
> 
>      if (SLAVE_LINK_IS_RGMII(slave))
> 		netcp_2u_rgmii_get_port_link(gbe_dev,
> 					     &sw_link_state);
>      if (SLAVE_LINK_IS_SGMII(slave))
> 	sw_link_state = netcp_sgmii_get_port_link(
> 	   SGMII_BASE(gbe_dev, sp), sp);
> 
Probably better to use a switch statement in this case for better readability?
handle only SGMII and RGMII cases in the switch statement.

Murali

>    Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 05/10] net: netcp: ethss: use rgmii link status for 2u cpsw hardware
@ 2018-03-27 21:07       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 21:07 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: mark.rutland, devicetree, malat, netdev, linux-kernel, w-kwok2,
	robh+dt, ssantosh, davem, linux-arm-kernel

On 03/27/2018 01:29 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:44PM -0400, Murali Karicheri wrote:
>> Introduce rgmii link status to handle link state events for 2u
>> cpsw hardware on K2G.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 27 +++++++++++++++++++++++----
>>  1 file changed, 23 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index ab9d369..078a1b8 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -552,6 +552,7 @@ struct gbe_ss_regs {
>>  struct gbe_ss_regs_ofs {
>>  	u16	id_ver;
>>  	u16	control;
>> +	u16	rgmii_status; /* 2U */
>>  };
>>  
>>  struct gbe_switch_regs {
>> @@ -2120,23 +2121,39 @@ static bool gbe_phy_link_status(struct gbe_slave *slave)
>>  	 return !slave->phy || slave->phy->link;
>>  }
>>  
>> +#define RGMII_REG_STATUS_LINK	BIT(0)
>> +
>> +static void netcp_2u_rgmii_get_port_link(struct gbe_priv *gbe_dev, bool *status)
>> +{
>> +	u32 val = 0;
>> +
>> +	val = readl(GBE_REG_ADDR(gbe_dev, ss_regs, rgmii_status));
>> +	*status = false;
>> +	if ((val & RGMII_REG_STATUS_LINK) != 0)
>> +		*status = true;
> 
>   *status = !!(val & RGMII_REG_STATUS_LINK);
> 
> 
>> +}
>> +
>>  static void netcp_ethss_update_link_state(struct gbe_priv *gbe_dev,
>>  					  struct gbe_slave *slave,
>>  					  struct net_device *ndev)
>>  {
>> -	int sp = slave->slave_num;
>> -	int phy_link_state, sgmii_link_state = 1, link_state;
>> +	bool sw_link_state = true, phy_link_state;
>> +	int sp = slave->slave_num, link_state;
>>  
>>  	if (!slave->open)
>>  		return;
>>  
>>  	if (!SLAVE_LINK_IS_XGMII(slave)) {
>> -		sgmii_link_state =
>> +		if (SLAVE_LINK_IS_RGMII(slave))
>> +			netcp_2u_rgmii_get_port_link(gbe_dev,
>> +						     &sw_link_state);
>> +		else
>> +			sw_link_state =
>>  			netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);
> 
> This would be more readable as
> 
>      if (SLAVE_LINK_IS_RGMII(slave))
> 		netcp_2u_rgmii_get_port_link(gbe_dev,
> 					     &sw_link_state);
>      if (SLAVE_LINK_IS_SGMII(slave))
> 	sw_link_state = netcp_sgmii_get_port_link(
> 	   SGMII_BASE(gbe_dev, sp), sp);
> 
Probably better to use a switch statement in this case for better readability?
handle only SGMII and RGMII cases in the switch statement.

Murali

>    Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 05/10] net: netcp: ethss: use rgmii link status for 2u cpsw hardware
@ 2018-03-27 21:07       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-27 21:07 UTC (permalink / raw)
  To: linux-arm-kernel

On 03/27/2018 01:29 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:44PM -0400, Murali Karicheri wrote:
>> Introduce rgmii link status to handle link state events for 2u
>> cpsw hardware on K2G.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 27 +++++++++++++++++++++++----
>>  1 file changed, 23 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index ab9d369..078a1b8 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -552,6 +552,7 @@ struct gbe_ss_regs {
>>  struct gbe_ss_regs_ofs {
>>  	u16	id_ver;
>>  	u16	control;
>> +	u16	rgmii_status; /* 2U */
>>  };
>>  
>>  struct gbe_switch_regs {
>> @@ -2120,23 +2121,39 @@ static bool gbe_phy_link_status(struct gbe_slave *slave)
>>  	 return !slave->phy || slave->phy->link;
>>  }
>>  
>> +#define RGMII_REG_STATUS_LINK	BIT(0)
>> +
>> +static void netcp_2u_rgmii_get_port_link(struct gbe_priv *gbe_dev, bool *status)
>> +{
>> +	u32 val = 0;
>> +
>> +	val = readl(GBE_REG_ADDR(gbe_dev, ss_regs, rgmii_status));
>> +	*status = false;
>> +	if ((val & RGMII_REG_STATUS_LINK) != 0)
>> +		*status = true;
> 
>   *status = !!(val & RGMII_REG_STATUS_LINK);
> 
> 
>> +}
>> +
>>  static void netcp_ethss_update_link_state(struct gbe_priv *gbe_dev,
>>  					  struct gbe_slave *slave,
>>  					  struct net_device *ndev)
>>  {
>> -	int sp = slave->slave_num;
>> -	int phy_link_state, sgmii_link_state = 1, link_state;
>> +	bool sw_link_state = true, phy_link_state;
>> +	int sp = slave->slave_num, link_state;
>>  
>>  	if (!slave->open)
>>  		return;
>>  
>>  	if (!SLAVE_LINK_IS_XGMII(slave)) {
>> -		sgmii_link_state =
>> +		if (SLAVE_LINK_IS_RGMII(slave))
>> +			netcp_2u_rgmii_get_port_link(gbe_dev,
>> +						     &sw_link_state);
>> +		else
>> +			sw_link_state =
>>  			netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);
> 
> This would be more readable as
> 
>      if (SLAVE_LINK_IS_RGMII(slave))
> 		netcp_2u_rgmii_get_port_link(gbe_dev,
> 					     &sw_link_state);
>      if (SLAVE_LINK_IS_SGMII(slave))
> 	sw_link_state = netcp_sgmii_get_port_link(
> 	   SGMII_BASE(gbe_dev, sp), sp);
> 
Probably better to use a switch statement in this case for better readability?
handle only SGMII and RGMII cases in the switch statement.

Murali

>    Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next,v2,01/10] soc: ti: K2G: enhancement to support QMSS in NSS
  2018-03-27 16:31   ` Murali Karicheri
  (?)
@ 2018-03-28 19:01     ` Grygorii Strashko
  -1 siblings, 0 replies; 70+ messages in thread
From: Grygorii Strashko @ 2018-03-28 19:01 UTC (permalink / raw)
  To: Murali Karicheri, robh+dt, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev
  Cc: mark.rutland

Hi Murali,

On 03/27/2018 11:31 AM, Murali Karicheri wrote:
> Navigator Subsystem (NSS) available on K2G SoC has a cut down
> version of QMSS with less number of queues, internal linking ram
> with lesser number of buffers etc.  It doesn't have status and
> explicit push register space as in QMSS available on other K2 SoCs.
> So define reg indices specific to QMSS on K2G. This patch introduces
> "keystone-navigator-qmss-l" compatibility to identify QMSS on
> K2G NSS (QMSS Lite) and to customize the dts handling code. Per
> Device manual, descriptors with index less than or equal to
> regions0_size is in region 0 in the case of QMSS where as for
> QMSS Lite, descriptors with index less than regions0_size is in
> region 0. So update the size accordingly in the regions0_size bits
> of the linking ram size 0 register.
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
> ---
>   .../bindings/soc/ti/keystone-navigator-qmss.txt    |  7 ++
>   drivers/soc/ti/knav_qmss.h                         |  6 ++
>   drivers/soc/ti/knav_qmss_queue.c                   | 90 ++++++++++++++++------
>   3 files changed, 81 insertions(+), 22 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
> index 77cd42c..1b0878a 100644
> --- a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
> +++ b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
> @@ -18,6 +18,7 @@ pool management.
>   
>   Required properties:
>   - compatible	: Must be "ti,keystone-navigator-qmss";
> +		: Must be "ti,keystone-navigator-qmss-l" for NSS Lite


I think, It will be more accurate to add K2G specific compat string
like "ti,66ak2g-navss-qm":

compatible = "ti,66ak2g-navss-qm", "ti,keystone-navigator-qmss";

because 66ak2g TRM doesn't mention "Navss light" and this Navss version is used
only in 66ak2g Soc. As result, 66ak2g Navss QM is subset of of keystone 2 Navss QM 
which should be defined in DT by adding more specific compat string in addition
to generic one.  


>   - clocks	: phandle to the reference clock for this device.
>   - queue-range	: <start number> total range of queue numbers for the device.
>   - linkram0	: <address size> for internal link ram, where size is the total
> @@ -39,6 +40,12 @@ Required properties:
>   			  - Descriptor memory setup region.
>   			  - Queue Management/Queue Proxy region for queue Push.
>   			  - Queue Management/Queue Proxy region for queue Pop.
> +
> +For NSS lite, following QMSS reg indexes are used in that order

For 66AK2G NAVSS QM..

> +			  - Queue Peek region.
> +			  - Queue configuration region.
> +			  - Queue Management/Queue Proxy region for queue Push/Pop.
> +
>   - queue-pools	: child node classifying the queue ranges into pools.
>   		  Queue ranges are grouped into 3 type of pools:
>   		  - qpend	    : pool of qpend(interruptible) queues
> diff --git a/drivers/soc/ti/knav_qmss.h b/drivers/soc/ti/knav_qmss.h
> index 905b974..5fa1ce6 100644
> --- a/drivers/soc/ti/knav_qmss.h
> +++ b/drivers/soc/ti/knav_qmss.h
> @@ -292,6 +292,11 @@ struct knav_queue {
>   	struct list_head		list;
>   };
>   
> +enum qmss_version {
> +	QMSS,
> +	QMSS_LITE,

QMSS_66AK2G

> +};
> +
>   struct knav_device {
>   	struct device				*dev;
>   	unsigned				base_id;
> @@ -305,6 +310,7 @@ struct knav_device {
>   	struct list_head			pools;
>   	struct list_head			pdsps;
>   	struct list_head			qmgrs;
> +	enum qmss_version			version;
>   };
>   

[...]

>   }
>   
> +/* Match table for of_platform binding */
> +static const struct of_device_id keystone_qmss_of_match[] = {
> +	{
> +		.compatible = "ti,keystone-navigator-qmss",

		.data	= (void *)QMSS,

> +	},
> +	{
> +		.compatible = "ti,keystone-navigator-qmss-l",
> +		.data	= (void *)QMSS_LITE,
> +	},
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
> +
>   static int knav_queue_probe(struct platform_device *pdev)
>   {
>   	struct device_node *node = pdev->dev.of_node;
>   	struct device_node *qmgrs, *queue_pools, *regions, *pdsps;
> +	const struct of_device_id *match;
>   	struct device *dev = &pdev->dev;
>   	u32 temp[2];
>   	int ret;
> @@ -1700,6 +1749,10 @@ static int knav_queue_probe(struct platform_device *pdev)
>   		return -ENOMEM;
>   	}
>   
> +	match = of_match_device(of_match_ptr(keystone_qmss_of_match), dev);
> +	if (match && match->data)
> +		kdev->version = QMSS_LITE;

	if (match)
		kdev->version = match->data;
	else
		error?
[...]

-- 
regards,
-grygorii

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next,v2,01/10] soc: ti: K2G: enhancement to support QMSS in NSS
@ 2018-03-28 19:01     ` Grygorii Strashko
  0 siblings, 0 replies; 70+ messages in thread
From: Grygorii Strashko @ 2018-03-28 19:01 UTC (permalink / raw)
  To: Murali Karicheri, robh+dt, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev
  Cc: mark.rutland

Hi Murali,

On 03/27/2018 11:31 AM, Murali Karicheri wrote:
> Navigator Subsystem (NSS) available on K2G SoC has a cut down
> version of QMSS with less number of queues, internal linking ram
> with lesser number of buffers etc.  It doesn't have status and
> explicit push register space as in QMSS available on other K2 SoCs.
> So define reg indices specific to QMSS on K2G. This patch introduces
> "keystone-navigator-qmss-l" compatibility to identify QMSS on
> K2G NSS (QMSS Lite) and to customize the dts handling code. Per
> Device manual, descriptors with index less than or equal to
> regions0_size is in region 0 in the case of QMSS where as for
> QMSS Lite, descriptors with index less than regions0_size is in
> region 0. So update the size accordingly in the regions0_size bits
> of the linking ram size 0 register.
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
> ---
>   .../bindings/soc/ti/keystone-navigator-qmss.txt    |  7 ++
>   drivers/soc/ti/knav_qmss.h                         |  6 ++
>   drivers/soc/ti/knav_qmss_queue.c                   | 90 ++++++++++++++++------
>   3 files changed, 81 insertions(+), 22 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
> index 77cd42c..1b0878a 100644
> --- a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
> +++ b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
> @@ -18,6 +18,7 @@ pool management.
>   
>   Required properties:
>   - compatible	: Must be "ti,keystone-navigator-qmss";
> +		: Must be "ti,keystone-navigator-qmss-l" for NSS Lite


I think, It will be more accurate to add K2G specific compat string
like "ti,66ak2g-navss-qm":

compatible = "ti,66ak2g-navss-qm", "ti,keystone-navigator-qmss";

because 66ak2g TRM doesn't mention "Navss light" and this Navss version is used
only in 66ak2g Soc. As result, 66ak2g Navss QM is subset of of keystone 2 Navss QM 
which should be defined in DT by adding more specific compat string in addition
to generic one.  


>   - clocks	: phandle to the reference clock for this device.
>   - queue-range	: <start number> total range of queue numbers for the device.
>   - linkram0	: <address size> for internal link ram, where size is the total
> @@ -39,6 +40,12 @@ Required properties:
>   			  - Descriptor memory setup region.
>   			  - Queue Management/Queue Proxy region for queue Push.
>   			  - Queue Management/Queue Proxy region for queue Pop.
> +
> +For NSS lite, following QMSS reg indexes are used in that order

For 66AK2G NAVSS QM..

> +			  - Queue Peek region.
> +			  - Queue configuration region.
> +			  - Queue Management/Queue Proxy region for queue Push/Pop.
> +
>   - queue-pools	: child node classifying the queue ranges into pools.
>   		  Queue ranges are grouped into 3 type of pools:
>   		  - qpend	    : pool of qpend(interruptible) queues
> diff --git a/drivers/soc/ti/knav_qmss.h b/drivers/soc/ti/knav_qmss.h
> index 905b974..5fa1ce6 100644
> --- a/drivers/soc/ti/knav_qmss.h
> +++ b/drivers/soc/ti/knav_qmss.h
> @@ -292,6 +292,11 @@ struct knav_queue {
>   	struct list_head		list;
>   };
>   
> +enum qmss_version {
> +	QMSS,
> +	QMSS_LITE,

QMSS_66AK2G

> +};
> +
>   struct knav_device {
>   	struct device				*dev;
>   	unsigned				base_id;
> @@ -305,6 +310,7 @@ struct knav_device {
>   	struct list_head			pools;
>   	struct list_head			pdsps;
>   	struct list_head			qmgrs;
> +	enum qmss_version			version;
>   };
>   

[...]

>   }
>   
> +/* Match table for of_platform binding */
> +static const struct of_device_id keystone_qmss_of_match[] = {
> +	{
> +		.compatible = "ti,keystone-navigator-qmss",

		.data	= (void *)QMSS,

> +	},
> +	{
> +		.compatible = "ti,keystone-navigator-qmss-l",
> +		.data	= (void *)QMSS_LITE,
> +	},
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
> +
>   static int knav_queue_probe(struct platform_device *pdev)
>   {
>   	struct device_node *node = pdev->dev.of_node;
>   	struct device_node *qmgrs, *queue_pools, *regions, *pdsps;
> +	const struct of_device_id *match;
>   	struct device *dev = &pdev->dev;
>   	u32 temp[2];
>   	int ret;
> @@ -1700,6 +1749,10 @@ static int knav_queue_probe(struct platform_device *pdev)
>   		return -ENOMEM;
>   	}
>   
> +	match = of_match_device(of_match_ptr(keystone_qmss_of_match), dev);
> +	if (match && match->data)
> +		kdev->version = QMSS_LITE;

	if (match)
		kdev->version = match->data;
	else
		error?
[...]

-- 
regards,
-grygorii

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next, v2, 01/10] soc: ti: K2G: enhancement to support QMSS in NSS
@ 2018-03-28 19:01     ` Grygorii Strashko
  0 siblings, 0 replies; 70+ messages in thread
From: Grygorii Strashko @ 2018-03-28 19:01 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Murali,

On 03/27/2018 11:31 AM, Murali Karicheri wrote:
> Navigator Subsystem (NSS) available on K2G SoC has a cut down
> version of QMSS with less number of queues, internal linking ram
> with lesser number of buffers etc.  It doesn't have status and
> explicit push register space as in QMSS available on other K2 SoCs.
> So define reg indices specific to QMSS on K2G. This patch introduces
> "keystone-navigator-qmss-l" compatibility to identify QMSS on
> K2G NSS (QMSS Lite) and to customize the dts handling code. Per
> Device manual, descriptors with index less than or equal to
> regions0_size is in region 0 in the case of QMSS where as for
> QMSS Lite, descriptors with index less than regions0_size is in
> region 0. So update the size accordingly in the regions0_size bits
> of the linking ram size 0 register.
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
> ---
>   .../bindings/soc/ti/keystone-navigator-qmss.txt    |  7 ++
>   drivers/soc/ti/knav_qmss.h                         |  6 ++
>   drivers/soc/ti/knav_qmss_queue.c                   | 90 ++++++++++++++++------
>   3 files changed, 81 insertions(+), 22 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
> index 77cd42c..1b0878a 100644
> --- a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
> +++ b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
> @@ -18,6 +18,7 @@ pool management.
>   
>   Required properties:
>   - compatible	: Must be "ti,keystone-navigator-qmss";
> +		: Must be "ti,keystone-navigator-qmss-l" for NSS Lite


I think, It will be more accurate to add K2G specific compat string
like "ti,66ak2g-navss-qm":

compatible = "ti,66ak2g-navss-qm", "ti,keystone-navigator-qmss";

because 66ak2g TRM doesn't mention "Navss light" and this Navss version is used
only in 66ak2g Soc. As result, 66ak2g Navss QM is subset of of keystone 2 Navss QM 
which should be defined in DT by adding more specific compat string in addition
to generic one.  


>   - clocks	: phandle to the reference clock for this device.
>   - queue-range	: <start number> total range of queue numbers for the device.
>   - linkram0	: <address size> for internal link ram, where size is the total
> @@ -39,6 +40,12 @@ Required properties:
>   			  - Descriptor memory setup region.
>   			  - Queue Management/Queue Proxy region for queue Push.
>   			  - Queue Management/Queue Proxy region for queue Pop.
> +
> +For NSS lite, following QMSS reg indexes are used in that order

For 66AK2G NAVSS QM..

> +			  - Queue Peek region.
> +			  - Queue configuration region.
> +			  - Queue Management/Queue Proxy region for queue Push/Pop.
> +
>   - queue-pools	: child node classifying the queue ranges into pools.
>   		  Queue ranges are grouped into 3 type of pools:
>   		  - qpend	    : pool of qpend(interruptible) queues
> diff --git a/drivers/soc/ti/knav_qmss.h b/drivers/soc/ti/knav_qmss.h
> index 905b974..5fa1ce6 100644
> --- a/drivers/soc/ti/knav_qmss.h
> +++ b/drivers/soc/ti/knav_qmss.h
> @@ -292,6 +292,11 @@ struct knav_queue {
>   	struct list_head		list;
>   };
>   
> +enum qmss_version {
> +	QMSS,
> +	QMSS_LITE,

QMSS_66AK2G

> +};
> +
>   struct knav_device {
>   	struct device				*dev;
>   	unsigned				base_id;
> @@ -305,6 +310,7 @@ struct knav_device {
>   	struct list_head			pools;
>   	struct list_head			pdsps;
>   	struct list_head			qmgrs;
> +	enum qmss_version			version;
>   };
>   

[...]

>   }
>   
> +/* Match table for of_platform binding */
> +static const struct of_device_id keystone_qmss_of_match[] = {
> +	{
> +		.compatible = "ti,keystone-navigator-qmss",

		.data	= (void *)QMSS,

> +	},
> +	{
> +		.compatible = "ti,keystone-navigator-qmss-l",
> +		.data	= (void *)QMSS_LITE,
> +	},
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
> +
>   static int knav_queue_probe(struct platform_device *pdev)
>   {
>   	struct device_node *node = pdev->dev.of_node;
>   	struct device_node *qmgrs, *queue_pools, *regions, *pdsps;
> +	const struct of_device_id *match;
>   	struct device *dev = &pdev->dev;
>   	u32 temp[2];
>   	int ret;
> @@ -1700,6 +1749,10 @@ static int knav_queue_probe(struct platform_device *pdev)
>   		return -ENOMEM;
>   	}
>   
> +	match = of_match_device(of_match_ptr(keystone_qmss_of_match), dev);
> +	if (match && match->data)
> +		kdev->version = QMSS_LITE;

	if (match)
		kdev->version = match->data;
	else
		error?
[...]

-- 
regards,
-grygorii

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next,v2,01/10] soc: ti: K2G: enhancement to support QMSS in NSS
  2018-03-28 19:01     ` [net-next,v2,01/10] " Grygorii Strashko
  (?)
  (?)
@ 2018-03-29 14:50       ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 14:50 UTC (permalink / raw)
  To: Grygorii Strashko, robh+dt, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev
  Cc: mark.rutland

Hi Grygorii,

Thanks for reviewing this!

On 03/28/2018 03:01 PM, Grygorii Strashko wrote:
> Hi Murali,
> 
> On 03/27/2018 11:31 AM, Murali Karicheri wrote:
>> Navigator Subsystem (NSS) available on K2G SoC has a cut down
>> version of QMSS with less number of queues, internal linking ram
>> with lesser number of buffers etc.  It doesn't have status and
>> explicit push register space as in QMSS available on other K2 SoCs.
>> So define reg indices specific to QMSS on K2G. This patch introduces
>> "keystone-navigator-qmss-l" compatibility to identify QMSS on
>> K2G NSS (QMSS Lite) and to customize the dts handling code. Per
>> Device manual, descriptors with index less than or equal to
>> regions0_size is in region 0 in the case of QMSS where as for
>> QMSS Lite, descriptors with index less than regions0_size is in
>> region 0. So update the size accordingly in the regions0_size bits
>> of the linking ram size 0 register.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
>> ---
>>   .../bindings/soc/ti/keystone-navigator-qmss.txt    |  7 ++
>>   drivers/soc/ti/knav_qmss.h                         |  6 ++
>>   drivers/soc/ti/knav_qmss_queue.c                   | 90 ++++++++++++++++------
>>   3 files changed, 81 insertions(+), 22 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
>> index 77cd42c..1b0878a 100644
>> --- a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
>> +++ b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
>> @@ -18,6 +18,7 @@ pool management.
>>   
>>   Required properties:
>>   - compatible	: Must be "ti,keystone-navigator-qmss";
>> +		: Must be "ti,keystone-navigator-qmss-l" for NSS Lite
> 
> 
> I think, It will be more accurate to add K2G specific compat string
> like "ti,66ak2g-navss-qm":
> 
> compatible = "ti,66ak2g-navss-qm", "ti,keystone-navigator-qmss";
> 
> because 66ak2g TRM doesn't mention "Navss light" and this Navss version is used
> only in 66ak2g Soc. As result, 66ak2g Navss QM is subset of of keystone 2 Navss QM 
> which should be defined in DT by adding more specific compat string in addition
> to generic one.  
> 

As I have mentioned in the commit description, it is not a subset of the K2
registers. There are some differences that makes it not compatible with K2 QMSS.
See my description, 

>>It doesn't have status and explicit push register space as in QMSS available on
>>other K2 SoCs.

And also

>> Per Device manual, descriptors with index less than or equal to
>> regions0_size is in region 0 in the case of QMSS where as for
>> QMSS Lite, descriptors with index less than regions0_size is in
>> region 0. So update the size accordingly in the regions0_size bits
>> of the linking ram size 0 register

So will have to use a specific compatible = "ti,66ak2g-navss-qm" for this QM IMO.

Murali
> 
>>   - clocks	: phandle to the reference clock for this device.
>>   - queue-range	: <start number> total range of queue numbers for the device.
>>   - linkram0	: <address size> for internal link ram, where size is the total
>> @@ -39,6 +40,12 @@ Required properties:
>>   			  - Descriptor memory setup region.
>>   			  - Queue Management/Queue Proxy region for queue Push.
>>   			  - Queue Management/Queue Proxy region for queue Pop.
>> +
>> +For NSS lite, following QMSS reg indexes are used in that order
> 
> For 66AK2G NAVSS QM..
> 
>> +			  - Queue Peek region.
>> +			  - Queue configuration region.
>> +			  - Queue Management/Queue Proxy region for queue Push/Pop.
>> +
>>   - queue-pools	: child node classifying the queue ranges into pools.
>>   		  Queue ranges are grouped into 3 type of pools:
>>   		  - qpend	    : pool of qpend(interruptible) queues
>> diff --git a/drivers/soc/ti/knav_qmss.h b/drivers/soc/ti/knav_qmss.h
>> index 905b974..5fa1ce6 100644
>> --- a/drivers/soc/ti/knav_qmss.h
>> +++ b/drivers/soc/ti/knav_qmss.h
>> @@ -292,6 +292,11 @@ struct knav_queue {
>>   	struct list_head		list;
>>   };
>>   
>> +enum qmss_version {
>> +	QMSS,
>> +	QMSS_LITE,
> 
> QMSS_66AK2G
> 
>> +};
>> +
>>   struct knav_device {
>>   	struct device				*dev;
>>   	unsigned				base_id;
>> @@ -305,6 +310,7 @@ struct knav_device {
>>   	struct list_head			pools;
>>   	struct list_head			pdsps;
>>   	struct list_head			qmgrs;
>> +	enum qmss_version			version;
>>   };
>>   
> 
> [...]
> 
>>   }
>>   
>> +/* Match table for of_platform binding */
>> +static const struct of_device_id keystone_qmss_of_match[] = {
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss",
> 
> 		.data	= (void *)QMSS,
> 
>> +	},
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss-l",
>> +		.data	= (void *)QMSS_LITE,
>> +	},
>> +	{},
>> +};
>> +MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
>> +
>>   static int knav_queue_probe(struct platform_device *pdev)
>>   {
>>   	struct device_node *node = pdev->dev.of_node;
>>   	struct device_node *qmgrs, *queue_pools, *regions, *pdsps;
>> +	const struct of_device_id *match;
>>   	struct device *dev = &pdev->dev;
>>   	u32 temp[2];
>>   	int ret;
>> @@ -1700,6 +1749,10 @@ static int knav_queue_probe(struct platform_device *pdev)
>>   		return -ENOMEM;
>>   	}
>>   
>> +	match = of_match_device(of_match_ptr(keystone_qmss_of_match), dev);
>> +	if (match && match->data)
>> +		kdev->version = QMSS_LITE;
> 
> 	if (match)
> 		kdev->version = match->data;
> 	else
> 		error?
> [...]
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next, v2, 01/10] soc: ti: K2G: enhancement to support QMSS in NSS
@ 2018-03-29 14:50       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 14:50 UTC (permalink / raw)
  To: Grygorii Strashko, robh+dt, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev
  Cc: mark.rutland

Hi Grygorii,

Thanks for reviewing this!

On 03/28/2018 03:01 PM, Grygorii Strashko wrote:
> Hi Murali,
> 
> On 03/27/2018 11:31 AM, Murali Karicheri wrote:
>> Navigator Subsystem (NSS) available on K2G SoC has a cut down
>> version of QMSS with less number of queues, internal linking ram
>> with lesser number of buffers etc.  It doesn't have status and
>> explicit push register space as in QMSS available on other K2 SoCs.
>> So define reg indices specific to QMSS on K2G. This patch introduces
>> "keystone-navigator-qmss-l" compatibility to identify QMSS on
>> K2G NSS (QMSS Lite) and to customize the dts handling code. Per
>> Device manual, descriptors with index less than or equal to
>> regions0_size is in region 0 in the case of QMSS where as for
>> QMSS Lite, descriptors with index less than regions0_size is in
>> region 0. So update the size accordingly in the regions0_size bits
>> of the linking ram size 0 register.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
>> ---
>>   .../bindings/soc/ti/keystone-navigator-qmss.txt    |  7 ++
>>   drivers/soc/ti/knav_qmss.h                         |  6 ++
>>   drivers/soc/ti/knav_qmss_queue.c                   | 90 ++++++++++++++++------
>>   3 files changed, 81 insertions(+), 22 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
>> index 77cd42c..1b0878a 100644
>> --- a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
>> +++ b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
>> @@ -18,6 +18,7 @@ pool management.
>>   
>>   Required properties:
>>   - compatible	: Must be "ti,keystone-navigator-qmss";
>> +		: Must be "ti,keystone-navigator-qmss-l" for NSS Lite
> 
> 
> I think, It will be more accurate to add K2G specific compat string
> like "ti,66ak2g-navss-qm":
> 
> compatible = "ti,66ak2g-navss-qm", "ti,keystone-navigator-qmss";
> 
> because 66ak2g TRM doesn't mention "Navss light" and this Navss version is used
> only in 66ak2g Soc. As result, 66ak2g Navss QM is subset of of keystone 2 Navss QM 
> which should be defined in DT by adding more specific compat string in addition
> to generic one.  
> 

As I have mentioned in the commit description, it is not a subset of the K2
registers. There are some differences that makes it not compatible with K2 QMSS.
See my description, 

>>It doesn't have status and explicit push register space as in QMSS available on
>>other K2 SoCs.

And also

>> Per Device manual, descriptors with index less than or equal to
>> regions0_size is in region 0 in the case of QMSS where as for
>> QMSS Lite, descriptors with index less than regions0_size is in
>> region 0. So update the size accordingly in the regions0_size bits
>> of the linking ram size 0 register

So will have to use a specific compatible = "ti,66ak2g-navss-qm" for this QM IMO.

Murali
> 
>>   - clocks	: phandle to the reference clock for this device.
>>   - queue-range	: <start number> total range of queue numbers for the device.
>>   - linkram0	: <address size> for internal link ram, where size is the total
>> @@ -39,6 +40,12 @@ Required properties:
>>   			  - Descriptor memory setup region.
>>   			  - Queue Management/Queue Proxy region for queue Push.
>>   			  - Queue Management/Queue Proxy region for queue Pop.
>> +
>> +For NSS lite, following QMSS reg indexes are used in that order
> 
> For 66AK2G NAVSS QM..
> 
>> +			  - Queue Peek region.
>> +			  - Queue configuration region.
>> +			  - Queue Management/Queue Proxy region for queue Push/Pop.
>> +
>>   - queue-pools	: child node classifying the queue ranges into pools.
>>   		  Queue ranges are grouped into 3 type of pools:
>>   		  - qpend	    : pool of qpend(interruptible) queues
>> diff --git a/drivers/soc/ti/knav_qmss.h b/drivers/soc/ti/knav_qmss.h
>> index 905b974..5fa1ce6 100644
>> --- a/drivers/soc/ti/knav_qmss.h
>> +++ b/drivers/soc/ti/knav_qmss.h
>> @@ -292,6 +292,11 @@ struct knav_queue {
>>   	struct list_head		list;
>>   };
>>   
>> +enum qmss_version {
>> +	QMSS,
>> +	QMSS_LITE,
> 
> QMSS_66AK2G
> 
>> +};
>> +
>>   struct knav_device {
>>   	struct device				*dev;
>>   	unsigned				base_id;
>> @@ -305,6 +310,7 @@ struct knav_device {
>>   	struct list_head			pools;
>>   	struct list_head			pdsps;
>>   	struct list_head			qmgrs;
>> +	enum qmss_version			version;
>>   };
>>   
> 
> [...]
> 
>>   }
>>   
>> +/* Match table for of_platform binding */
>> +static const struct of_device_id keystone_qmss_of_match[] = {
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss",
> 
> 		.data	= (void *)QMSS,
> 
>> +	},
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss-l",
>> +		.data	= (void *)QMSS_LITE,
>> +	},
>> +	{},
>> +};
>> +MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
>> +
>>   static int knav_queue_probe(struct platform_device *pdev)
>>   {
>>   	struct device_node *node = pdev->dev.of_node;
>>   	struct device_node *qmgrs, *queue_pools, *regions, *pdsps;
>> +	const struct of_device_id *match;
>>   	struct device *dev = &pdev->dev;
>>   	u32 temp[2];
>>   	int ret;
>> @@ -1700,6 +1749,10 @@ static int knav_queue_probe(struct platform_device *pdev)
>>   		return -ENOMEM;
>>   	}
>>   
>> +	match = of_match_device(of_match_ptr(keystone_qmss_of_match), dev);
>> +	if (match && match->data)
>> +		kdev->version = QMSS_LITE;
> 
> 	if (match)
> 		kdev->version = match->data;
> 	else
> 		error?
> [...]
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next, v2, 01/10] soc: ti: K2G: enhancement to support QMSS in NSS
@ 2018-03-29 14:50       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 14:50 UTC (permalink / raw)
  To: Grygorii Strashko, robh+dt, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev
  Cc: mark.rutland

Hi Grygorii,

Thanks for reviewing this!

On 03/28/2018 03:01 PM, Grygorii Strashko wrote:
> Hi Murali,
> 
> On 03/27/2018 11:31 AM, Murali Karicheri wrote:
>> Navigator Subsystem (NSS) available on K2G SoC has a cut down
>> version of QMSS with less number of queues, internal linking ram
>> with lesser number of buffers etc.  It doesn't have status and
>> explicit push register space as in QMSS available on other K2 SoCs.
>> So define reg indices specific to QMSS on K2G. This patch introduces
>> "keystone-navigator-qmss-l" compatibility to identify QMSS on
>> K2G NSS (QMSS Lite) and to customize the dts handling code. Per
>> Device manual, descriptors with index less than or equal to
>> regions0_size is in region 0 in the case of QMSS where as for
>> QMSS Lite, descriptors with index less than regions0_size is in
>> region 0. So update the size accordingly in the regions0_size bits
>> of the linking ram size 0 register.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
>> ---
>>   .../bindings/soc/ti/keystone-navigator-qmss.txt    |  7 ++
>>   drivers/soc/ti/knav_qmss.h                         |  6 ++
>>   drivers/soc/ti/knav_qmss_queue.c                   | 90 ++++++++++++++++------
>>   3 files changed, 81 insertions(+), 22 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
>> index 77cd42c..1b0878a 100644
>> --- a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
>> +++ b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
>> @@ -18,6 +18,7 @@ pool management.
>>   
>>   Required properties:
>>   - compatible	: Must be "ti,keystone-navigator-qmss";
>> +		: Must be "ti,keystone-navigator-qmss-l" for NSS Lite
> 
> 
> I think, It will be more accurate to add K2G specific compat string
> like "ti,66ak2g-navss-qm":
> 
> compatible = "ti,66ak2g-navss-qm", "ti,keystone-navigator-qmss";
> 
> because 66ak2g TRM doesn't mention "Navss light" and this Navss version is used
> only in 66ak2g Soc. As result, 66ak2g Navss QM is subset of of keystone 2 Navss QM 
> which should be defined in DT by adding more specific compat string in addition
> to generic one.  
> 

As I have mentioned in the commit description, it is not a subset of the K2
registers. There are some differences that makes it not compatible with K2 QMSS.
See my description, 

>>It doesn't have status and explicit push register space as in QMSS available on
>>other K2 SoCs.

And also

>> Per Device manual, descriptors with index less than or equal to
>> regions0_size is in region 0 in the case of QMSS where as for
>> QMSS Lite, descriptors with index less than regions0_size is in
>> region 0. So update the size accordingly in the regions0_size bits
>> of the linking ram size 0 register

So will have to use a specific compatible = "ti,66ak2g-navss-qm" for this QM IMO.

Murali
> 
>>   - clocks	: phandle to the reference clock for this device.
>>   - queue-range	: <start number> total range of queue numbers for the device.
>>   - linkram0	: <address size> for internal link ram, where size is the total
>> @@ -39,6 +40,12 @@ Required properties:
>>   			  - Descriptor memory setup region.
>>   			  - Queue Management/Queue Proxy region for queue Push.
>>   			  - Queue Management/Queue Proxy region for queue Pop.
>> +
>> +For NSS lite, following QMSS reg indexes are used in that order
> 
> For 66AK2G NAVSS QM..
> 
>> +			  - Queue Peek region.
>> +			  - Queue configuration region.
>> +			  - Queue Management/Queue Proxy region for queue Push/Pop.
>> +
>>   - queue-pools	: child node classifying the queue ranges into pools.
>>   		  Queue ranges are grouped into 3 type of pools:
>>   		  - qpend	    : pool of qpend(interruptible) queues
>> diff --git a/drivers/soc/ti/knav_qmss.h b/drivers/soc/ti/knav_qmss.h
>> index 905b974..5fa1ce6 100644
>> --- a/drivers/soc/ti/knav_qmss.h
>> +++ b/drivers/soc/ti/knav_qmss.h
>> @@ -292,6 +292,11 @@ struct knav_queue {
>>   	struct list_head		list;
>>   };
>>   
>> +enum qmss_version {
>> +	QMSS,
>> +	QMSS_LITE,
> 
> QMSS_66AK2G
> 
>> +};
>> +
>>   struct knav_device {
>>   	struct device				*dev;
>>   	unsigned				base_id;
>> @@ -305,6 +310,7 @@ struct knav_device {
>>   	struct list_head			pools;
>>   	struct list_head			pdsps;
>>   	struct list_head			qmgrs;
>> +	enum qmss_version			version;
>>   };
>>   
> 
> [...]
> 
>>   }
>>   
>> +/* Match table for of_platform binding */
>> +static const struct of_device_id keystone_qmss_of_match[] = {
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss",
> 
> 		.data	= (void *)QMSS,
> 
>> +	},
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss-l",
>> +		.data	= (void *)QMSS_LITE,
>> +	},
>> +	{},
>> +};
>> +MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
>> +
>>   static int knav_queue_probe(struct platform_device *pdev)
>>   {
>>   	struct device_node *node = pdev->dev.of_node;
>>   	struct device_node *qmgrs, *queue_pools, *regions, *pdsps;
>> +	const struct of_device_id *match;
>>   	struct device *dev = &pdev->dev;
>>   	u32 temp[2];
>>   	int ret;
>> @@ -1700,6 +1749,10 @@ static int knav_queue_probe(struct platform_device *pdev)
>>   		return -ENOMEM;
>>   	}
>>   
>> +	match = of_match_device(of_match_ptr(keystone_qmss_of_match), dev);
>> +	if (match && match->data)
>> +		kdev->version = QMSS_LITE;
> 
> 	if (match)
> 		kdev->version = match->data;
> 	else
> 		error?
> [...]
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next, v2, 01/10] soc: ti: K2G: enhancement to support QMSS in NSS
@ 2018-03-29 14:50       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 14:50 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Grygorii,

Thanks for reviewing this!

On 03/28/2018 03:01 PM, Grygorii Strashko wrote:
> Hi Murali,
> 
> On 03/27/2018 11:31 AM, Murali Karicheri wrote:
>> Navigator Subsystem (NSS) available on K2G SoC has a cut down
>> version of QMSS with less number of queues, internal linking ram
>> with lesser number of buffers etc.  It doesn't have status and
>> explicit push register space as in QMSS available on other K2 SoCs.
>> So define reg indices specific to QMSS on K2G. This patch introduces
>> "keystone-navigator-qmss-l" compatibility to identify QMSS on
>> K2G NSS (QMSS Lite) and to customize the dts handling code. Per
>> Device manual, descriptors with index less than or equal to
>> regions0_size is in region 0 in the case of QMSS where as for
>> QMSS Lite, descriptors with index less than regions0_size is in
>> region 0. So update the size accordingly in the regions0_size bits
>> of the linking ram size 0 register.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
>> ---
>>   .../bindings/soc/ti/keystone-navigator-qmss.txt    |  7 ++
>>   drivers/soc/ti/knav_qmss.h                         |  6 ++
>>   drivers/soc/ti/knav_qmss_queue.c                   | 90 ++++++++++++++++------
>>   3 files changed, 81 insertions(+), 22 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
>> index 77cd42c..1b0878a 100644
>> --- a/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
>> +++ b/Documentation/devicetree/bindings/soc/ti/keystone-navigator-qmss.txt
>> @@ -18,6 +18,7 @@ pool management.
>>   
>>   Required properties:
>>   - compatible	: Must be "ti,keystone-navigator-qmss";
>> +		: Must be "ti,keystone-navigator-qmss-l" for NSS Lite
> 
> 
> I think, It will be more accurate to add K2G specific compat string
> like "ti,66ak2g-navss-qm":
> 
> compatible = "ti,66ak2g-navss-qm", "ti,keystone-navigator-qmss";
> 
> because 66ak2g TRM doesn't mention "Navss light" and this Navss version is used
> only in 66ak2g Soc. As result, 66ak2g Navss QM is subset of of keystone 2 Navss QM 
> which should be defined in DT by adding more specific compat string in addition
> to generic one.  
> 

As I have mentioned in the commit description, it is not a subset of the K2
registers. There are some differences that makes it not compatible with K2 QMSS.
See my description, 

>>It doesn't have status and explicit push register space as in QMSS available on
>>other K2 SoCs.

And also

>> Per Device manual, descriptors with index less than or equal to
>> regions0_size is in region 0 in the case of QMSS where as for
>> QMSS Lite, descriptors with index less than regions0_size is in
>> region 0. So update the size accordingly in the regions0_size bits
>> of the linking ram size 0 register

So will have to use a specific compatible = "ti,66ak2g-navss-qm" for this QM IMO.

Murali
> 
>>   - clocks	: phandle to the reference clock for this device.
>>   - queue-range	: <start number> total range of queue numbers for the device.
>>   - linkram0	: <address size> for internal link ram, where size is the total
>> @@ -39,6 +40,12 @@ Required properties:
>>   			  - Descriptor memory setup region.
>>   			  - Queue Management/Queue Proxy region for queue Push.
>>   			  - Queue Management/Queue Proxy region for queue Pop.
>> +
>> +For NSS lite, following QMSS reg indexes are used in that order
> 
> For 66AK2G NAVSS QM..
> 
>> +			  - Queue Peek region.
>> +			  - Queue configuration region.
>> +			  - Queue Management/Queue Proxy region for queue Push/Pop.
>> +
>>   - queue-pools	: child node classifying the queue ranges into pools.
>>   		  Queue ranges are grouped into 3 type of pools:
>>   		  - qpend	    : pool of qpend(interruptible) queues
>> diff --git a/drivers/soc/ti/knav_qmss.h b/drivers/soc/ti/knav_qmss.h
>> index 905b974..5fa1ce6 100644
>> --- a/drivers/soc/ti/knav_qmss.h
>> +++ b/drivers/soc/ti/knav_qmss.h
>> @@ -292,6 +292,11 @@ struct knav_queue {
>>   	struct list_head		list;
>>   };
>>   
>> +enum qmss_version {
>> +	QMSS,
>> +	QMSS_LITE,
> 
> QMSS_66AK2G
> 
>> +};
>> +
>>   struct knav_device {
>>   	struct device				*dev;
>>   	unsigned				base_id;
>> @@ -305,6 +310,7 @@ struct knav_device {
>>   	struct list_head			pools;
>>   	struct list_head			pdsps;
>>   	struct list_head			qmgrs;
>> +	enum qmss_version			version;
>>   };
>>   
> 
> [...]
> 
>>   }
>>   
>> +/* Match table for of_platform binding */
>> +static const struct of_device_id keystone_qmss_of_match[] = {
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss",
> 
> 		.data	= (void *)QMSS,
> 
>> +	},
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss-l",
>> +		.data	= (void *)QMSS_LITE,
>> +	},
>> +	{},
>> +};
>> +MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
>> +
>>   static int knav_queue_probe(struct platform_device *pdev)
>>   {
>>   	struct device_node *node = pdev->dev.of_node;
>>   	struct device_node *qmgrs, *queue_pools, *regions, *pdsps;
>> +	const struct of_device_id *match;
>>   	struct device *dev = &pdev->dev;
>>   	u32 temp[2];
>>   	int ret;
>> @@ -1700,6 +1749,10 @@ static int knav_queue_probe(struct platform_device *pdev)
>>   		return -ENOMEM;
>>   	}
>>   
>> +	match = of_match_device(of_match_ptr(keystone_qmss_of_match), dev);
>> +	if (match && match->data)
>> +		kdev->version = QMSS_LITE;
> 
> 	if (match)
> 		kdev->version = match->data;
> 	else
> 		error?
> [...]
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next,v2,01/10] soc: ti: K2G: enhancement to support QMSS in NSS
  2018-03-28 19:01     ` [net-next,v2,01/10] " Grygorii Strashko
  (?)
@ 2018-03-29 14:59       ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 14:59 UTC (permalink / raw)
  To: Grygorii Strashko, robh+dt, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev
  Cc: mark.rutland

On 03/28/2018 03:01 PM, Grygorii Strashko wrote:
> Hi Murali,
> 

>>   
>> +enum qmss_version {
>> +	QMSS,
>> +	QMSS_LITE,
> 
> QMSS_66AK2G
> 

OK.

>> +};
>> +
>>   struct knav_device {
>>   	struct device				*dev;
>>   	unsigned				base_id;
>> @@ -305,6 +310,7 @@ struct knav_device {
>>   	struct list_head			pools;
>>   	struct list_head			pdsps;
>>   	struct list_head			qmgrs;
>> +	enum qmss_version			version;
>>   };
>>   
> 
> [...]
> 
>>   }
>>   
>> +/* Match table for of_platform binding */
>> +static const struct of_device_id keystone_qmss_of_match[] = {
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss",
> 
> 		.data	= (void *)QMSS,

This seems to be unnecessary as QMSS is actually defined as zero. Also 
this static. So that value is zero already in memory.
> 
>> +	},
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss-l",
>> +		.data	= (void *)QMSS_LITE,
>> +	},
>> +	{},
>> +};
>> +MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
>> +
>>   static int knav_queue_probe(struct platform_device *pdev)
>>   {
>>   	struct device_node *node = pdev->dev.of_node;
>>   	struct device_node *qmgrs, *queue_pools, *regions, *pdsps;
>> +	const struct of_device_id *match;
>>   	struct device *dev = &pdev->dev;
>>   	u32 temp[2];
>>   	int ret;
>> @@ -1700,6 +1749,10 @@ static int knav_queue_probe(struct platform_device *pdev)
>>   		return -ENOMEM;
>>   	}
>>   
>> +	match = of_match_device(of_match_ptr(keystone_qmss_of_match), dev);
>> +	if (match && match->data)
>> +		kdev->version = QMSS_LITE;
> 
> 	if (match)
> 		kdev->version = match->data;
> 	else
> 		error?

Similar to above. This private memory is allocated using kzalloc which initializes
everything to zero. So the else part is unnecessary.

Murali

> [...]
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next,v2,01/10] soc: ti: K2G: enhancement to support QMSS in NSS
@ 2018-03-29 14:59       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 14:59 UTC (permalink / raw)
  To: Grygorii Strashko, robh+dt, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev
  Cc: mark.rutland

On 03/28/2018 03:01 PM, Grygorii Strashko wrote:
> Hi Murali,
> 

>>   
>> +enum qmss_version {
>> +	QMSS,
>> +	QMSS_LITE,
> 
> QMSS_66AK2G
> 

OK.

>> +};
>> +
>>   struct knav_device {
>>   	struct device				*dev;
>>   	unsigned				base_id;
>> @@ -305,6 +310,7 @@ struct knav_device {
>>   	struct list_head			pools;
>>   	struct list_head			pdsps;
>>   	struct list_head			qmgrs;
>> +	enum qmss_version			version;
>>   };
>>   
> 
> [...]
> 
>>   }
>>   
>> +/* Match table for of_platform binding */
>> +static const struct of_device_id keystone_qmss_of_match[] = {
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss",
> 
> 		.data	= (void *)QMSS,

This seems to be unnecessary as QMSS is actually defined as zero. Also 
this static. So that value is zero already in memory.
> 
>> +	},
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss-l",
>> +		.data	= (void *)QMSS_LITE,
>> +	},
>> +	{},
>> +};
>> +MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
>> +
>>   static int knav_queue_probe(struct platform_device *pdev)
>>   {
>>   	struct device_node *node = pdev->dev.of_node;
>>   	struct device_node *qmgrs, *queue_pools, *regions, *pdsps;
>> +	const struct of_device_id *match;
>>   	struct device *dev = &pdev->dev;
>>   	u32 temp[2];
>>   	int ret;
>> @@ -1700,6 +1749,10 @@ static int knav_queue_probe(struct platform_device *pdev)
>>   		return -ENOMEM;
>>   	}
>>   
>> +	match = of_match_device(of_match_ptr(keystone_qmss_of_match), dev);
>> +	if (match && match->data)
>> +		kdev->version = QMSS_LITE;
> 
> 	if (match)
> 		kdev->version = match->data;
> 	else
> 		error?

Similar to above. This private memory is allocated using kzalloc which initializes
everything to zero. So the else part is unnecessary.

Murali

> [...]
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next, v2, 01/10] soc: ti: K2G: enhancement to support QMSS in NSS
@ 2018-03-29 14:59       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 14:59 UTC (permalink / raw)
  To: linux-arm-kernel

On 03/28/2018 03:01 PM, Grygorii Strashko wrote:
> Hi Murali,
> 

>>   
>> +enum qmss_version {
>> +	QMSS,
>> +	QMSS_LITE,
> 
> QMSS_66AK2G
> 

OK.

>> +};
>> +
>>   struct knav_device {
>>   	struct device				*dev;
>>   	unsigned				base_id;
>> @@ -305,6 +310,7 @@ struct knav_device {
>>   	struct list_head			pools;
>>   	struct list_head			pdsps;
>>   	struct list_head			qmgrs;
>> +	enum qmss_version			version;
>>   };
>>   
> 
> [...]
> 
>>   }
>>   
>> +/* Match table for of_platform binding */
>> +static const struct of_device_id keystone_qmss_of_match[] = {
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss",
> 
> 		.data	= (void *)QMSS,

This seems to be unnecessary as QMSS is actually defined as zero. Also 
this static. So that value is zero already in memory.
> 
>> +	},
>> +	{
>> +		.compatible = "ti,keystone-navigator-qmss-l",
>> +		.data	= (void *)QMSS_LITE,
>> +	},
>> +	{},
>> +};
>> +MODULE_DEVICE_TABLE(of, keystone_qmss_of_match);
>> +
>>   static int knav_queue_probe(struct platform_device *pdev)
>>   {
>>   	struct device_node *node = pdev->dev.of_node;
>>   	struct device_node *qmgrs, *queue_pools, *regions, *pdsps;
>> +	const struct of_device_id *match;
>>   	struct device *dev = &pdev->dev;
>>   	u32 temp[2];
>>   	int ret;
>> @@ -1700,6 +1749,10 @@ static int knav_queue_probe(struct platform_device *pdev)
>>   		return -ENOMEM;
>>   	}
>>   
>> +	match = of_match_device(of_match_ptr(keystone_qmss_of_match), dev);
>> +	if (match && match->data)
>> +		kdev->version = QMSS_LITE;
> 
> 	if (match)
> 		kdev->version = match->data;
> 	else
> 		error?

Similar to above. This private memory is allocated using kzalloc which initializes
everything to zero. So the else part is unnecessary.

Murali

> [...]
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
  2018-03-27 17:18     ` Andrew Lunn
  (?)
@ 2018-03-29 16:27       ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 16:27 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

On 03/27/2018 01:18 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
>> As a preparatory patch to add support for 2u cpsw hardware found on
>> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
>> since 2u uses RGMII interface instead of SGMII and to allow for driver
>> re-use.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index 56dbc0b..1dea891 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>>  
>>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>>  
>> -	gbe_sgmii_config(priv, slave);
>> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
>> +		gbe_sgmii_config(priv, slave);
> 
> Or maybe:
> 
>    if (slave->phy_node == PHY_INTERFACE_MODE_SGMII)
>    	gbe_sgmii_config(priv, slave);
> 
> 	Andrew
> Actually, on specific cpsw hardware, driver supports specific interface. Driver also
uses link-interface DT property to configure this and link-interface can be without phy
as well. So essentially the above code looks good IMO.

I need to change this as 

if (IS_SS_ID_VER_14(priv) || IS_SS_ID_NU(priv))
    gbe_sgmii_config(priv, slave);

Based on the link-interface, driver selects the phy mode and pass it to of_phy_connect().

I will update the above in v3.
-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
@ 2018-03-29 16:27       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 16:27 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: mark.rutland, devicetree, malat, netdev, linux-kernel, w-kwok2,
	robh+dt, ssantosh, davem, linux-arm-kernel

On 03/27/2018 01:18 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
>> As a preparatory patch to add support for 2u cpsw hardware found on
>> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
>> since 2u uses RGMII interface instead of SGMII and to allow for driver
>> re-use.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index 56dbc0b..1dea891 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>>  
>>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>>  
>> -	gbe_sgmii_config(priv, slave);
>> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
>> +		gbe_sgmii_config(priv, slave);
> 
> Or maybe:
> 
>    if (slave->phy_node == PHY_INTERFACE_MODE_SGMII)
>    	gbe_sgmii_config(priv, slave);
> 
> 	Andrew
> Actually, on specific cpsw hardware, driver supports specific interface. Driver also
uses link-interface DT property to configure this and link-interface can be without phy
as well. So essentially the above code looks good IMO.

I need to change this as 

if (IS_SS_ID_VER_14(priv) || IS_SS_ID_NU(priv))
    gbe_sgmii_config(priv, slave);

Based on the link-interface, driver selects the phy mode and pass it to of_phy_connect().

I will update the above in v3.
-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional
@ 2018-03-29 16:27       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 16:27 UTC (permalink / raw)
  To: linux-arm-kernel

On 03/27/2018 01:18 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:42PM -0400, Murali Karicheri wrote:
>> As a preparatory patch to add support for 2u cpsw hardware found on
>> K2G SoC, make call to gbe_sgmii_config() conditional. This is required
>> since 2u uses RGMII interface instead of SGMII and to allow for driver
>> re-use.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index 56dbc0b..1dea891 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -2271,7 +2271,8 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
>>  
>>  	void (*hndlr)(struct net_device *) = gbe_adjust_link;
>>  
>> -	gbe_sgmii_config(priv, slave);
>> +	if ((priv->ss_version == GBE_SS_VERSION_14) || IS_SS_ID_NU(priv))
>> +		gbe_sgmii_config(priv, slave);
> 
> Or maybe:
> 
>    if (slave->phy_node == PHY_INTERFACE_MODE_SGMII)
>    	gbe_sgmii_config(priv, slave);
> 
> 	Andrew
> Actually, on specific cpsw hardware, driver supports specific interface. Driver also
uses link-interface DT property to configure this and link-interface can be without phy
as well. So essentially the above code looks good IMO.

I need to change this as 

if (IS_SS_ID_VER_14(priv) || IS_SS_ID_NU(priv))
    gbe_sgmii_config(priv, slave);

Based on the link-interface, driver selects the phy mode and pass it to of_phy_connect().

I will update the above in v3.
-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 05/10] net: netcp: ethss: use rgmii link status for 2u cpsw hardware
  2018-03-27 17:29     ` Andrew Lunn
  (?)
@ 2018-03-29 16:35       ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 16:35 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

On 03/27/2018 01:29 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:44PM -0400, Murali Karicheri wrote:
>> Introduce rgmii link status to handle link state events for 2u
>> cpsw hardware on K2G.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 27 +++++++++++++++++++++++----
>>  1 file changed, 23 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index ab9d369..078a1b8 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -552,6 +552,7 @@ struct gbe_ss_regs {
>>  struct gbe_ss_regs_ofs {
>>  	u16	id_ver;
>>  	u16	control;
>> +	u16	rgmii_status; /* 2U */
>>  };
>>  
>>  struct gbe_switch_regs {
>> @@ -2120,23 +2121,39 @@ static bool gbe_phy_link_status(struct gbe_slave *slave)
>>  	 return !slave->phy || slave->phy->link;
>>  }
>>  
>> +#define RGMII_REG_STATUS_LINK	BIT(0)
>> +
>> +static void netcp_2u_rgmii_get_port_link(struct gbe_priv *gbe_dev, bool *status)
>> +{
>> +	u32 val = 0;
>> +
>> +	val = readl(GBE_REG_ADDR(gbe_dev, ss_regs, rgmii_status));
>> +	*status = false;
>> +	if ((val & RGMII_REG_STATUS_LINK) != 0)
>> +		*status = true;
> 
>   *status = !!(val & RGMII_REG_STATUS_LINK);
> 

Ok

> 
>> +}
>> +
>>  static void netcp_ethss_update_link_state(struct gbe_priv *gbe_dev,
>>  					  struct gbe_slave *slave,
>>  					  struct net_device *ndev)
>>  {
>> -	int sp = slave->slave_num;
>> -	int phy_link_state, sgmii_link_state = 1, link_state;
>> +	bool sw_link_state = true, phy_link_state;
>> +	int sp = slave->slave_num, link_state;
>>  
>>  	if (!slave->open)
>>  		return;
>>  
>>  	if (!SLAVE_LINK_IS_XGMII(slave)) {
>> -		sgmii_link_state =
>> +		if (SLAVE_LINK_IS_RGMII(slave))
>> +			netcp_2u_rgmii_get_port_link(gbe_dev,
>> +						     &sw_link_state);
>> +		else
>> +			sw_link_state =
>>  			netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);
> 
> This would be more readable as
> 
>      if (SLAVE_LINK_IS_RGMII(slave))
> 		netcp_2u_rgmii_get_port_link(gbe_dev,
> 					     &sw_link_state);
>      if (SLAVE_LINK_IS_SGMII(slave))
> 	sw_link_state = netcp_sgmii_get_port_link(
> 	   SGMII_BASE(gbe_dev, sp), sp);

OK. I will add the new macro for SLAVE_LINK_IS_SGMII() as well.

> 
>    Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 05/10] net: netcp: ethss: use rgmii link status for 2u cpsw hardware
@ 2018-03-29 16:35       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 16:35 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

On 03/27/2018 01:29 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:44PM -0400, Murali Karicheri wrote:
>> Introduce rgmii link status to handle link state events for 2u
>> cpsw hardware on K2G.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 27 +++++++++++++++++++++++----
>>  1 file changed, 23 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index ab9d369..078a1b8 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -552,6 +552,7 @@ struct gbe_ss_regs {
>>  struct gbe_ss_regs_ofs {
>>  	u16	id_ver;
>>  	u16	control;
>> +	u16	rgmii_status; /* 2U */
>>  };
>>  
>>  struct gbe_switch_regs {
>> @@ -2120,23 +2121,39 @@ static bool gbe_phy_link_status(struct gbe_slave *slave)
>>  	 return !slave->phy || slave->phy->link;
>>  }
>>  
>> +#define RGMII_REG_STATUS_LINK	BIT(0)
>> +
>> +static void netcp_2u_rgmii_get_port_link(struct gbe_priv *gbe_dev, bool *status)
>> +{
>> +	u32 val = 0;
>> +
>> +	val = readl(GBE_REG_ADDR(gbe_dev, ss_regs, rgmii_status));
>> +	*status = false;
>> +	if ((val & RGMII_REG_STATUS_LINK) != 0)
>> +		*status = true;
> 
>   *status = !!(val & RGMII_REG_STATUS_LINK);
> 

Ok

> 
>> +}
>> +
>>  static void netcp_ethss_update_link_state(struct gbe_priv *gbe_dev,
>>  					  struct gbe_slave *slave,
>>  					  struct net_device *ndev)
>>  {
>> -	int sp = slave->slave_num;
>> -	int phy_link_state, sgmii_link_state = 1, link_state;
>> +	bool sw_link_state = true, phy_link_state;
>> +	int sp = slave->slave_num, link_state;
>>  
>>  	if (!slave->open)
>>  		return;
>>  
>>  	if (!SLAVE_LINK_IS_XGMII(slave)) {
>> -		sgmii_link_state =
>> +		if (SLAVE_LINK_IS_RGMII(slave))
>> +			netcp_2u_rgmii_get_port_link(gbe_dev,
>> +						     &sw_link_state);
>> +		else
>> +			sw_link_state =
>>  			netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);
> 
> This would be more readable as
> 
>      if (SLAVE_LINK_IS_RGMII(slave))
> 		netcp_2u_rgmii_get_port_link(gbe_dev,
> 					     &sw_link_state);
>      if (SLAVE_LINK_IS_SGMII(slave))
> 	sw_link_state = netcp_sgmii_get_port_link(
> 	   SGMII_BASE(gbe_dev, sp), sp);

OK. I will add the new macro for SLAVE_LINK_IS_SGMII() as well.

> 
>    Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 05/10] net: netcp: ethss: use rgmii link status for 2u cpsw hardware
@ 2018-03-29 16:35       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 16:35 UTC (permalink / raw)
  To: linux-arm-kernel

On 03/27/2018 01:29 PM, Andrew Lunn wrote:
> On Tue, Mar 27, 2018 at 12:31:44PM -0400, Murali Karicheri wrote:
>> Introduce rgmii link status to handle link state events for 2u
>> cpsw hardware on K2G.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> ---
>>  drivers/net/ethernet/ti/netcp_ethss.c | 27 +++++++++++++++++++++++----
>>  1 file changed, 23 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
>> index ab9d369..078a1b8 100644
>> --- a/drivers/net/ethernet/ti/netcp_ethss.c
>> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
>> @@ -552,6 +552,7 @@ struct gbe_ss_regs {
>>  struct gbe_ss_regs_ofs {
>>  	u16	id_ver;
>>  	u16	control;
>> +	u16	rgmii_status; /* 2U */
>>  };
>>  
>>  struct gbe_switch_regs {
>> @@ -2120,23 +2121,39 @@ static bool gbe_phy_link_status(struct gbe_slave *slave)
>>  	 return !slave->phy || slave->phy->link;
>>  }
>>  
>> +#define RGMII_REG_STATUS_LINK	BIT(0)
>> +
>> +static void netcp_2u_rgmii_get_port_link(struct gbe_priv *gbe_dev, bool *status)
>> +{
>> +	u32 val = 0;
>> +
>> +	val = readl(GBE_REG_ADDR(gbe_dev, ss_regs, rgmii_status));
>> +	*status = false;
>> +	if ((val & RGMII_REG_STATUS_LINK) != 0)
>> +		*status = true;
> 
>   *status = !!(val & RGMII_REG_STATUS_LINK);
> 

Ok

> 
>> +}
>> +
>>  static void netcp_ethss_update_link_state(struct gbe_priv *gbe_dev,
>>  					  struct gbe_slave *slave,
>>  					  struct net_device *ndev)
>>  {
>> -	int sp = slave->slave_num;
>> -	int phy_link_state, sgmii_link_state = 1, link_state;
>> +	bool sw_link_state = true, phy_link_state;
>> +	int sp = slave->slave_num, link_state;
>>  
>>  	if (!slave->open)
>>  		return;
>>  
>>  	if (!SLAVE_LINK_IS_XGMII(slave)) {
>> -		sgmii_link_state =
>> +		if (SLAVE_LINK_IS_RGMII(slave))
>> +			netcp_2u_rgmii_get_port_link(gbe_dev,
>> +						     &sw_link_state);
>> +		else
>> +			sw_link_state =
>>  			netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);
> 
> This would be more readable as
> 
>      if (SLAVE_LINK_IS_RGMII(slave))
> 		netcp_2u_rgmii_get_port_link(gbe_dev,
> 					     &sw_link_state);
>      if (SLAVE_LINK_IS_SGMII(slave))
> 	sw_link_state = netcp_sgmii_get_port_link(
> 	   SGMII_BASE(gbe_dev, sp), sp);

OK. I will add the new macro for SLAVE_LINK_IS_SGMII() as well.

> 
>    Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 08/10] net: netcp: ethss: use of_get_phy_mode() to support different RGMII modes
  2018-03-27 17:35     ` Andrew Lunn
  (?)
@ 2018-03-29 20:03       ` Murali Karicheri
  -1 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 20:03 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: robh+dt, mark.rutland, ssantosh, malat, w-kwok2, devicetree,
	linux-kernel, linux-arm-kernel, davem, netdev

On 03/27/2018 01:35 PM, Andrew Lunn wrote:
>> +	} else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
>> +		has_phy = true;
>> +		phy_mode = of_get_phy_mode(slave->node);
>> +		/* if phy-mode is not present, default to
>> +		 * PHY_INTERFACE_MODE_RGMII
>> +		 */
>> +		if (phy_mode < 0)
>> +			phy_mode = PHY_INTERFACE_MODE_RGMII;
> 
> Can only do RGMII? Maybe add a call here to
> phy_interface_mode_is_rgmii() and return -EINVAL if DT contains
> something which is not RGMII?
> 
Ok. Make sense.

> 	  Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [net-next PATCH v2 08/10] net: netcp: ethss: use of_get_phy_mode() to support different RGMII modes
@ 2018-03-29 20:03       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 20:03 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: mark.rutland, devicetree, malat, netdev, linux-kernel, w-kwok2,
	robh+dt, ssantosh, davem, linux-arm-kernel

On 03/27/2018 01:35 PM, Andrew Lunn wrote:
>> +	} else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
>> +		has_phy = true;
>> +		phy_mode = of_get_phy_mode(slave->node);
>> +		/* if phy-mode is not present, default to
>> +		 * PHY_INTERFACE_MODE_RGMII
>> +		 */
>> +		if (phy_mode < 0)
>> +			phy_mode = PHY_INTERFACE_MODE_RGMII;
> 
> Can only do RGMII? Maybe add a call here to
> phy_interface_mode_is_rgmii() and return -EINVAL if DT contains
> something which is not RGMII?
> 
Ok. Make sense.

> 	  Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [net-next PATCH v2 08/10] net: netcp: ethss: use of_get_phy_mode() to support different RGMII modes
@ 2018-03-29 20:03       ` Murali Karicheri
  0 siblings, 0 replies; 70+ messages in thread
From: Murali Karicheri @ 2018-03-29 20:03 UTC (permalink / raw)
  To: linux-arm-kernel

On 03/27/2018 01:35 PM, Andrew Lunn wrote:
>> +	} else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
>> +		has_phy = true;
>> +		phy_mode = of_get_phy_mode(slave->node);
>> +		/* if phy-mode is not present, default to
>> +		 * PHY_INTERFACE_MODE_RGMII
>> +		 */
>> +		if (phy_mode < 0)
>> +			phy_mode = PHY_INTERFACE_MODE_RGMII;
> 
> Can only do RGMII? Maybe add a call here to
> phy_interface_mode_is_rgmii() and return -EINVAL if DT contains
> something which is not RGMII?
> 
Ok. Make sense.

> 	  Andrew
> 


-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 70+ messages in thread

end of thread, other threads:[~2018-03-29 20:03 UTC | newest]

Thread overview: 70+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27 16:31 [net-next PATCH v2 00/10] Add support for netcp driver on K2G SoC Murali Karicheri
2018-03-27 16:31 ` Murali Karicheri
2018-03-27 16:31 ` Murali Karicheri
2018-03-27 16:31 ` [net-next PATCH v2 01/10] soc: ti: K2G: enhancement to support QMSS in NSS Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-28 19:01   ` [net-next,v2,01/10] " Grygorii Strashko
2018-03-28 19:01     ` [net-next, v2, 01/10] " Grygorii Strashko
2018-03-28 19:01     ` [net-next,v2,01/10] " Grygorii Strashko
2018-03-29 14:50     ` Murali Karicheri
2018-03-29 14:50       ` [net-next, v2, 01/10] " Murali Karicheri
2018-03-29 14:50       ` Murali Karicheri
2018-03-29 14:50       ` Murali Karicheri
2018-03-29 14:59     ` [net-next,v2,01/10] " Murali Karicheri
2018-03-29 14:59       ` [net-next, v2, 01/10] " Murali Karicheri
2018-03-29 14:59       ` [net-next,v2,01/10] " Murali Karicheri
2018-03-27 16:31 ` [net-next PATCH v2 02/10] soc: ti: K2G: provide APIs to support driver probe deferral Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31 ` [net-next PATCH v2 03/10] net: netcp: ethss: make call to gbe_sgmii_config() conditional Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 17:13   ` Andrew Lunn
2018-03-27 17:13     ` Andrew Lunn
2018-03-27 19:20     ` Murali Karicheri
2018-03-27 19:20       ` Murali Karicheri
2018-03-27 19:20       ` Murali Karicheri
2018-03-27 17:18   ` Andrew Lunn
2018-03-27 17:18     ` Andrew Lunn
2018-03-27 17:18     ` Andrew Lunn
2018-03-27 19:39     ` Murali Karicheri
2018-03-27 19:39       ` Murali Karicheri
2018-03-27 19:39       ` Murali Karicheri
2018-03-29 16:27     ` Murali Karicheri
2018-03-29 16:27       ` Murali Karicheri
2018-03-29 16:27       ` Murali Karicheri
2018-03-27 16:31 ` [net-next PATCH v2 04/10] net: netcp: ethss: add support for handling sgmii link interface Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31 ` [net-next PATCH v2 05/10] net: netcp: ethss: use rgmii link status for 2u cpsw hardware Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 17:29   ` Andrew Lunn
2018-03-27 17:29     ` Andrew Lunn
2018-03-27 21:07     ` Murali Karicheri
2018-03-27 21:07       ` Murali Karicheri
2018-03-27 21:07       ` Murali Karicheri
2018-03-29 16:35     ` Murali Karicheri
2018-03-29 16:35       ` Murali Karicheri
2018-03-29 16:35       ` Murali Karicheri
2018-03-27 16:31 ` [net-next PATCH v2 06/10] net: netcp: ethss: map vlan priorities to zero flow Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31 ` [net-next PATCH v2 07/10] net: netcp: ethss: re-use stats handling code for 2u hardware Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31 ` [net-next PATCH v2 08/10] net: netcp: ethss: use of_get_phy_mode() to support different RGMII modes Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 17:35   ` Andrew Lunn
2018-03-27 17:35     ` Andrew Lunn
2018-03-29 20:03     ` Murali Karicheri
2018-03-29 20:03       ` Murali Karicheri
2018-03-29 20:03       ` Murali Karicheri
2018-03-27 16:31 ` [net-next PATCH v2 09/10] Revert "net: netcp: remove dead code from the driver" Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31 ` [net-next PATCH v2 10/10] net: netcp: support probe deferral Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri
2018-03-27 16:31   ` Murali Karicheri

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.