All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-13  3:14 ` Kejian Yan
  0 siblings, 0 replies; 32+ messages in thread
From: Kejian Yan @ 2016-01-13  3:14 UTC (permalink / raw)
  To: davem, robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	catalin.marinas, will.deacon, huangdaode, liguozhu, arnd,
	fengguang.wu, salil.mehta, andriy.shevchenko, lisheng011
  Cc: haifeng.wei, netdev, devicetree, linux-kernel, linux-arm-kernel,
	linuxarm

This patch replace the assoication between dsaf and enet from string
matching to object reference. It requires the DTS to be updated within
BIOS. Thanks god it can be done for all released boards.

Signed-off-by: Kejian Yan <yankejian@huawei.com>
---
change log:
v2:
 merge the two patches into one to allow bisection.

v1:
 first submit.

v1 patch reference:
 https://lkml.org/lkml/2015/12/5/11
 https://lkml.org/lkml/2015/12/5/12
---
 .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
 .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------
 drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
 drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
 drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
 drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
 10 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
index 80411b2..ecacfa4 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
@@ -4,8 +4,6 @@ Required properties:
 - compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2".
   "hisilicon,hns-dsaf-v1" is for hip05.
   "hisilicon,hns-dsaf-v2" is for Hi1610 and Hi1612.
-- dsa-name: dsa fabric name who provide this interface.
-  should be "dsafX", X is the dsaf id.
 - mode: dsa fabric mode string. only support one of dsaf modes like these:
 		"2port-64vf",
 		"6port-16rss",
@@ -26,9 +24,8 @@ Required properties:
 
 Example:
 
-dsa: dsa@c7000000 {
+dsaf0: dsa@c7000000 {
 	compatible = "hisilicon,hns-dsaf-v1";
-	dsa_name = "dsaf0";
 	mode = "6port-16rss";
 	interrupt-parent = <&mbigen_dsa>;
 	reg = <0x0 0xC0000000 0x0 0x420000
diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
index 41d19be..e6a9d1c 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
@@ -4,8 +4,9 @@ Required properties:
 - compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2".
   "hisilicon,hns-nic-v1" is for hip05.
   "hisilicon,hns-nic-v2" is for Hi1610 and Hi1612.
-- ae-name: accelerator name who provides this interface,
-  is simply a name referring to the name of name in the accelerator node.
+- ae-handle: accelerator engine handle for hns,
+  specifies a reference to the associating hardware driver node.
+  see Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
 - port-id: is the index of port provided by DSAF (the accelerator). DSAF can
   connect to 8 PHYs. Port 0 to 1 are both used for adminstration purpose. They
   are called debug ports.
@@ -41,7 +42,7 @@ Example:
 
 	ethernet@0{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <0>;
 		local-mac-address = [a2 14 e4 4b 56 76];
 	};
diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
index 606dd5a..89c883e 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
@@ -23,9 +23,8 @@ soc0: soc@000000000 {
 		};
 	};
 
-	dsa: dsa@c7000000 {
+	dsaf0: dsa@c7000000 {
 		compatible = "hisilicon,hns-dsaf-v1";
-		dsa_name = "dsaf0";
 		mode = "6port-16rss";
 		interrupt-parent = <&mbigen_dsa>;
 
@@ -127,7 +126,7 @@ soc0: soc@000000000 {
 
 	eth0: ethernet@0{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <0>;
 		local-mac-address = [00 00 00 01 00 58];
 		status = "disabled";
@@ -135,14 +134,14 @@ soc0: soc@000000000 {
 	};
 	eth1: ethernet@1{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <1>;
 		status = "disabled";
 		dma-coherent;
 	};
 	eth2: ethernet@2{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <2>;
 		local-mac-address = [00 00 00 01 00 5a];
 		status = "disabled";
@@ -150,7 +149,7 @@ soc0: soc@000000000 {
 	};
 	eth3: ethernet@3{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <3>;
 		local-mac-address = [00 00 00 01 00 5b];
 		status = "disabled";
@@ -158,7 +157,7 @@ soc0: soc@000000000 {
 	};
 	eth4: ethernet@4{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <4>;
 		local-mac-address = [00 00 00 01 00 5c];
 		status = "disabled";
@@ -166,7 +165,7 @@ soc0: soc@000000000 {
 	};
 	eth5: ethernet@5{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <5>;
 		local-mac-address = [00 00 00 01 00 5d];
 		status = "disabled";
@@ -174,7 +173,7 @@ soc0: soc@000000000 {
 	};
 	eth6: ethernet@6{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <6>;
 		local-mac-address = [00 00 00 01 00 5e];
 		status = "disabled";
@@ -182,7 +181,7 @@ soc0: soc@000000000 {
 	};
 	eth7: ethernet@7{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <7>;
 		local-mac-address = [00 00 00 01 00 5f];
 		status = "disabled";
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
index b364529..3bfe36f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.c
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
@@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = {
 static int __ae_match(struct device *dev, const void *data)
 {
 	struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
-	const char *ae_id = data;
 
-	if (!strncmp(ae_id, hdev->name, AE_NAME_SIZE))
-		return 1;
-
-	return 0;
+	return hdev->dev->of_node == data;
 }
 
-static struct hnae_ae_dev *find_ae(const char *ae_id)
+static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
 {
 	struct device *dev;
 
-	WARN_ON(!ae_id);
+	WARN_ON(!ae_node);
 
-	dev = class_find_device(hnae_class, NULL, ae_id, __ae_match);
+	dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
 
 	return dev ? cls_to_ae_dev(dev) : NULL;
 }
@@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle);
  * return handle ptr or ERR_PTR
  */
 struct hnae_handle *hnae_get_handle(struct device *owner_dev,
-				    const char *ae_id, u32 port_id,
+				    const struct device_node *ae_node,
+				    u32 port_id,
 				    struct hnae_buf_ops *bops)
 {
 	struct hnae_ae_dev *dev;
@@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
 	int i, j;
 	int ret;
 
-	dev = find_ae(ae_id);
+	dev = find_ae(ae_node);
 	if (!dev)
 		return ERR_PTR(-ENODEV);
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
index 6ca94dc..1cbcb9f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -524,8 +524,11 @@ struct hnae_handle {
 
 #define ring_to_dev(ring) ((ring)->q->dev->dev)
 
-struct hnae_handle *hnae_get_handle(struct device *owner_dev, const char *ae_id,
-				    u32 port_id, struct hnae_buf_ops *bops);
+struct hnae_handle *hnae_get_handle(struct device *owner_dev,
+				    const struct device_node *ae_node,
+				    u32 port_id,
+				    struct hnae_buf_ops *bops);
+
 void hnae_put_handle(struct hnae_handle *handle);
 int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
 void hnae_ae_unregister(struct hnae_ae_dev *dev);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index 522b264..a0070d0 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
 int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
 {
 	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
+	static atomic_t id = ATOMIC_INIT(-1);
 
 	switch (dsaf_dev->dsaf_ver) {
 	case AE_VERSION_1:
@@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
 	default:
 		break;
 	}
+
+	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d", DSAF_DEVICE_NAME,
+		 (int)atomic_inc_return(&id));
 	ae_dev->ops = &hns_dsaf_ops;
 	ae_dev->dev = dsaf_dev->dev;
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 1c33bd0..9439f04 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
 	int ret, i;
 	u32 desc_num;
 	u32 buf_size;
-	const char *name, *mode_str;
+	const char *mode_str;
 	struct device_node *np = dsaf_dev->dev->of_node;
 
 	if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
@@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
 	else
 		dsaf_dev->dsaf_ver = AE_VERSION_2;
 
-	ret = of_property_read_string(np, "dsa_name", &name);
-	if (ret) {
-		dev_err(dsaf_dev->dev, "get dsaf name fail, ret=%d!\n", ret);
-		return ret;
-	}
-	strncpy(dsaf_dev->ae_dev.name, name, AE_NAME_SIZE);
-	dsaf_dev->ae_dev.name[AE_NAME_SIZE - 1] = '\0';
-
 	ret = of_property_read_string(np, "mode", &mode_str);
 	if (ret) {
 		dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
index 31c312f..40205b9 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
@@ -18,6 +18,7 @@ struct hns_mac_cb;
 
 #define DSAF_DRV_NAME "hns_dsaf"
 #define DSAF_MOD_VERSION "v1.0"
+#define DSAF_DEVICE_NAME "dsaf"
 
 #define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 0e30846..340ca54 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
 	int ret;
 
 	h = hnae_get_handle(&priv->netdev->dev,
-			    priv->ae_name, priv->port_id, NULL);
+			    priv->ae_node, priv->port_id, NULL);
 	if (IS_ERR_OR_NULL(h)) {
 		ret = PTR_ERR(h);
 		dev_dbg(priv->dev, "has not handle, register notifier!\n");
@@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 	else
 		priv->enet_ver = AE_VERSION_2;
 
-	ret = of_property_read_string(node, "ae-name", &priv->ae_name);
-	if (ret)
-		goto out_read_string_fail;
+	priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
+	if (IS_ERR_OR_NULL(priv->ae_node)) {
+		ret = PTR_ERR(priv->ae_node);
+		dev_err(dev, "not find ae-handle\n");
+		goto out_read_handle_fai;
+	}
 
 	ret = of_property_read_u32(node, "port-id", &priv->port_id);
 	if (ret)
@@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 
 out_notify_fail:
 	(void)cancel_work_sync(&priv->service_task);
+out_read_handle_fai:
+
 out_read_string_fail:
 	free_netdev(ndev);
 	return ret;
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.h b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
index 4b75270..c68ab3d 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
@@ -51,7 +51,7 @@ struct hns_nic_ops {
 };
 
 struct hns_nic_priv {
-	const char *ae_name;
+	const struct device_node *ae_node;
 	u32 enet_ver;
 	u32 port_id;
 	int phy_mode;
-- 
2.4.1

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

* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-13  3:14 ` Kejian Yan
  0 siblings, 0 replies; 32+ messages in thread
From: Kejian Yan @ 2016-01-13  3:14 UTC (permalink / raw)
  To: davem, robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	catalin.marinas, will.deacon, huangdaode, liguozhu, arnd,
	fengguang.wu, salil.mehta, andriy.shevchenko, lisheng011
  Cc: haifeng.wei, netdev, devicetree, linux-kernel, linux-arm-kernel,
	linuxarm

This patch replace the assoication between dsaf and enet from string
matching to object reference. It requires the DTS to be updated within
BIOS. Thanks god it can be done for all released boards.

Signed-off-by: Kejian Yan <yankejian@huawei.com>
---
change log:
v2:
 merge the two patches into one to allow bisection.

v1:
 first submit.

v1 patch reference:
 https://lkml.org/lkml/2015/12/5/11
 https://lkml.org/lkml/2015/12/5/12
---
 .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
 .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------
 drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
 drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
 drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
 drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
 10 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
index 80411b2..ecacfa4 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
@@ -4,8 +4,6 @@ Required properties:
 - compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2".
   "hisilicon,hns-dsaf-v1" is for hip05.
   "hisilicon,hns-dsaf-v2" is for Hi1610 and Hi1612.
-- dsa-name: dsa fabric name who provide this interface.
-  should be "dsafX", X is the dsaf id.
 - mode: dsa fabric mode string. only support one of dsaf modes like these:
 		"2port-64vf",
 		"6port-16rss",
@@ -26,9 +24,8 @@ Required properties:
 
 Example:
 
-dsa: dsa@c7000000 {
+dsaf0: dsa@c7000000 {
 	compatible = "hisilicon,hns-dsaf-v1";
-	dsa_name = "dsaf0";
 	mode = "6port-16rss";
 	interrupt-parent = <&mbigen_dsa>;
 	reg = <0x0 0xC0000000 0x0 0x420000
diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
index 41d19be..e6a9d1c 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
@@ -4,8 +4,9 @@ Required properties:
 - compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2".
   "hisilicon,hns-nic-v1" is for hip05.
   "hisilicon,hns-nic-v2" is for Hi1610 and Hi1612.
-- ae-name: accelerator name who provides this interface,
-  is simply a name referring to the name of name in the accelerator node.
+- ae-handle: accelerator engine handle for hns,
+  specifies a reference to the associating hardware driver node.
+  see Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
 - port-id: is the index of port provided by DSAF (the accelerator). DSAF can
   connect to 8 PHYs. Port 0 to 1 are both used for adminstration purpose. They
   are called debug ports.
@@ -41,7 +42,7 @@ Example:
 
 	ethernet@0{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <0>;
 		local-mac-address = [a2 14 e4 4b 56 76];
 	};
diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
index 606dd5a..89c883e 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
@@ -23,9 +23,8 @@ soc0: soc@000000000 {
 		};
 	};
 
-	dsa: dsa@c7000000 {
+	dsaf0: dsa@c7000000 {
 		compatible = "hisilicon,hns-dsaf-v1";
-		dsa_name = "dsaf0";
 		mode = "6port-16rss";
 		interrupt-parent = <&mbigen_dsa>;
 
@@ -127,7 +126,7 @@ soc0: soc@000000000 {
 
 	eth0: ethernet@0{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <0>;
 		local-mac-address = [00 00 00 01 00 58];
 		status = "disabled";
@@ -135,14 +134,14 @@ soc0: soc@000000000 {
 	};
 	eth1: ethernet@1{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <1>;
 		status = "disabled";
 		dma-coherent;
 	};
 	eth2: ethernet@2{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <2>;
 		local-mac-address = [00 00 00 01 00 5a];
 		status = "disabled";
@@ -150,7 +149,7 @@ soc0: soc@000000000 {
 	};
 	eth3: ethernet@3{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <3>;
 		local-mac-address = [00 00 00 01 00 5b];
 		status = "disabled";
@@ -158,7 +157,7 @@ soc0: soc@000000000 {
 	};
 	eth4: ethernet@4{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <4>;
 		local-mac-address = [00 00 00 01 00 5c];
 		status = "disabled";
@@ -166,7 +165,7 @@ soc0: soc@000000000 {
 	};
 	eth5: ethernet@5{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <5>;
 		local-mac-address = [00 00 00 01 00 5d];
 		status = "disabled";
@@ -174,7 +173,7 @@ soc0: soc@000000000 {
 	};
 	eth6: ethernet@6{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <6>;
 		local-mac-address = [00 00 00 01 00 5e];
 		status = "disabled";
@@ -182,7 +181,7 @@ soc0: soc@000000000 {
 	};
 	eth7: ethernet@7{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <7>;
 		local-mac-address = [00 00 00 01 00 5f];
 		status = "disabled";
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
index b364529..3bfe36f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.c
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
@@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = {
 static int __ae_match(struct device *dev, const void *data)
 {
 	struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
-	const char *ae_id = data;
 
-	if (!strncmp(ae_id, hdev->name, AE_NAME_SIZE))
-		return 1;
-
-	return 0;
+	return hdev->dev->of_node == data;
 }
 
-static struct hnae_ae_dev *find_ae(const char *ae_id)
+static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
 {
 	struct device *dev;
 
-	WARN_ON(!ae_id);
+	WARN_ON(!ae_node);
 
-	dev = class_find_device(hnae_class, NULL, ae_id, __ae_match);
+	dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
 
 	return dev ? cls_to_ae_dev(dev) : NULL;
 }
@@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle);
  * return handle ptr or ERR_PTR
  */
 struct hnae_handle *hnae_get_handle(struct device *owner_dev,
-				    const char *ae_id, u32 port_id,
+				    const struct device_node *ae_node,
+				    u32 port_id,
 				    struct hnae_buf_ops *bops)
 {
 	struct hnae_ae_dev *dev;
@@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
 	int i, j;
 	int ret;
 
-	dev = find_ae(ae_id);
+	dev = find_ae(ae_node);
 	if (!dev)
 		return ERR_PTR(-ENODEV);
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
index 6ca94dc..1cbcb9f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -524,8 +524,11 @@ struct hnae_handle {
 
 #define ring_to_dev(ring) ((ring)->q->dev->dev)
 
-struct hnae_handle *hnae_get_handle(struct device *owner_dev, const char *ae_id,
-				    u32 port_id, struct hnae_buf_ops *bops);
+struct hnae_handle *hnae_get_handle(struct device *owner_dev,
+				    const struct device_node *ae_node,
+				    u32 port_id,
+				    struct hnae_buf_ops *bops);
+
 void hnae_put_handle(struct hnae_handle *handle);
 int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
 void hnae_ae_unregister(struct hnae_ae_dev *dev);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index 522b264..a0070d0 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
 int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
 {
 	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
+	static atomic_t id = ATOMIC_INIT(-1);
 
 	switch (dsaf_dev->dsaf_ver) {
 	case AE_VERSION_1:
@@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
 	default:
 		break;
 	}
+
+	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d", DSAF_DEVICE_NAME,
+		 (int)atomic_inc_return(&id));
 	ae_dev->ops = &hns_dsaf_ops;
 	ae_dev->dev = dsaf_dev->dev;
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 1c33bd0..9439f04 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
 	int ret, i;
 	u32 desc_num;
 	u32 buf_size;
-	const char *name, *mode_str;
+	const char *mode_str;
 	struct device_node *np = dsaf_dev->dev->of_node;
 
 	if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
@@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
 	else
 		dsaf_dev->dsaf_ver = AE_VERSION_2;
 
-	ret = of_property_read_string(np, "dsa_name", &name);
-	if (ret) {
-		dev_err(dsaf_dev->dev, "get dsaf name fail, ret=%d!\n", ret);
-		return ret;
-	}
-	strncpy(dsaf_dev->ae_dev.name, name, AE_NAME_SIZE);
-	dsaf_dev->ae_dev.name[AE_NAME_SIZE - 1] = '\0';
-
 	ret = of_property_read_string(np, "mode", &mode_str);
 	if (ret) {
 		dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
index 31c312f..40205b9 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
@@ -18,6 +18,7 @@ struct hns_mac_cb;
 
 #define DSAF_DRV_NAME "hns_dsaf"
 #define DSAF_MOD_VERSION "v1.0"
+#define DSAF_DEVICE_NAME "dsaf"
 
 #define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 0e30846..340ca54 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
 	int ret;
 
 	h = hnae_get_handle(&priv->netdev->dev,
-			    priv->ae_name, priv->port_id, NULL);
+			    priv->ae_node, priv->port_id, NULL);
 	if (IS_ERR_OR_NULL(h)) {
 		ret = PTR_ERR(h);
 		dev_dbg(priv->dev, "has not handle, register notifier!\n");
@@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 	else
 		priv->enet_ver = AE_VERSION_2;
 
-	ret = of_property_read_string(node, "ae-name", &priv->ae_name);
-	if (ret)
-		goto out_read_string_fail;
+	priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
+	if (IS_ERR_OR_NULL(priv->ae_node)) {
+		ret = PTR_ERR(priv->ae_node);
+		dev_err(dev, "not find ae-handle\n");
+		goto out_read_handle_fai;
+	}
 
 	ret = of_property_read_u32(node, "port-id", &priv->port_id);
 	if (ret)
@@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 
 out_notify_fail:
 	(void)cancel_work_sync(&priv->service_task);
+out_read_handle_fai:
+
 out_read_string_fail:
 	free_netdev(ndev);
 	return ret;
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.h b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
index 4b75270..c68ab3d 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
@@ -51,7 +51,7 @@ struct hns_nic_ops {
 };
 
 struct hns_nic_priv {
-	const char *ae_name;
+	const struct device_node *ae_node;
 	u32 enet_ver;
 	u32 port_id;
 	int phy_mode;
-- 
2.4.1

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

* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-13  3:14 ` Kejian Yan
  0 siblings, 0 replies; 32+ messages in thread
From: Kejian Yan @ 2016-01-13  3:14 UTC (permalink / raw)
  To: linux-arm-kernel

This patch replace the assoication between dsaf and enet from string
matching to object reference. It requires the DTS to be updated within
BIOS. Thanks god it can be done for all released boards.

Signed-off-by: Kejian Yan <yankejian@huawei.com>
---
change log:
v2:
 merge the two patches into one to allow bisection.

v1:
 first submit.

v1 patch reference:
 https://lkml.org/lkml/2015/12/5/11
 https://lkml.org/lkml/2015/12/5/12
---
 .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
 .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------
 drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
 drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
 drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
 drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
 10 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
index 80411b2..ecacfa4 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
@@ -4,8 +4,6 @@ Required properties:
 - compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2".
   "hisilicon,hns-dsaf-v1" is for hip05.
   "hisilicon,hns-dsaf-v2" is for Hi1610 and Hi1612.
-- dsa-name: dsa fabric name who provide this interface.
-  should be "dsafX", X is the dsaf id.
 - mode: dsa fabric mode string. only support one of dsaf modes like these:
 		"2port-64vf",
 		"6port-16rss",
@@ -26,9 +24,8 @@ Required properties:
 
 Example:
 
-dsa: dsa at c7000000 {
+dsaf0: dsa at c7000000 {
 	compatible = "hisilicon,hns-dsaf-v1";
-	dsa_name = "dsaf0";
 	mode = "6port-16rss";
 	interrupt-parent = <&mbigen_dsa>;
 	reg = <0x0 0xC0000000 0x0 0x420000
diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
index 41d19be..e6a9d1c 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
@@ -4,8 +4,9 @@ Required properties:
 - compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2".
   "hisilicon,hns-nic-v1" is for hip05.
   "hisilicon,hns-nic-v2" is for Hi1610 and Hi1612.
-- ae-name: accelerator name who provides this interface,
-  is simply a name referring to the name of name in the accelerator node.
+- ae-handle: accelerator engine handle for hns,
+  specifies a reference to the associating hardware driver node.
+  see Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
 - port-id: is the index of port provided by DSAF (the accelerator). DSAF can
   connect to 8 PHYs. Port 0 to 1 are both used for adminstration purpose. They
   are called debug ports.
@@ -41,7 +42,7 @@ Example:
 
 	ethernet@0{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <0>;
 		local-mac-address = [a2 14 e4 4b 56 76];
 	};
diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
index 606dd5a..89c883e 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
@@ -23,9 +23,8 @@ soc0: soc at 000000000 {
 		};
 	};
 
-	dsa: dsa at c7000000 {
+	dsaf0: dsa at c7000000 {
 		compatible = "hisilicon,hns-dsaf-v1";
-		dsa_name = "dsaf0";
 		mode = "6port-16rss";
 		interrupt-parent = <&mbigen_dsa>;
 
@@ -127,7 +126,7 @@ soc0: soc at 000000000 {
 
 	eth0: ethernet at 0{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <0>;
 		local-mac-address = [00 00 00 01 00 58];
 		status = "disabled";
@@ -135,14 +134,14 @@ soc0: soc at 000000000 {
 	};
 	eth1: ethernet at 1{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <1>;
 		status = "disabled";
 		dma-coherent;
 	};
 	eth2: ethernet at 2{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <2>;
 		local-mac-address = [00 00 00 01 00 5a];
 		status = "disabled";
@@ -150,7 +149,7 @@ soc0: soc at 000000000 {
 	};
 	eth3: ethernet at 3{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <3>;
 		local-mac-address = [00 00 00 01 00 5b];
 		status = "disabled";
@@ -158,7 +157,7 @@ soc0: soc at 000000000 {
 	};
 	eth4: ethernet at 4{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <4>;
 		local-mac-address = [00 00 00 01 00 5c];
 		status = "disabled";
@@ -166,7 +165,7 @@ soc0: soc at 000000000 {
 	};
 	eth5: ethernet at 5{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <5>;
 		local-mac-address = [00 00 00 01 00 5d];
 		status = "disabled";
@@ -174,7 +173,7 @@ soc0: soc at 000000000 {
 	};
 	eth6: ethernet at 6{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <6>;
 		local-mac-address = [00 00 00 01 00 5e];
 		status = "disabled";
@@ -182,7 +181,7 @@ soc0: soc at 000000000 {
 	};
 	eth7: ethernet at 7{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <7>;
 		local-mac-address = [00 00 00 01 00 5f];
 		status = "disabled";
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
index b364529..3bfe36f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.c
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
@@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = {
 static int __ae_match(struct device *dev, const void *data)
 {
 	struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
-	const char *ae_id = data;
 
-	if (!strncmp(ae_id, hdev->name, AE_NAME_SIZE))
-		return 1;
-
-	return 0;
+	return hdev->dev->of_node == data;
 }
 
-static struct hnae_ae_dev *find_ae(const char *ae_id)
+static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
 {
 	struct device *dev;
 
-	WARN_ON(!ae_id);
+	WARN_ON(!ae_node);
 
-	dev = class_find_device(hnae_class, NULL, ae_id, __ae_match);
+	dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
 
 	return dev ? cls_to_ae_dev(dev) : NULL;
 }
@@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle);
  * return handle ptr or ERR_PTR
  */
 struct hnae_handle *hnae_get_handle(struct device *owner_dev,
-				    const char *ae_id, u32 port_id,
+				    const struct device_node *ae_node,
+				    u32 port_id,
 				    struct hnae_buf_ops *bops)
 {
 	struct hnae_ae_dev *dev;
@@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
 	int i, j;
 	int ret;
 
-	dev = find_ae(ae_id);
+	dev = find_ae(ae_node);
 	if (!dev)
 		return ERR_PTR(-ENODEV);
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
index 6ca94dc..1cbcb9f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -524,8 +524,11 @@ struct hnae_handle {
 
 #define ring_to_dev(ring) ((ring)->q->dev->dev)
 
-struct hnae_handle *hnae_get_handle(struct device *owner_dev, const char *ae_id,
-				    u32 port_id, struct hnae_buf_ops *bops);
+struct hnae_handle *hnae_get_handle(struct device *owner_dev,
+				    const struct device_node *ae_node,
+				    u32 port_id,
+				    struct hnae_buf_ops *bops);
+
 void hnae_put_handle(struct hnae_handle *handle);
 int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
 void hnae_ae_unregister(struct hnae_ae_dev *dev);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index 522b264..a0070d0 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
 int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
 {
 	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
+	static atomic_t id = ATOMIC_INIT(-1);
 
 	switch (dsaf_dev->dsaf_ver) {
 	case AE_VERSION_1:
@@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
 	default:
 		break;
 	}
+
+	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d", DSAF_DEVICE_NAME,
+		 (int)atomic_inc_return(&id));
 	ae_dev->ops = &hns_dsaf_ops;
 	ae_dev->dev = dsaf_dev->dev;
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 1c33bd0..9439f04 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
 	int ret, i;
 	u32 desc_num;
 	u32 buf_size;
-	const char *name, *mode_str;
+	const char *mode_str;
 	struct device_node *np = dsaf_dev->dev->of_node;
 
 	if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
@@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
 	else
 		dsaf_dev->dsaf_ver = AE_VERSION_2;
 
-	ret = of_property_read_string(np, "dsa_name", &name);
-	if (ret) {
-		dev_err(dsaf_dev->dev, "get dsaf name fail, ret=%d!\n", ret);
-		return ret;
-	}
-	strncpy(dsaf_dev->ae_dev.name, name, AE_NAME_SIZE);
-	dsaf_dev->ae_dev.name[AE_NAME_SIZE - 1] = '\0';
-
 	ret = of_property_read_string(np, "mode", &mode_str);
 	if (ret) {
 		dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
index 31c312f..40205b9 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
@@ -18,6 +18,7 @@ struct hns_mac_cb;
 
 #define DSAF_DRV_NAME "hns_dsaf"
 #define DSAF_MOD_VERSION "v1.0"
+#define DSAF_DEVICE_NAME "dsaf"
 
 #define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 0e30846..340ca54 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
 	int ret;
 
 	h = hnae_get_handle(&priv->netdev->dev,
-			    priv->ae_name, priv->port_id, NULL);
+			    priv->ae_node, priv->port_id, NULL);
 	if (IS_ERR_OR_NULL(h)) {
 		ret = PTR_ERR(h);
 		dev_dbg(priv->dev, "has not handle, register notifier!\n");
@@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 	else
 		priv->enet_ver = AE_VERSION_2;
 
-	ret = of_property_read_string(node, "ae-name", &priv->ae_name);
-	if (ret)
-		goto out_read_string_fail;
+	priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
+	if (IS_ERR_OR_NULL(priv->ae_node)) {
+		ret = PTR_ERR(priv->ae_node);
+		dev_err(dev, "not find ae-handle\n");
+		goto out_read_handle_fai;
+	}
 
 	ret = of_property_read_u32(node, "port-id", &priv->port_id);
 	if (ret)
@@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 
 out_notify_fail:
 	(void)cancel_work_sync(&priv->service_task);
+out_read_handle_fai:
+
 out_read_string_fail:
 	free_netdev(ndev);
 	return ret;
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.h b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
index 4b75270..c68ab3d 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
@@ -51,7 +51,7 @@ struct hns_nic_ops {
 };
 
 struct hns_nic_priv {
-	const char *ae_name;
+	const struct device_node *ae_node;
 	u32 enet_ver;
 	u32 port_id;
 	int phy_mode;
-- 
2.4.1

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
  2016-01-13  3:14 ` Kejian Yan
  (?)
@ 2016-01-14  3:00   ` Yisen Zhuang
  -1 siblings, 0 replies; 32+ messages in thread
From: Yisen Zhuang @ 2016-01-14  3:00 UTC (permalink / raw)
  To: Kejian Yan, davem, robh+dt, pawel.moll, mark.rutland,
	ijc+devicetree, galak, catalin.marinas, will.deacon, huangdaode,
	liguozhu, arnd, fengguang.wu, salil.mehta, andriy.shevchenko,
	lisheng011
  Cc: devicetree, netdev, linuxarm, linux-kernel, linux-arm-kernel



在 2016/1/13 11:14, Kejian Yan 写道:
> This patch replace the assoication between dsaf and enet from string
> matching to object reference. It requires the DTS to be updated within
> BIOS. Thanks god it can be done for all released boards.
> 

Hi kejian,

This patch is fine to me.

Many thanks,

Yisen

> Signed-off-by: Kejian Yan <yankejian@huawei.com>
> ---
> change log:
> v2:
>  merge the two patches into one to allow bisection.
> 
> v1:
>  first submit.
> 
> v1 patch reference:
>  https://lkml.org/lkml/2015/12/5/11
>  https://lkml.org/lkml/2015/12/5/12
> ---
>  .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
>  .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
>  arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
>  drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
>  drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
>  drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
>  10 files changed, 42 insertions(+), 43 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> index 80411b2..ecacfa4 100644
> --- a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> +++ b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> @@ -4,8 +4,6 @@ Required properties:
>  - compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2".
>    "hisilicon,hns-dsaf-v1" is for hip05.
>    "hisilicon,hns-dsaf-v2" is for Hi1610 and Hi1612.
> -- dsa-name: dsa fabric name who provide this interface.
> -  should be "dsafX", X is the dsaf id.
>  - mode: dsa fabric mode string. only support one of dsaf modes like these:
>  		"2port-64vf",
>  		"6port-16rss",
> @@ -26,9 +24,8 @@ Required properties:
>  
>  Example:
>  
> -dsa: dsa@c7000000 {
> +dsaf0: dsa@c7000000 {
>  	compatible = "hisilicon,hns-dsaf-v1";
> -	dsa_name = "dsaf0";
>  	mode = "6port-16rss";
>  	interrupt-parent = <&mbigen_dsa>;
>  	reg = <0x0 0xC0000000 0x0 0x420000
> diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> index 41d19be..e6a9d1c 100644
> --- a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> +++ b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> @@ -4,8 +4,9 @@ Required properties:
>  - compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2".
>    "hisilicon,hns-nic-v1" is for hip05.
>    "hisilicon,hns-nic-v2" is for Hi1610 and Hi1612.
> -- ae-name: accelerator name who provides this interface,
> -  is simply a name referring to the name of name in the accelerator node.
> +- ae-handle: accelerator engine handle for hns,
> +  specifies a reference to the associating hardware driver node.
> +  see Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
>  - port-id: is the index of port provided by DSAF (the accelerator). DSAF can
>    connect to 8 PHYs. Port 0 to 1 are both used for adminstration purpose. They
>    are called debug ports.
> @@ -41,7 +42,7 @@ Example:
>  
>  	ethernet@0{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <0>;
>  		local-mac-address = [a2 14 e4 4b 56 76];
>  	};
> diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> index 606dd5a..89c883e 100644
> --- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> +++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> @@ -23,9 +23,8 @@ soc0: soc@000000000 {
>  		};
>  	};
>  
> -	dsa: dsa@c7000000 {
> +	dsaf0: dsa@c7000000 {
>  		compatible = "hisilicon,hns-dsaf-v1";
> -		dsa_name = "dsaf0";
>  		mode = "6port-16rss";
>  		interrupt-parent = <&mbigen_dsa>;
>  
> @@ -127,7 +126,7 @@ soc0: soc@000000000 {
>  
>  	eth0: ethernet@0{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <0>;
>  		local-mac-address = [00 00 00 01 00 58];
>  		status = "disabled";
> @@ -135,14 +134,14 @@ soc0: soc@000000000 {
>  	};
>  	eth1: ethernet@1{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <1>;
>  		status = "disabled";
>  		dma-coherent;
>  	};
>  	eth2: ethernet@2{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <2>;
>  		local-mac-address = [00 00 00 01 00 5a];
>  		status = "disabled";
> @@ -150,7 +149,7 @@ soc0: soc@000000000 {
>  	};
>  	eth3: ethernet@3{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <3>;
>  		local-mac-address = [00 00 00 01 00 5b];
>  		status = "disabled";
> @@ -158,7 +157,7 @@ soc0: soc@000000000 {
>  	};
>  	eth4: ethernet@4{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <4>;
>  		local-mac-address = [00 00 00 01 00 5c];
>  		status = "disabled";
> @@ -166,7 +165,7 @@ soc0: soc@000000000 {
>  	};
>  	eth5: ethernet@5{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <5>;
>  		local-mac-address = [00 00 00 01 00 5d];
>  		status = "disabled";
> @@ -174,7 +173,7 @@ soc0: soc@000000000 {
>  	};
>  	eth6: ethernet@6{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <6>;
>  		local-mac-address = [00 00 00 01 00 5e];
>  		status = "disabled";
> @@ -182,7 +181,7 @@ soc0: soc@000000000 {
>  	};
>  	eth7: ethernet@7{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <7>;
>  		local-mac-address = [00 00 00 01 00 5f];
>  		status = "disabled";
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
> index b364529..3bfe36f 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
> @@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = {
>  static int __ae_match(struct device *dev, const void *data)
>  {
>  	struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
> -	const char *ae_id = data;
>  
> -	if (!strncmp(ae_id, hdev->name, AE_NAME_SIZE))
> -		return 1;
> -
> -	return 0;
> +	return hdev->dev->of_node == data;
>  }
>  
> -static struct hnae_ae_dev *find_ae(const char *ae_id)
> +static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
>  {
>  	struct device *dev;
>  
> -	WARN_ON(!ae_id);
> +	WARN_ON(!ae_node);
>  
> -	dev = class_find_device(hnae_class, NULL, ae_id, __ae_match);
> +	dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
>  
>  	return dev ? cls_to_ae_dev(dev) : NULL;
>  }
> @@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle);
>   * return handle ptr or ERR_PTR
>   */
>  struct hnae_handle *hnae_get_handle(struct device *owner_dev,
> -				    const char *ae_id, u32 port_id,
> +				    const struct device_node *ae_node,
> +				    u32 port_id,
>  				    struct hnae_buf_ops *bops)
>  {
>  	struct hnae_ae_dev *dev;
> @@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
>  	int i, j;
>  	int ret;
>  
> -	dev = find_ae(ae_id);
> +	dev = find_ae(ae_node);
>  	if (!dev)
>  		return ERR_PTR(-ENODEV);
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
> index 6ca94dc..1cbcb9f 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
> @@ -524,8 +524,11 @@ struct hnae_handle {
>  
>  #define ring_to_dev(ring) ((ring)->q->dev->dev)
>  
> -struct hnae_handle *hnae_get_handle(struct device *owner_dev, const char *ae_id,
> -				    u32 port_id, struct hnae_buf_ops *bops);
> +struct hnae_handle *hnae_get_handle(struct device *owner_dev,
> +				    const struct device_node *ae_node,
> +				    u32 port_id,
> +				    struct hnae_buf_ops *bops);
> +
>  void hnae_put_handle(struct hnae_handle *handle);
>  int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
>  void hnae_ae_unregister(struct hnae_ae_dev *dev);
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> index 522b264..a0070d0 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
>  int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>  {
>  	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
> +	static atomic_t id = ATOMIC_INIT(-1);
>  
>  	switch (dsaf_dev->dsaf_ver) {
>  	case AE_VERSION_1:
> @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>  	default:
>  		break;
>  	}
> +
> +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d", DSAF_DEVICE_NAME,
> +		 (int)atomic_inc_return(&id));
>  	ae_dev->ops = &hns_dsaf_ops;
>  	ae_dev->dev = dsaf_dev->dev;
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> index 1c33bd0..9439f04 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> @@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
>  	int ret, i;
>  	u32 desc_num;
>  	u32 buf_size;
> -	const char *name, *mode_str;
> +	const char *mode_str;
>  	struct device_node *np = dsaf_dev->dev->of_node;
>  
>  	if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
> @@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
>  	else
>  		dsaf_dev->dsaf_ver = AE_VERSION_2;
>  
> -	ret = of_property_read_string(np, "dsa_name", &name);
> -	if (ret) {
> -		dev_err(dsaf_dev->dev, "get dsaf name fail, ret=%d!\n", ret);
> -		return ret;
> -	}
> -	strncpy(dsaf_dev->ae_dev.name, name, AE_NAME_SIZE);
> -	dsaf_dev->ae_dev.name[AE_NAME_SIZE - 1] = '\0';
> -
>  	ret = of_property_read_string(np, "mode", &mode_str);
>  	if (ret) {
>  		dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> index 31c312f..40205b9 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> @@ -18,6 +18,7 @@ struct hns_mac_cb;
>  
>  #define DSAF_DRV_NAME "hns_dsaf"
>  #define DSAF_MOD_VERSION "v1.0"
> +#define DSAF_DEVICE_NAME "dsaf"
>  
>  #define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> index 0e30846..340ca54 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> @@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
>  	int ret;
>  
>  	h = hnae_get_handle(&priv->netdev->dev,
> -			    priv->ae_name, priv->port_id, NULL);
> +			    priv->ae_node, priv->port_id, NULL);
>  	if (IS_ERR_OR_NULL(h)) {
>  		ret = PTR_ERR(h);
>  		dev_dbg(priv->dev, "has not handle, register notifier!\n");
> @@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
>  	else
>  		priv->enet_ver = AE_VERSION_2;
>  
> -	ret = of_property_read_string(node, "ae-name", &priv->ae_name);
> -	if (ret)
> -		goto out_read_string_fail;
> +	priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
> +	if (IS_ERR_OR_NULL(priv->ae_node)) {
> +		ret = PTR_ERR(priv->ae_node);
> +		dev_err(dev, "not find ae-handle\n");
> +		goto out_read_handle_fai;
> +	}
>  
>  	ret = of_property_read_u32(node, "port-id", &priv->port_id);
>  	if (ret)
> @@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
>  
>  out_notify_fail:
>  	(void)cancel_work_sync(&priv->service_task);
> +out_read_handle_fai:
> +
>  out_read_string_fail:
>  	free_netdev(ndev);
>  	return ret;
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.h b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> index 4b75270..c68ab3d 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> @@ -51,7 +51,7 @@ struct hns_nic_ops {
>  };
>  
>  struct hns_nic_priv {
> -	const char *ae_name;
> +	const struct device_node *ae_node;
>  	u32 enet_ver;
>  	u32 port_id;
>  	int phy_mode;
> 

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-14  3:00   ` Yisen Zhuang
  0 siblings, 0 replies; 32+ messages in thread
From: Yisen Zhuang @ 2016-01-14  3:00 UTC (permalink / raw)
  To: Kejian Yan, davem, robh+dt, pawel.moll, mark.rutland,
	ijc+devicetree, galak, catalin.marinas, will.deacon, huangdaode,
	liguozhu, arnd, fengguang.wu, salil.mehta, andriy.shevchenko,
	lisheng011
  Cc: devicetree, netdev, linuxarm, linux-kernel, linux-arm-kernel



在 2016/1/13 11:14, Kejian Yan 写道:
> This patch replace the assoication between dsaf and enet from string
> matching to object reference. It requires the DTS to be updated within
> BIOS. Thanks god it can be done for all released boards.
> 

Hi kejian,

This patch is fine to me.

Many thanks,

Yisen

> Signed-off-by: Kejian Yan <yankejian@huawei.com>
> ---
> change log:
> v2:
>  merge the two patches into one to allow bisection.
> 
> v1:
>  first submit.
> 
> v1 patch reference:
>  https://lkml.org/lkml/2015/12/5/11
>  https://lkml.org/lkml/2015/12/5/12
> ---
>  .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
>  .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
>  arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
>  drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
>  drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
>  drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
>  10 files changed, 42 insertions(+), 43 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> index 80411b2..ecacfa4 100644
> --- a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> +++ b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> @@ -4,8 +4,6 @@ Required properties:
>  - compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2".
>    "hisilicon,hns-dsaf-v1" is for hip05.
>    "hisilicon,hns-dsaf-v2" is for Hi1610 and Hi1612.
> -- dsa-name: dsa fabric name who provide this interface.
> -  should be "dsafX", X is the dsaf id.
>  - mode: dsa fabric mode string. only support one of dsaf modes like these:
>  		"2port-64vf",
>  		"6port-16rss",
> @@ -26,9 +24,8 @@ Required properties:
>  
>  Example:
>  
> -dsa: dsa@c7000000 {
> +dsaf0: dsa@c7000000 {
>  	compatible = "hisilicon,hns-dsaf-v1";
> -	dsa_name = "dsaf0";
>  	mode = "6port-16rss";
>  	interrupt-parent = <&mbigen_dsa>;
>  	reg = <0x0 0xC0000000 0x0 0x420000
> diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> index 41d19be..e6a9d1c 100644
> --- a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> +++ b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> @@ -4,8 +4,9 @@ Required properties:
>  - compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2".
>    "hisilicon,hns-nic-v1" is for hip05.
>    "hisilicon,hns-nic-v2" is for Hi1610 and Hi1612.
> -- ae-name: accelerator name who provides this interface,
> -  is simply a name referring to the name of name in the accelerator node.
> +- ae-handle: accelerator engine handle for hns,
> +  specifies a reference to the associating hardware driver node.
> +  see Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
>  - port-id: is the index of port provided by DSAF (the accelerator). DSAF can
>    connect to 8 PHYs. Port 0 to 1 are both used for adminstration purpose. They
>    are called debug ports.
> @@ -41,7 +42,7 @@ Example:
>  
>  	ethernet@0{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <0>;
>  		local-mac-address = [a2 14 e4 4b 56 76];
>  	};
> diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> index 606dd5a..89c883e 100644
> --- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> +++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> @@ -23,9 +23,8 @@ soc0: soc@000000000 {
>  		};
>  	};
>  
> -	dsa: dsa@c7000000 {
> +	dsaf0: dsa@c7000000 {
>  		compatible = "hisilicon,hns-dsaf-v1";
> -		dsa_name = "dsaf0";
>  		mode = "6port-16rss";
>  		interrupt-parent = <&mbigen_dsa>;
>  
> @@ -127,7 +126,7 @@ soc0: soc@000000000 {
>  
>  	eth0: ethernet@0{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <0>;
>  		local-mac-address = [00 00 00 01 00 58];
>  		status = "disabled";
> @@ -135,14 +134,14 @@ soc0: soc@000000000 {
>  	};
>  	eth1: ethernet@1{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <1>;
>  		status = "disabled";
>  		dma-coherent;
>  	};
>  	eth2: ethernet@2{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <2>;
>  		local-mac-address = [00 00 00 01 00 5a];
>  		status = "disabled";
> @@ -150,7 +149,7 @@ soc0: soc@000000000 {
>  	};
>  	eth3: ethernet@3{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <3>;
>  		local-mac-address = [00 00 00 01 00 5b];
>  		status = "disabled";
> @@ -158,7 +157,7 @@ soc0: soc@000000000 {
>  	};
>  	eth4: ethernet@4{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <4>;
>  		local-mac-address = [00 00 00 01 00 5c];
>  		status = "disabled";
> @@ -166,7 +165,7 @@ soc0: soc@000000000 {
>  	};
>  	eth5: ethernet@5{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <5>;
>  		local-mac-address = [00 00 00 01 00 5d];
>  		status = "disabled";
> @@ -174,7 +173,7 @@ soc0: soc@000000000 {
>  	};
>  	eth6: ethernet@6{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <6>;
>  		local-mac-address = [00 00 00 01 00 5e];
>  		status = "disabled";
> @@ -182,7 +181,7 @@ soc0: soc@000000000 {
>  	};
>  	eth7: ethernet@7{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <7>;
>  		local-mac-address = [00 00 00 01 00 5f];
>  		status = "disabled";
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
> index b364529..3bfe36f 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
> @@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = {
>  static int __ae_match(struct device *dev, const void *data)
>  {
>  	struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
> -	const char *ae_id = data;
>  
> -	if (!strncmp(ae_id, hdev->name, AE_NAME_SIZE))
> -		return 1;
> -
> -	return 0;
> +	return hdev->dev->of_node == data;
>  }
>  
> -static struct hnae_ae_dev *find_ae(const char *ae_id)
> +static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
>  {
>  	struct device *dev;
>  
> -	WARN_ON(!ae_id);
> +	WARN_ON(!ae_node);
>  
> -	dev = class_find_device(hnae_class, NULL, ae_id, __ae_match);
> +	dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
>  
>  	return dev ? cls_to_ae_dev(dev) : NULL;
>  }
> @@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle);
>   * return handle ptr or ERR_PTR
>   */
>  struct hnae_handle *hnae_get_handle(struct device *owner_dev,
> -				    const char *ae_id, u32 port_id,
> +				    const struct device_node *ae_node,
> +				    u32 port_id,
>  				    struct hnae_buf_ops *bops)
>  {
>  	struct hnae_ae_dev *dev;
> @@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
>  	int i, j;
>  	int ret;
>  
> -	dev = find_ae(ae_id);
> +	dev = find_ae(ae_node);
>  	if (!dev)
>  		return ERR_PTR(-ENODEV);
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
> index 6ca94dc..1cbcb9f 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
> @@ -524,8 +524,11 @@ struct hnae_handle {
>  
>  #define ring_to_dev(ring) ((ring)->q->dev->dev)
>  
> -struct hnae_handle *hnae_get_handle(struct device *owner_dev, const char *ae_id,
> -				    u32 port_id, struct hnae_buf_ops *bops);
> +struct hnae_handle *hnae_get_handle(struct device *owner_dev,
> +				    const struct device_node *ae_node,
> +				    u32 port_id,
> +				    struct hnae_buf_ops *bops);
> +
>  void hnae_put_handle(struct hnae_handle *handle);
>  int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
>  void hnae_ae_unregister(struct hnae_ae_dev *dev);
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> index 522b264..a0070d0 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
>  int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>  {
>  	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
> +	static atomic_t id = ATOMIC_INIT(-1);
>  
>  	switch (dsaf_dev->dsaf_ver) {
>  	case AE_VERSION_1:
> @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>  	default:
>  		break;
>  	}
> +
> +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d", DSAF_DEVICE_NAME,
> +		 (int)atomic_inc_return(&id));
>  	ae_dev->ops = &hns_dsaf_ops;
>  	ae_dev->dev = dsaf_dev->dev;
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> index 1c33bd0..9439f04 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> @@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
>  	int ret, i;
>  	u32 desc_num;
>  	u32 buf_size;
> -	const char *name, *mode_str;
> +	const char *mode_str;
>  	struct device_node *np = dsaf_dev->dev->of_node;
>  
>  	if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
> @@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
>  	else
>  		dsaf_dev->dsaf_ver = AE_VERSION_2;
>  
> -	ret = of_property_read_string(np, "dsa_name", &name);
> -	if (ret) {
> -		dev_err(dsaf_dev->dev, "get dsaf name fail, ret=%d!\n", ret);
> -		return ret;
> -	}
> -	strncpy(dsaf_dev->ae_dev.name, name, AE_NAME_SIZE);
> -	dsaf_dev->ae_dev.name[AE_NAME_SIZE - 1] = '\0';
> -
>  	ret = of_property_read_string(np, "mode", &mode_str);
>  	if (ret) {
>  		dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> index 31c312f..40205b9 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> @@ -18,6 +18,7 @@ struct hns_mac_cb;
>  
>  #define DSAF_DRV_NAME "hns_dsaf"
>  #define DSAF_MOD_VERSION "v1.0"
> +#define DSAF_DEVICE_NAME "dsaf"
>  
>  #define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> index 0e30846..340ca54 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> @@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
>  	int ret;
>  
>  	h = hnae_get_handle(&priv->netdev->dev,
> -			    priv->ae_name, priv->port_id, NULL);
> +			    priv->ae_node, priv->port_id, NULL);
>  	if (IS_ERR_OR_NULL(h)) {
>  		ret = PTR_ERR(h);
>  		dev_dbg(priv->dev, "has not handle, register notifier!\n");
> @@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
>  	else
>  		priv->enet_ver = AE_VERSION_2;
>  
> -	ret = of_property_read_string(node, "ae-name", &priv->ae_name);
> -	if (ret)
> -		goto out_read_string_fail;
> +	priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
> +	if (IS_ERR_OR_NULL(priv->ae_node)) {
> +		ret = PTR_ERR(priv->ae_node);
> +		dev_err(dev, "not find ae-handle\n");
> +		goto out_read_handle_fai;
> +	}
>  
>  	ret = of_property_read_u32(node, "port-id", &priv->port_id);
>  	if (ret)
> @@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
>  
>  out_notify_fail:
>  	(void)cancel_work_sync(&priv->service_task);
> +out_read_handle_fai:
> +
>  out_read_string_fail:
>  	free_netdev(ndev);
>  	return ret;
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.h b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> index 4b75270..c68ab3d 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> @@ -51,7 +51,7 @@ struct hns_nic_ops {
>  };
>  
>  struct hns_nic_priv {
> -	const char *ae_name;
> +	const struct device_node *ae_node;
>  	u32 enet_ver;
>  	u32 port_id;
>  	int phy_mode;
> 

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

* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-14  3:00   ` Yisen Zhuang
  0 siblings, 0 replies; 32+ messages in thread
From: Yisen Zhuang @ 2016-01-14  3:00 UTC (permalink / raw)
  To: linux-arm-kernel



? 2016/1/13 11:14, Kejian Yan ??:
> This patch replace the assoication between dsaf and enet from string
> matching to object reference. It requires the DTS to be updated within
> BIOS. Thanks god it can be done for all released boards.
> 

Hi kejian,

This patch is fine to me.

Many thanks,

Yisen

> Signed-off-by: Kejian Yan <yankejian@huawei.com>
> ---
> change log:
> v2:
>  merge the two patches into one to allow bisection.
> 
> v1:
>  first submit.
> 
> v1 patch reference:
>  https://lkml.org/lkml/2015/12/5/11
>  https://lkml.org/lkml/2015/12/5/12
> ---
>  .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
>  .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
>  arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
>  drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
>  drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
>  drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
>  10 files changed, 42 insertions(+), 43 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> index 80411b2..ecacfa4 100644
> --- a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> +++ b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> @@ -4,8 +4,6 @@ Required properties:
>  - compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2".
>    "hisilicon,hns-dsaf-v1" is for hip05.
>    "hisilicon,hns-dsaf-v2" is for Hi1610 and Hi1612.
> -- dsa-name: dsa fabric name who provide this interface.
> -  should be "dsafX", X is the dsaf id.
>  - mode: dsa fabric mode string. only support one of dsaf modes like these:
>  		"2port-64vf",
>  		"6port-16rss",
> @@ -26,9 +24,8 @@ Required properties:
>  
>  Example:
>  
> -dsa: dsa at c7000000 {
> +dsaf0: dsa at c7000000 {
>  	compatible = "hisilicon,hns-dsaf-v1";
> -	dsa_name = "dsaf0";
>  	mode = "6port-16rss";
>  	interrupt-parent = <&mbigen_dsa>;
>  	reg = <0x0 0xC0000000 0x0 0x420000
> diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> index 41d19be..e6a9d1c 100644
> --- a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> +++ b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> @@ -4,8 +4,9 @@ Required properties:
>  - compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2".
>    "hisilicon,hns-nic-v1" is for hip05.
>    "hisilicon,hns-nic-v2" is for Hi1610 and Hi1612.
> -- ae-name: accelerator name who provides this interface,
> -  is simply a name referring to the name of name in the accelerator node.
> +- ae-handle: accelerator engine handle for hns,
> +  specifies a reference to the associating hardware driver node.
> +  see Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
>  - port-id: is the index of port provided by DSAF (the accelerator). DSAF can
>    connect to 8 PHYs. Port 0 to 1 are both used for adminstration purpose. They
>    are called debug ports.
> @@ -41,7 +42,7 @@ Example:
>  
>  	ethernet at 0{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <0>;
>  		local-mac-address = [a2 14 e4 4b 56 76];
>  	};
> diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> index 606dd5a..89c883e 100644
> --- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> +++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> @@ -23,9 +23,8 @@ soc0: soc at 000000000 {
>  		};
>  	};
>  
> -	dsa: dsa at c7000000 {
> +	dsaf0: dsa at c7000000 {
>  		compatible = "hisilicon,hns-dsaf-v1";
> -		dsa_name = "dsaf0";
>  		mode = "6port-16rss";
>  		interrupt-parent = <&mbigen_dsa>;
>  
> @@ -127,7 +126,7 @@ soc0: soc at 000000000 {
>  
>  	eth0: ethernet at 0{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <0>;
>  		local-mac-address = [00 00 00 01 00 58];
>  		status = "disabled";
> @@ -135,14 +134,14 @@ soc0: soc at 000000000 {
>  	};
>  	eth1: ethernet at 1{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <1>;
>  		status = "disabled";
>  		dma-coherent;
>  	};
>  	eth2: ethernet at 2{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <2>;
>  		local-mac-address = [00 00 00 01 00 5a];
>  		status = "disabled";
> @@ -150,7 +149,7 @@ soc0: soc at 000000000 {
>  	};
>  	eth3: ethernet at 3{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <3>;
>  		local-mac-address = [00 00 00 01 00 5b];
>  		status = "disabled";
> @@ -158,7 +157,7 @@ soc0: soc at 000000000 {
>  	};
>  	eth4: ethernet at 4{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <4>;
>  		local-mac-address = [00 00 00 01 00 5c];
>  		status = "disabled";
> @@ -166,7 +165,7 @@ soc0: soc at 000000000 {
>  	};
>  	eth5: ethernet at 5{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <5>;
>  		local-mac-address = [00 00 00 01 00 5d];
>  		status = "disabled";
> @@ -174,7 +173,7 @@ soc0: soc at 000000000 {
>  	};
>  	eth6: ethernet at 6{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <6>;
>  		local-mac-address = [00 00 00 01 00 5e];
>  		status = "disabled";
> @@ -182,7 +181,7 @@ soc0: soc at 000000000 {
>  	};
>  	eth7: ethernet at 7{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <7>;
>  		local-mac-address = [00 00 00 01 00 5f];
>  		status = "disabled";
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
> index b364529..3bfe36f 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
> @@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = {
>  static int __ae_match(struct device *dev, const void *data)
>  {
>  	struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
> -	const char *ae_id = data;
>  
> -	if (!strncmp(ae_id, hdev->name, AE_NAME_SIZE))
> -		return 1;
> -
> -	return 0;
> +	return hdev->dev->of_node == data;
>  }
>  
> -static struct hnae_ae_dev *find_ae(const char *ae_id)
> +static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
>  {
>  	struct device *dev;
>  
> -	WARN_ON(!ae_id);
> +	WARN_ON(!ae_node);
>  
> -	dev = class_find_device(hnae_class, NULL, ae_id, __ae_match);
> +	dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
>  
>  	return dev ? cls_to_ae_dev(dev) : NULL;
>  }
> @@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle);
>   * return handle ptr or ERR_PTR
>   */
>  struct hnae_handle *hnae_get_handle(struct device *owner_dev,
> -				    const char *ae_id, u32 port_id,
> +				    const struct device_node *ae_node,
> +				    u32 port_id,
>  				    struct hnae_buf_ops *bops)
>  {
>  	struct hnae_ae_dev *dev;
> @@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
>  	int i, j;
>  	int ret;
>  
> -	dev = find_ae(ae_id);
> +	dev = find_ae(ae_node);
>  	if (!dev)
>  		return ERR_PTR(-ENODEV);
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
> index 6ca94dc..1cbcb9f 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
> @@ -524,8 +524,11 @@ struct hnae_handle {
>  
>  #define ring_to_dev(ring) ((ring)->q->dev->dev)
>  
> -struct hnae_handle *hnae_get_handle(struct device *owner_dev, const char *ae_id,
> -				    u32 port_id, struct hnae_buf_ops *bops);
> +struct hnae_handle *hnae_get_handle(struct device *owner_dev,
> +				    const struct device_node *ae_node,
> +				    u32 port_id,
> +				    struct hnae_buf_ops *bops);
> +
>  void hnae_put_handle(struct hnae_handle *handle);
>  int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
>  void hnae_ae_unregister(struct hnae_ae_dev *dev);
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> index 522b264..a0070d0 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
>  int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>  {
>  	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
> +	static atomic_t id = ATOMIC_INIT(-1);
>  
>  	switch (dsaf_dev->dsaf_ver) {
>  	case AE_VERSION_1:
> @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>  	default:
>  		break;
>  	}
> +
> +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d", DSAF_DEVICE_NAME,
> +		 (int)atomic_inc_return(&id));
>  	ae_dev->ops = &hns_dsaf_ops;
>  	ae_dev->dev = dsaf_dev->dev;
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> index 1c33bd0..9439f04 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> @@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
>  	int ret, i;
>  	u32 desc_num;
>  	u32 buf_size;
> -	const char *name, *mode_str;
> +	const char *mode_str;
>  	struct device_node *np = dsaf_dev->dev->of_node;
>  
>  	if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
> @@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
>  	else
>  		dsaf_dev->dsaf_ver = AE_VERSION_2;
>  
> -	ret = of_property_read_string(np, "dsa_name", &name);
> -	if (ret) {
> -		dev_err(dsaf_dev->dev, "get dsaf name fail, ret=%d!\n", ret);
> -		return ret;
> -	}
> -	strncpy(dsaf_dev->ae_dev.name, name, AE_NAME_SIZE);
> -	dsaf_dev->ae_dev.name[AE_NAME_SIZE - 1] = '\0';
> -
>  	ret = of_property_read_string(np, "mode", &mode_str);
>  	if (ret) {
>  		dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> index 31c312f..40205b9 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> @@ -18,6 +18,7 @@ struct hns_mac_cb;
>  
>  #define DSAF_DRV_NAME "hns_dsaf"
>  #define DSAF_MOD_VERSION "v1.0"
> +#define DSAF_DEVICE_NAME "dsaf"
>  
>  #define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> index 0e30846..340ca54 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> @@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
>  	int ret;
>  
>  	h = hnae_get_handle(&priv->netdev->dev,
> -			    priv->ae_name, priv->port_id, NULL);
> +			    priv->ae_node, priv->port_id, NULL);
>  	if (IS_ERR_OR_NULL(h)) {
>  		ret = PTR_ERR(h);
>  		dev_dbg(priv->dev, "has not handle, register notifier!\n");
> @@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
>  	else
>  		priv->enet_ver = AE_VERSION_2;
>  
> -	ret = of_property_read_string(node, "ae-name", &priv->ae_name);
> -	if (ret)
> -		goto out_read_string_fail;
> +	priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
> +	if (IS_ERR_OR_NULL(priv->ae_node)) {
> +		ret = PTR_ERR(priv->ae_node);
> +		dev_err(dev, "not find ae-handle\n");
> +		goto out_read_handle_fai;
> +	}
>  
>  	ret = of_property_read_u32(node, "port-id", &priv->port_id);
>  	if (ret)
> @@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
>  
>  out_notify_fail:
>  	(void)cancel_work_sync(&priv->service_task);
> +out_read_handle_fai:
> +
>  out_read_string_fail:
>  	free_netdev(ndev);
>  	return ret;
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.h b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> index 4b75270..c68ab3d 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> @@ -51,7 +51,7 @@ struct hns_nic_ops {
>  };
>  
>  struct hns_nic_priv {
> -	const char *ae_name;
> +	const struct device_node *ae_node;
>  	u32 enet_ver;
>  	u32 port_id;
>  	int phy_mode;
> 

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-14  9:43     ` Andy Shevchenko
  0 siblings, 0 replies; 32+ messages in thread
From: Andy Shevchenko @ 2016-01-14  9:43 UTC (permalink / raw)
  To: Yisen Zhuang, Kejian Yan, davem, robh+dt, pawel.moll,
	mark.rutland, ijc+devicetree, galak, catalin.marinas,
	will.deacon, huangdaode, liguozhu, arnd, fengguang.wu,
	salil.mehta, lisheng011
  Cc: devicetree, netdev, linuxarm, linux-kernel, linux-arm-kernel

On Thu, 2016-01-14 at 11:00 +0800, Yisen Zhuang wrote:
> 
> 在 2016/1/13 11:14, Kejian Yan 写道:
> > This patch replace the assoication between dsaf and enet from
> > string
> > matching to object reference. It requires the DTS to be updated
> > within
> > BIOS. Thanks god it can be done for all released boards.
> > 
> 
> Hi kejian,
> 
> This patch is fine to me.

There are few thing below.

> 
> > --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> > +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> > @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
> >  int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
> >  {
> >  	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
> > +	static atomic_t id = ATOMIC_INIT(-1);
> >  
> >  	switch (dsaf_dev->dsaf_ver) {
> >  	case AE_VERSION_1:
> > @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device
> > *dsaf_dev)
> >  	default:
> >  		break;
> >  	}
> > +
> > +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
> > DSAF_DEVICE_NAME,
> > +		 (int)atomic_inc_return(&id));

If you bind/unbind device enough times you may get an overflow and end
up with name of existing device (if you have 1+ of them in the system).

To avoid such situation better to use IDA/IDR framework.

> > 
> > --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> > +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> > @@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct
> > net_device *ndev)
> >  	int ret;
> >  
> >  	h = hnae_get_handle(&priv->netdev->dev,
> > -			    priv->ae_name, priv->port_id, NULL);
> > +			    priv->ae_node, priv->port_id, NULL);
> >  	if (IS_ERR_OR_NULL(h)) {
> >  		ret = PTR_ERR(h);
> >  		dev_dbg(priv->dev, "has not handle, register
> > notifier!\n");
> > @@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct
> > platform_device *pdev)
> >  	else
> >  		priv->enet_ver = AE_VERSION_2;
> >  
> > -	ret = of_property_read_string(node, "ae-name", &priv-
> > >ae_name);
> > -	if (ret)
> > -		goto out_read_string_fail;

(1)

> > +	priv->ae_node = (void *)of_parse_phandle(node, "ae-
> > handle", 0);
> > +	if (IS_ERR_OR_NULL(priv->ae_node)) {
> > +		ret = PTR_ERR(priv->ae_node);
> > +		dev_err(dev, "not find ae-handle\n");
> > +		goto out_read_handle_fai;

(2)

> > +	}
> >  
> >  	ret = of_property_read_u32(node, "port-id", &priv-
> > >port_id);
> >  	if (ret)
> > @@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct
> > platform_device *pdev)
> >  
> >  out_notify_fail:
> >  	(void)cancel_work_sync(&priv->service_task);
> > +out_read_handle_fai:

> > +

Redundant line

> >  out_read_string_fail:

Leftover? (see (1) and (2) )

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-14  9:43     ` Andy Shevchenko
  0 siblings, 0 replies; 32+ messages in thread
From: Andy Shevchenko @ 2016-01-14  9:43 UTC (permalink / raw)
  To: Yisen Zhuang, Kejian Yan, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, catalin.marinas-5wv7dgnIgG8,
	will.deacon-5wv7dgnIgG8, huangdaode-C8/M+/jPZTeaMJb+Lgu22Q,
	liguozhu-hv44wF8Li93QT0dZR+AlfA, arnd-r2nGTMty4D4,
	fengguang.wu-ral2JQCrhuEAvxtiuMwx3w,
	salil.mehta-hv44wF8Li93QT0dZR+AlfA,
	lisheng011-hv44wF8Li93QT0dZR+AlfA
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linuxarm-hv44wF8Li93QT0dZR+AlfA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Thu, 2016-01-14 at 11:00 +0800, Yisen Zhuang wrote:
> 
> 在 2016/1/13 11:14, Kejian Yan 写道:
> > This patch replace the assoication between dsaf and enet from
> > string
> > matching to object reference. It requires the DTS to be updated
> > within
> > BIOS. Thanks god it can be done for all released boards.
> > 
> 
> Hi kejian,
> 
> This patch is fine to me.

There are few thing below.

> 
> > --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> > +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> > @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
> >  int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
> >  {
> >  	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
> > +	static atomic_t id = ATOMIC_INIT(-1);
> >  
> >  	switch (dsaf_dev->dsaf_ver) {
> >  	case AE_VERSION_1:
> > @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device
> > *dsaf_dev)
> >  	default:
> >  		break;
> >  	}
> > +
> > +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
> > DSAF_DEVICE_NAME,
> > +		 (int)atomic_inc_return(&id));

If you bind/unbind device enough times you may get an overflow and end
up with name of existing device (if you have 1+ of them in the system).

To avoid such situation better to use IDA/IDR framework.

> > 
> > --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> > +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> > @@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct
> > net_device *ndev)
> >  	int ret;
> >  
> >  	h = hnae_get_handle(&priv->netdev->dev,
> > -			    priv->ae_name, priv->port_id, NULL);
> > +			    priv->ae_node, priv->port_id, NULL);
> >  	if (IS_ERR_OR_NULL(h)) {
> >  		ret = PTR_ERR(h);
> >  		dev_dbg(priv->dev, "has not handle, register
> > notifier!\n");
> > @@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct
> > platform_device *pdev)
> >  	else
> >  		priv->enet_ver = AE_VERSION_2;
> >  
> > -	ret = of_property_read_string(node, "ae-name", &priv-
> > >ae_name);
> > -	if (ret)
> > -		goto out_read_string_fail;

(1)

> > +	priv->ae_node = (void *)of_parse_phandle(node, "ae-
> > handle", 0);
> > +	if (IS_ERR_OR_NULL(priv->ae_node)) {
> > +		ret = PTR_ERR(priv->ae_node);
> > +		dev_err(dev, "not find ae-handle\n");
> > +		goto out_read_handle_fai;

(2)

> > +	}
> >  
> >  	ret = of_property_read_u32(node, "port-id", &priv-
> > >port_id);
> >  	if (ret)
> > @@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct
> > platform_device *pdev)
> >  
> >  out_notify_fail:
> >  	(void)cancel_work_sync(&priv->service_task);
> > +out_read_handle_fai:

> > +

Redundant line

> >  out_read_string_fail:

Leftover? (see (1) and (2) )

-- 
Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-14  9:43     ` Andy Shevchenko
  0 siblings, 0 replies; 32+ messages in thread
From: Andy Shevchenko @ 2016-01-14  9:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 2016-01-14 at 11:00 +0800, Yisen Zhuang wrote:
> 
> ? 2016/1/13 11:14, Kejian Yan ??:
> > This patch replace the assoication between dsaf and enet from
> > string
> > matching to object reference. It requires the DTS to be updated
> > within
> > BIOS. Thanks god it can be done for all released boards.
> > 
> 
> Hi kejian,
> 
> This patch is fine to me.

There are few thing below.

>?
> > --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> > +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> > @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
> > ?int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
> > ?{
> > ?	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
> > +	static atomic_t id = ATOMIC_INIT(-1);
> > ?
> > ?	switch (dsaf_dev->dsaf_ver) {
> > ?	case AE_VERSION_1:
> > @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device
> > *dsaf_dev)
> > ?	default:
> > ?		break;
> > ?	}
> > +
> > +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
> > DSAF_DEVICE_NAME,
> > +		?(int)atomic_inc_return(&id));

If you bind/unbind device enough times you may get an overflow and end
up with name of existing device (if you have 1+ of them in the system).

To avoid such situation better to use IDA/IDR framework.

> >?
> > --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> > +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> > @@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct
> > net_device *ndev)
> > ?	int ret;
> > ?
> > ?	h = hnae_get_handle(&priv->netdev->dev,
> > -			????priv->ae_name, priv->port_id, NULL);
> > +			????priv->ae_node, priv->port_id, NULL);
> > ?	if (IS_ERR_OR_NULL(h)) {
> > ?		ret = PTR_ERR(h);
> > ?		dev_dbg(priv->dev, "has not handle, register
> > notifier!\n");
> > @@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct
> > platform_device *pdev)
> > ?	else
> > ?		priv->enet_ver = AE_VERSION_2;
> > ?
> > -	ret = of_property_read_string(node, "ae-name", &priv-
> > >ae_name);
> > -	if (ret)
> > -		goto out_read_string_fail;

(1)

> > +	priv->ae_node = (void *)of_parse_phandle(node, "ae-
> > handle", 0);
> > +	if (IS_ERR_OR_NULL(priv->ae_node)) {
> > +		ret = PTR_ERR(priv->ae_node);
> > +		dev_err(dev, "not find ae-handle\n");
> > +		goto out_read_handle_fai;

(2)

> > +	}
> > ?
> > ?	ret = of_property_read_u32(node, "port-id", &priv-
> > >port_id);
> > ?	if (ret)
> > @@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct
> > platform_device *pdev)
> > ?
> > ?out_notify_fail:
> > ?	(void)cancel_work_sync(&priv->service_task);
> > +out_read_handle_fai:

> > +

Redundant line

> > ?out_read_string_fail:

Leftover? (see (1) and (2) )

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-15  2:28   ` Rob Herring
  0 siblings, 0 replies; 32+ messages in thread
From: Rob Herring @ 2016-01-15  2:28 UTC (permalink / raw)
  To: Kejian Yan
  Cc: davem, pawel.moll, mark.rutland, ijc+devicetree, galak,
	catalin.marinas, will.deacon, huangdaode, liguozhu, arnd,
	fengguang.wu, salil.mehta, andriy.shevchenko, lisheng011,
	haifeng.wei, netdev, devicetree, linux-kernel, linux-arm-kernel,
	linuxarm

On Wed, Jan 13, 2016 at 11:14:40AM +0800, Kejian Yan wrote:
> This patch replace the assoication between dsaf and enet from string
> matching to object reference. It requires the DTS to be updated within
> BIOS. Thanks god it can be done for all released boards.
> 
> Signed-off-by: Kejian Yan <yankejian@huawei.com>
> ---
> change log:
> v2:
>  merge the two patches into one to allow bisection.


> 
> v1:
>  first submit.
> 
> v1 patch reference:
>  https://lkml.org/lkml/2015/12/5/11
>  https://lkml.org/lkml/2015/12/5/12
> ---
>  .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
>  .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
>  arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------

Acked-by: Rob Herring <robh@kernel.org>

>  drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
>  drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
>  drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
>  drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
>  10 files changed, 42 insertions(+), 43 deletions(-)

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-15  2:28   ` Rob Herring
  0 siblings, 0 replies; 32+ messages in thread
From: Rob Herring @ 2016-01-15  2:28 UTC (permalink / raw)
  To: Kejian Yan
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, catalin.marinas-5wv7dgnIgG8,
	will.deacon-5wv7dgnIgG8, huangdaode-C8/M+/jPZTeaMJb+Lgu22Q,
	liguozhu-hv44wF8Li93QT0dZR+AlfA, arnd-r2nGTMty4D4,
	fengguang.wu-ral2JQCrhuEAvxtiuMwx3w,
	salil.mehta-hv44wF8Li93QT0dZR+AlfA,
	andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA,
	lisheng011-hv44wF8Li93QT0dZR+AlfA,
	haifeng.wei-hv44wF8Li93QT0dZR+AlfA,
	netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linuxarm-hv44wF8Li93QT0dZR+AlfA

On Wed, Jan 13, 2016 at 11:14:40AM +0800, Kejian Yan wrote:
> This patch replace the assoication between dsaf and enet from string
> matching to object reference. It requires the DTS to be updated within
> BIOS. Thanks god it can be done for all released boards.
> 
> Signed-off-by: Kejian Yan <yankejian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> ---
> change log:
> v2:
>  merge the two patches into one to allow bisection.


> 
> v1:
>  first submit.
> 
> v1 patch reference:
>  https://lkml.org/lkml/2015/12/5/11
>  https://lkml.org/lkml/2015/12/5/12
> ---
>  .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
>  .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
>  arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

>  drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
>  drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
>  drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
>  drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
>  10 files changed, 42 insertions(+), 43 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-15  2:28   ` Rob Herring
  0 siblings, 0 replies; 32+ messages in thread
From: Rob Herring @ 2016-01-15  2:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jan 13, 2016 at 11:14:40AM +0800, Kejian Yan wrote:
> This patch replace the assoication between dsaf and enet from string
> matching to object reference. It requires the DTS to be updated within
> BIOS. Thanks god it can be done for all released boards.
> 
> Signed-off-by: Kejian Yan <yankejian@huawei.com>
> ---
> change log:
> v2:
>  merge the two patches into one to allow bisection.


> 
> v1:
>  first submit.
> 
> v1 patch reference:
>  https://lkml.org/lkml/2015/12/5/11
>  https://lkml.org/lkml/2015/12/5/12
> ---
>  .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
>  .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
>  arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------

Acked-by: Rob Herring <robh@kernel.org>

>  drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
>  drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
>  drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
>  drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
>  10 files changed, 42 insertions(+), 43 deletions(-)

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-18 11:35       ` Yankejian (Hackim Yim)
  0 siblings, 0 replies; 32+ messages in thread
From: Yankejian (Hackim Yim) @ 2016-01-18 11:35 UTC (permalink / raw)
  To: Andy Shevchenko, Yisen Zhuang, davem, robh+dt, pawel.moll,
	mark.rutland, ijc+devicetree, galak, catalin.marinas,
	will.deacon, huangdaode, liguozhu, arnd, fengguang.wu,
	salil.mehta, lisheng011
  Cc: devicetree, netdev, linuxarm, linux-kernel, linux-arm-kernel



On 2016/1/14 17:43, Andy Shevchenko wrote:
> On Thu, 2016-01-14 at 11:00 +0800, Yisen Zhuang wrote:
>> 在 2016/1/13 11:14, Kejian Yan 写道:
>>> This patch replace the assoication between dsaf and enet from
>>> string
>>> matching to object reference. It requires the DTS to be updated
>>> within
>>> BIOS. Thanks god it can be done for all released boards.
>>>
>> Hi kejian,
>>
>> This patch is fine to me.
> There are few thing below.
>
>>  
>>> --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>>> @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
>>>  int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>>>  {
>>>  	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
>>> +	static atomic_t id = ATOMIC_INIT(-1);
>>>  
>>>  	switch (dsaf_dev->dsaf_ver) {
>>>  	case AE_VERSION_1:
>>> @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device
>>> *dsaf_dev)
>>>  	default:
>>>  		break;
>>>  	}
>>> +
>>> +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
>>> DSAF_DEVICE_NAME,
>>> +		 (int)atomic_inc_return(&id));
> If you bind/unbind device enough times you may get an overflow and end
> up with name of existing device (if you have 1+ of them in the system).
>
> To avoid such situation better to use IDA/IDR framework.

thanks

Best Regards
Kejian Yan

>>>  
>>> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
>>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
>>> @@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct
>>> net_device *ndev)
>>>  	int ret;
>>>  
>>>  	h = hnae_get_handle(&priv->netdev->dev,
>>> -			    priv->ae_name, priv->port_id, NULL);
>>> +			    priv->ae_node, priv->port_id, NULL);
>>>  	if (IS_ERR_OR_NULL(h)) {
>>>  		ret = PTR_ERR(h);
>>>  		dev_dbg(priv->dev, "has not handle, register
>>> notifier!\n");
>>> @@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct
>>> platform_device *pdev)
>>>  	else
>>>  		priv->enet_ver = AE_VERSION_2;
>>>  
>>> -	ret = of_property_read_string(node, "ae-name", &priv-
>>>> ae_name);
>>> -	if (ret)
>>> -		goto out_read_string_fail;
> (1)
>
>>> +	priv->ae_node = (void *)of_parse_phandle(node, "ae-
>>> handle", 0);
>>> +	if (IS_ERR_OR_NULL(priv->ae_node)) {
>>> +		ret = PTR_ERR(priv->ae_node);
>>> +		dev_err(dev, "not find ae-handle\n");
>>> +		goto out_read_handle_fai;
> (2)
>
>>> +	}
>>>  
>>>  	ret = of_property_read_u32(node, "port-id", &priv-
>>>> port_id);
>>>  	if (ret)
>>> @@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct
>>> platform_device *pdev)
>>>  
>>>  out_notify_fail:
>>>  	(void)cancel_work_sync(&priv->service_task);
>>> +out_read_handle_fai:
>>> +
> Redundant line
>
>>>  out_read_string_fail:
> Leftover? (see (1) and (2) )

thanks.

Best Regards
Kejian Yan

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-18 11:35       ` Yankejian (Hackim Yim)
  0 siblings, 0 replies; 32+ messages in thread
From: Yankejian (Hackim Yim) @ 2016-01-18 11:35 UTC (permalink / raw)
  To: Andy Shevchenko, Yisen Zhuang, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, catalin.marinas-5wv7dgnIgG8,
	will.deacon-5wv7dgnIgG8, huangdaode-C8/M+/jPZTeaMJb+Lgu22Q,
	liguozhu-hv44wF8Li93QT0dZR+AlfA, arnd-r2nGTMty4D4,
	fengguang.wu-ral2JQCrhuEAvxtiuMwx3w,
	salil.mehta-hv44wF8Li93QT0dZR+AlfA,
	lisheng011-hv44wF8Li93QT0dZR+AlfA
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linuxarm-hv44wF8Li93QT0dZR+AlfA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r



On 2016/1/14 17:43, Andy Shevchenko wrote:
> On Thu, 2016-01-14 at 11:00 +0800, Yisen Zhuang wrote:
>> 在 2016/1/13 11:14, Kejian Yan 写道:
>>> This patch replace the assoication between dsaf and enet from
>>> string
>>> matching to object reference. It requires the DTS to be updated
>>> within
>>> BIOS. Thanks god it can be done for all released boards.
>>>
>> Hi kejian,
>>
>> This patch is fine to me.
> There are few thing below.
>
>>  
>>> --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>>> @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
>>>  int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>>>  {
>>>  	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
>>> +	static atomic_t id = ATOMIC_INIT(-1);
>>>  
>>>  	switch (dsaf_dev->dsaf_ver) {
>>>  	case AE_VERSION_1:
>>> @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device
>>> *dsaf_dev)
>>>  	default:
>>>  		break;
>>>  	}
>>> +
>>> +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
>>> DSAF_DEVICE_NAME,
>>> +		 (int)atomic_inc_return(&id));
> If you bind/unbind device enough times you may get an overflow and end
> up with name of existing device (if you have 1+ of them in the system).
>
> To avoid such situation better to use IDA/IDR framework.

thanks

Best Regards
Kejian Yan

>>>  
>>> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
>>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
>>> @@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct
>>> net_device *ndev)
>>>  	int ret;
>>>  
>>>  	h = hnae_get_handle(&priv->netdev->dev,
>>> -			    priv->ae_name, priv->port_id, NULL);
>>> +			    priv->ae_node, priv->port_id, NULL);
>>>  	if (IS_ERR_OR_NULL(h)) {
>>>  		ret = PTR_ERR(h);
>>>  		dev_dbg(priv->dev, "has not handle, register
>>> notifier!\n");
>>> @@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct
>>> platform_device *pdev)
>>>  	else
>>>  		priv->enet_ver = AE_VERSION_2;
>>>  
>>> -	ret = of_property_read_string(node, "ae-name", &priv-
>>>> ae_name);
>>> -	if (ret)
>>> -		goto out_read_string_fail;
> (1)
>
>>> +	priv->ae_node = (void *)of_parse_phandle(node, "ae-
>>> handle", 0);
>>> +	if (IS_ERR_OR_NULL(priv->ae_node)) {
>>> +		ret = PTR_ERR(priv->ae_node);
>>> +		dev_err(dev, "not find ae-handle\n");
>>> +		goto out_read_handle_fai;
> (2)
>
>>> +	}
>>>  
>>>  	ret = of_property_read_u32(node, "port-id", &priv-
>>>> port_id);
>>>  	if (ret)
>>> @@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct
>>> platform_device *pdev)
>>>  
>>>  out_notify_fail:
>>>  	(void)cancel_work_sync(&priv->service_task);
>>> +out_read_handle_fai:
>>> +
> Redundant line
>
>>>  out_read_string_fail:
> Leftover? (see (1) and (2) )

thanks.

Best Regards
Kejian Yan


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-18 11:35       ` Yankejian (Hackim Yim)
  0 siblings, 0 replies; 32+ messages in thread
From: Yankejian (Hackim Yim) @ 2016-01-18 11:35 UTC (permalink / raw)
  To: Andy Shevchenko, Yisen Zhuang, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, catalin.marinas-5wv7dgnIgG8,
	will.deacon-5wv7dgnIgG8, huangdaode-C8/M+/jPZTeaMJb+Lgu22Q,
	liguozhu-hv44wF8Li93QT0dZR+AlfA, arnd-r2nGTMty4D4,
	fengguang.wu-ral2JQCrhuEAvxtiuMwx3w,
	salil.mehta-hv44wF8Li93QT0dZR+AlfA,
	lisheng011-hv44wF8Li93QT0dZR+AlfA
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linuxarm-hv44wF8Li93QT0dZR+AlfA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r



On 2016/1/14 17:43, Andy Shevchenko wrote:
> On Thu, 2016-01-14 at 11:00 +0800, Yisen Zhuang wrote:
>> 在 2016/1/13 11:14, Kejian Yan 写道:
>>> This patch replace the assoication between dsaf and enet from
>>> string
>>> matching to object reference. It requires the DTS to be updated
>>> within
>>> BIOS. Thanks god it can be done for all released boards.
>>>
>> Hi kejian,
>>
>> This patch is fine to me.
> There are few thing below.
>
>>  
>>> --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>>> @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
>>>  int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>>>  {
>>>  	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
>>> +	static atomic_t id = ATOMIC_INIT(-1);
>>>  
>>>  	switch (dsaf_dev->dsaf_ver) {
>>>  	case AE_VERSION_1:
>>> @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device
>>> *dsaf_dev)
>>>  	default:
>>>  		break;
>>>  	}
>>> +
>>> +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
>>> DSAF_DEVICE_NAME,
>>> +		 (int)atomic_inc_return(&id));
> If you bind/unbind device enough times you may get an overflow and end
> up with name of existing device (if you have 1+ of them in the system).
>
> To avoid such situation better to use IDA/IDR framework.

thanks

Best Regards
Kejian Yan

>>>  
>>> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
>>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
>>> @@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct
>>> net_device *ndev)
>>>  	int ret;
>>>  
>>>  	h = hnae_get_handle(&priv->netdev->dev,
>>> -			    priv->ae_name, priv->port_id, NULL);
>>> +			    priv->ae_node, priv->port_id, NULL);
>>>  	if (IS_ERR_OR_NULL(h)) {
>>>  		ret = PTR_ERR(h);
>>>  		dev_dbg(priv->dev, "has not handle, register
>>> notifier!\n");
>>> @@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct
>>> platform_device *pdev)
>>>  	else
>>>  		priv->enet_ver = AE_VERSION_2;
>>>  
>>> -	ret = of_property_read_string(node, "ae-name", &priv-
>>>> ae_name);
>>> -	if (ret)
>>> -		goto out_read_string_fail;
> (1)
>
>>> +	priv->ae_node = (void *)of_parse_phandle(node, "ae-
>>> handle", 0);
>>> +	if (IS_ERR_OR_NULL(priv->ae_node)) {
>>> +		ret = PTR_ERR(priv->ae_node);
>>> +		dev_err(dev, "not find ae-handle\n");
>>> +		goto out_read_handle_fai;
> (2)
>
>>> +	}
>>>  
>>>  	ret = of_property_read_u32(node, "port-id", &priv-
>>>> port_id);
>>>  	if (ret)
>>> @@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct
>>> platform_device *pdev)
>>>  
>>>  out_notify_fail:
>>>  	(void)cancel_work_sync(&priv->service_task);
>>> +out_read_handle_fai:
>>> +
> Redundant line
>
>>>  out_read_string_fail:
> Leftover? (see (1) and (2) )

thanks.

Best Regards
Kejian Yan


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-18 11:35       ` Yankejian (Hackim Yim)
  0 siblings, 0 replies; 32+ messages in thread
From: Yankejian (Hackim Yim) @ 2016-01-18 11:35 UTC (permalink / raw)
  To: linux-arm-kernel



On 2016/1/14 17:43, Andy Shevchenko wrote:
> On Thu, 2016-01-14 at 11:00 +0800, Yisen Zhuang wrote:
>> ? 2016/1/13 11:14, Kejian Yan ??:
>>> This patch replace the assoication between dsaf and enet from
>>> string
>>> matching to object reference. It requires the DTS to be updated
>>> within
>>> BIOS. Thanks god it can be done for all released boards.
>>>
>> Hi kejian,
>>
>> This patch is fine to me.
> There are few thing below.
>
>>  
>>> --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>>> @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
>>>  int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>>>  {
>>>  	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
>>> +	static atomic_t id = ATOMIC_INIT(-1);
>>>  
>>>  	switch (dsaf_dev->dsaf_ver) {
>>>  	case AE_VERSION_1:
>>> @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device
>>> *dsaf_dev)
>>>  	default:
>>>  		break;
>>>  	}
>>> +
>>> +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
>>> DSAF_DEVICE_NAME,
>>> +		 (int)atomic_inc_return(&id));
> If you bind/unbind device enough times you may get an overflow and end
> up with name of existing device (if you have 1+ of them in the system).
>
> To avoid such situation better to use IDA/IDR framework.

thanks

Best Regards
Kejian Yan

>>>  
>>> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
>>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
>>> @@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct
>>> net_device *ndev)
>>>  	int ret;
>>>  
>>>  	h = hnae_get_handle(&priv->netdev->dev,
>>> -			    priv->ae_name, priv->port_id, NULL);
>>> +			    priv->ae_node, priv->port_id, NULL);
>>>  	if (IS_ERR_OR_NULL(h)) {
>>>  		ret = PTR_ERR(h);
>>>  		dev_dbg(priv->dev, "has not handle, register
>>> notifier!\n");
>>> @@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct
>>> platform_device *pdev)
>>>  	else
>>>  		priv->enet_ver = AE_VERSION_2;
>>>  
>>> -	ret = of_property_read_string(node, "ae-name", &priv-
>>>> ae_name);
>>> -	if (ret)
>>> -		goto out_read_string_fail;
> (1)
>
>>> +	priv->ae_node = (void *)of_parse_phandle(node, "ae-
>>> handle", 0);
>>> +	if (IS_ERR_OR_NULL(priv->ae_node)) {
>>> +		ret = PTR_ERR(priv->ae_node);
>>> +		dev_err(dev, "not find ae-handle\n");
>>> +		goto out_read_handle_fai;
> (2)
>
>>> +	}
>>>  
>>>  	ret = of_property_read_u32(node, "port-id", &priv-
>>>> port_id);
>>>  	if (ret)
>>> @@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct
>>> platform_device *pdev)
>>>  
>>>  out_notify_fail:
>>>  	(void)cancel_work_sync(&priv->service_task);
>>> +out_read_handle_fai:
>>> +
> Redundant line
>
>>>  out_read_string_fail:
> Leftover? (see (1) and (2) )

thanks.

Best Regards
Kejian Yan

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
  2016-01-14  9:43     ` Andy Shevchenko
                       ` (2 preceding siblings ...)
  (?)
@ 2016-01-20  6:49     ` Yankejian (Hackim Yim)
  2016-01-20  9:36         ` Andy Shevchenko
  -1 siblings, 1 reply; 32+ messages in thread
From: Yankejian (Hackim Yim) @ 2016-01-20  6:49 UTC (permalink / raw)
  To: Andy Shevchenko, Yisen Zhuang, davem, robh+dt, pawel.moll,
	mark.rutland, ijc+devicetree, galak, catalin.marinas,
	will.deacon, huangdaode, liguozhu, arnd, fengguang.wu,
	salil.mehta, lisheng011
  Cc: devicetree, netdev, linuxarm, linux-kernel, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]



On 2016/1/14 17:43, Andy Shevchenko wrote:
>>  
>>> > > --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>>> > > +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>>> > > @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
>>> > >  int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>>> > >  {
>>> > >  	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
>>> > > +	static atomic_t id = ATOMIC_INIT(-1);
>>> > >  
>>> > >  	switch (dsaf_dev->dsaf_ver) {
>>> > >  	case AE_VERSION_1:
>>> > > @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device
>>> > > *dsaf_dev)
>>> > >  	default:
>>> > >  		break;
>>> > >  	}
>>> > > +
>>> > > +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
>>> > > DSAF_DEVICE_NAME,
>>> > > +		 (int)atomic_inc_return(&id));
> If you bind/unbind device enough times you may get an overflow and end
> up with name of existing device (if you have 1+ of them in the system).
>
> To avoid such situation better to use IDA/IDR framework.
>
Hi, Andy
Thanks again for your suggestion.
It seems that using IDA/IDR framework is better, but all of the functions must be serialized by lock.
And actually, we confirm that it won't be overflow in our analysis before we implemented it.

Best Regards,
Kejian Yan




[-- Attachment #2: Type: text/html, Size: 3149 bytes --]

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-20  9:36         ` Andy Shevchenko
  0 siblings, 0 replies; 32+ messages in thread
From: Andy Shevchenko @ 2016-01-20  9:36 UTC (permalink / raw)
  To: Yankejian (Hackim Yim),
	Yisen Zhuang, davem, robh+dt, pawel.moll, mark.rutland,
	ijc+devicetree, galak, catalin.marinas, will.deacon, huangdaode,
	liguozhu, arnd, fengguang.wu, salil.mehta, lisheng011
  Cc: devicetree, netdev, linuxarm, linux-kernel, linux-arm-kernel

On Wed, 2016-01-20 at 14:49 +0800, Yankejian (Hackim Yim) wrote:
> > > +
> > > > > > +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
> > > > > > DSAF_DEVICE_NAME,
> > > > > > +		 (int)atomic_inc_return(&id));
> > If you bind/unbind device enough times you may get an overflow and
> > end
> > up with name of existing device (if you have 1+ of them in the
> > system).
> > 
> > To avoid such situation better to use IDA/IDR framework.
> > 
> Hi, Andy
> Thanks again for your suggestion.
> It seems that using IDA/IDR framework is better, but all of the
> functions must be serialized by lock.

AFAIR it's designed in a way you don't need to do any additional
locking or synchronization.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-20  9:36         ` Andy Shevchenko
  0 siblings, 0 replies; 32+ messages in thread
From: Andy Shevchenko @ 2016-01-20  9:36 UTC (permalink / raw)
  To: Yankejian (Hackim Yim),
	Yisen Zhuang, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, catalin.marinas-5wv7dgnIgG8,
	will.deacon-5wv7dgnIgG8, huangdaode-C8/M+/jPZTeaMJb+Lgu22Q,
	liguozhu-hv44wF8Li93QT0dZR+AlfA, arnd-r2nGTMty4D4,
	fengguang.wu-ral2JQCrhuEAvxtiuMwx3w,
	salil.mehta-hv44wF8Li93QT0dZR+AlfA,
	lisheng011-hv44wF8Li93QT0dZR+AlfA
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linuxarm-hv44wF8Li93QT0dZR+AlfA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Wed, 2016-01-20 at 14:49 +0800, Yankejian (Hackim Yim) wrote:
> > > +
> > > > > > +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
> > > > > > DSAF_DEVICE_NAME,
> > > > > > +		 (int)atomic_inc_return(&id));
> > If you bind/unbind device enough times you may get an overflow and
> > end
> > up with name of existing device (if you have 1+ of them in the
> > system).
> > 
> > To avoid such situation better to use IDA/IDR framework.
> > 
> Hi, Andy
> Thanks again for your suggestion.
> It seems that using IDA/IDR framework is better, but all of the
> functions must be serialized by lock.

AFAIR it's designed in a way you don't need to do any additional
locking or synchronization.

-- 
Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-20  9:36         ` Andy Shevchenko
  0 siblings, 0 replies; 32+ messages in thread
From: Andy Shevchenko @ 2016-01-20  9:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 2016-01-20 at 14:49 +0800, Yankejian (Hackim Yim) wrote:
> > > +
> > > > > > +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
> > > > > > DSAF_DEVICE_NAME,
> > > > > > +		?(int)atomic_inc_return(&id));
> > If you bind/unbind device enough times you may get an overflow and
> > end
> > up with name of existing device (if you have 1+ of them in the
> > system).
> > 
> > To avoid such situation better to use IDA/IDR framework.
> > 
> Hi, Andy
> Thanks again for your suggestion.
> It seems that using IDA/IDR framework is better, but all of the
> functions must be serialized by lock.

AFAIR it's designed in a way you don't need to do any additional
locking or synchronization.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
  2016-01-20  9:36         ` Andy Shevchenko
  (?)
@ 2016-01-20 11:10           ` Yankejian (Hackim Yim)
  -1 siblings, 0 replies; 32+ messages in thread
From: Yankejian (Hackim Yim) @ 2016-01-20 11:10 UTC (permalink / raw)
  To: Andy Shevchenko, Yisen Zhuang, davem, robh+dt, pawel.moll,
	mark.rutland, ijc+devicetree, galak, catalin.marinas,
	will.deacon, huangdaode, liguozhu, arnd, fengguang.wu,
	salil.mehta, lisheng011
  Cc: devicetree, netdev, linuxarm, linux-kernel, linux-arm-kernel



On 2016/1/20 17:36, Andy Shevchenko wrote:
> On Wed, 2016-01-20 at 14:49 +0800, Yankejian (Hackim Yim) wrote:
>>>> +
>>>>>>> +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
>>>>>>> DSAF_DEVICE_NAME,
>>>>>>> +		 (int)atomic_inc_return(&id));
>>> If you bind/unbind device enough times you may get an overflow and
>>> end
>>> up with name of existing device (if you have 1+ of them in the
>>> system).
>>>
>>> To avoid such situation better to use IDA/IDR framework.
>>>
>> Hi, Andy
>> Thanks again for your suggestion.
>> It seems that using IDA/IDR framework is better, but all of the
>> functions must be serialized by lock.
> AFAIR it's designed in a way you don't need to do any additional
> locking or synchronization.

really? if so, that is great.
could you sent me an example.
thanks very much. Andy.

Best Regards,
Kejian Yan

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-20 11:10           ` Yankejian (Hackim Yim)
  0 siblings, 0 replies; 32+ messages in thread
From: Yankejian (Hackim Yim) @ 2016-01-20 11:10 UTC (permalink / raw)
  To: Andy Shevchenko, Yisen Zhuang, davem, robh+dt, pawel.moll,
	mark.rutland, ijc+devicetree, galak, catalin.marinas,
	will.deacon, huangdaode, liguozhu, arnd, fengguang.wu,
	salil.mehta, lisheng011
  Cc: devicetree, netdev, linuxarm, linux-kernel, linux-arm-kernel



On 2016/1/20 17:36, Andy Shevchenko wrote:
> On Wed, 2016-01-20 at 14:49 +0800, Yankejian (Hackim Yim) wrote:
>>>> +
>>>>>>> +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
>>>>>>> DSAF_DEVICE_NAME,
>>>>>>> +		 (int)atomic_inc_return(&id));
>>> If you bind/unbind device enough times you may get an overflow and
>>> end
>>> up with name of existing device (if you have 1+ of them in the
>>> system).
>>>
>>> To avoid such situation better to use IDA/IDR framework.
>>>
>> Hi, Andy
>> Thanks again for your suggestion.
>> It seems that using IDA/IDR framework is better, but all of the
>> functions must be serialized by lock.
> AFAIR it's designed in a way you don't need to do any additional
> locking or synchronization.

really? if so, that is great.
could you sent me an example.
thanks very much. Andy.

Best Regards,
Kejian Yan

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

* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-20 11:10           ` Yankejian (Hackim Yim)
  0 siblings, 0 replies; 32+ messages in thread
From: Yankejian (Hackim Yim) @ 2016-01-20 11:10 UTC (permalink / raw)
  To: linux-arm-kernel



On 2016/1/20 17:36, Andy Shevchenko wrote:
> On Wed, 2016-01-20 at 14:49 +0800, Yankejian (Hackim Yim) wrote:
>>>> +
>>>>>>> +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d",
>>>>>>> DSAF_DEVICE_NAME,
>>>>>>> +		 (int)atomic_inc_return(&id));
>>> If you bind/unbind device enough times you may get an overflow and
>>> end
>>> up with name of existing device (if you have 1+ of them in the
>>> system).
>>>
>>> To avoid such situation better to use IDA/IDR framework.
>>>
>> Hi, Andy
>> Thanks again for your suggestion.
>> It seems that using IDA/IDR framework is better, but all of the
>> functions must be serialized by lock.
> AFAIR it's designed in a way you don't need to do any additional
> locking or synchronization.

really? if so, that is great.
could you sent me an example.
thanks very much. Andy.

Best Regards,
Kejian Yan

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

* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-13  3:01 ` Kejian Yan
  0 siblings, 0 replies; 32+ messages in thread
From: Kejian Yan @ 2016-01-13  3:01 UTC (permalink / raw)
  To: davem, robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	catalin.marinas, will.deacon, huangdaode, liguozhu, arnd,
	fengguang.wu, salil.mehta, andriy.shevchenko, lisheng011
  Cc: haifeng.wei, netdev, devicetree, linux-kernel, linux-arm-kernel,
	linuxarm

This patch replace the assoication between dsaf and enet from string
matching to object reference. It requires the DTS to be updated within
BIOS. Thanks god it can be done for all released boards.

Signed-off-by: Kejian Yan <yankejian@huawei.com>
---
change log:
v2:
 merge the two patches into one to allow bisection.

v1:
 first submit.

v1 patch reference:
 https://lkml.org/lkml/2015/12/5/11
 https://lkml.org/lkml/2015/12/5/12
---
 .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
 .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------
 drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
 drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
 drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
 drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
 10 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
index 80411b2..ecacfa4 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
@@ -4,8 +4,6 @@ Required properties:
 - compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2".
   "hisilicon,hns-dsaf-v1" is for hip05.
   "hisilicon,hns-dsaf-v2" is for Hi1610 and Hi1612.
-- dsa-name: dsa fabric name who provide this interface.
-  should be "dsafX", X is the dsaf id.
 - mode: dsa fabric mode string. only support one of dsaf modes like these:
 		"2port-64vf",
 		"6port-16rss",
@@ -26,9 +24,8 @@ Required properties:
 
 Example:
 
-dsa: dsa@c7000000 {
+dsaf0: dsa@c7000000 {
 	compatible = "hisilicon,hns-dsaf-v1";
-	dsa_name = "dsaf0";
 	mode = "6port-16rss";
 	interrupt-parent = <&mbigen_dsa>;
 	reg = <0x0 0xC0000000 0x0 0x420000
diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
index 41d19be..e6a9d1c 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
@@ -4,8 +4,9 @@ Required properties:
 - compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2".
   "hisilicon,hns-nic-v1" is for hip05.
   "hisilicon,hns-nic-v2" is for Hi1610 and Hi1612.
-- ae-name: accelerator name who provides this interface,
-  is simply a name referring to the name of name in the accelerator node.
+- ae-handle: accelerator engine handle for hns,
+  specifies a reference to the associating hardware driver node.
+  see Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
 - port-id: is the index of port provided by DSAF (the accelerator). DSAF can
   connect to 8 PHYs. Port 0 to 1 are both used for adminstration purpose. They
   are called debug ports.
@@ -41,7 +42,7 @@ Example:
 
 	ethernet@0{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <0>;
 		local-mac-address = [a2 14 e4 4b 56 76];
 	};
diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
index 606dd5a..89c883e 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
@@ -23,9 +23,8 @@ soc0: soc@000000000 {
 		};
 	};
 
-	dsa: dsa@c7000000 {
+	dsaf0: dsa@c7000000 {
 		compatible = "hisilicon,hns-dsaf-v1";
-		dsa_name = "dsaf0";
 		mode = "6port-16rss";
 		interrupt-parent = <&mbigen_dsa>;
 
@@ -127,7 +126,7 @@ soc0: soc@000000000 {
 
 	eth0: ethernet@0{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <0>;
 		local-mac-address = [00 00 00 01 00 58];
 		status = "disabled";
@@ -135,14 +134,14 @@ soc0: soc@000000000 {
 	};
 	eth1: ethernet@1{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <1>;
 		status = "disabled";
 		dma-coherent;
 	};
 	eth2: ethernet@2{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <2>;
 		local-mac-address = [00 00 00 01 00 5a];
 		status = "disabled";
@@ -150,7 +149,7 @@ soc0: soc@000000000 {
 	};
 	eth3: ethernet@3{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <3>;
 		local-mac-address = [00 00 00 01 00 5b];
 		status = "disabled";
@@ -158,7 +157,7 @@ soc0: soc@000000000 {
 	};
 	eth4: ethernet@4{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <4>;
 		local-mac-address = [00 00 00 01 00 5c];
 		status = "disabled";
@@ -166,7 +165,7 @@ soc0: soc@000000000 {
 	};
 	eth5: ethernet@5{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <5>;
 		local-mac-address = [00 00 00 01 00 5d];
 		status = "disabled";
@@ -174,7 +173,7 @@ soc0: soc@000000000 {
 	};
 	eth6: ethernet@6{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <6>;
 		local-mac-address = [00 00 00 01 00 5e];
 		status = "disabled";
@@ -182,7 +181,7 @@ soc0: soc@000000000 {
 	};
 	eth7: ethernet@7{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <7>;
 		local-mac-address = [00 00 00 01 00 5f];
 		status = "disabled";
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
index b364529..3bfe36f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.c
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
@@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = {
 static int __ae_match(struct device *dev, const void *data)
 {
 	struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
-	const char *ae_id = data;
 
-	if (!strncmp(ae_id, hdev->name, AE_NAME_SIZE))
-		return 1;
-
-	return 0;
+	return hdev->dev->of_node == data;
 }
 
-static struct hnae_ae_dev *find_ae(const char *ae_id)
+static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
 {
 	struct device *dev;
 
-	WARN_ON(!ae_id);
+	WARN_ON(!ae_node);
 
-	dev = class_find_device(hnae_class, NULL, ae_id, __ae_match);
+	dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
 
 	return dev ? cls_to_ae_dev(dev) : NULL;
 }
@@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle);
  * return handle ptr or ERR_PTR
  */
 struct hnae_handle *hnae_get_handle(struct device *owner_dev,
-				    const char *ae_id, u32 port_id,
+				    const struct device_node *ae_node,
+				    u32 port_id,
 				    struct hnae_buf_ops *bops)
 {
 	struct hnae_ae_dev *dev;
@@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
 	int i, j;
 	int ret;
 
-	dev = find_ae(ae_id);
+	dev = find_ae(ae_node);
 	if (!dev)
 		return ERR_PTR(-ENODEV);
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
index 6ca94dc..1cbcb9f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -524,8 +524,11 @@ struct hnae_handle {
 
 #define ring_to_dev(ring) ((ring)->q->dev->dev)
 
-struct hnae_handle *hnae_get_handle(struct device *owner_dev, const char *ae_id,
-				    u32 port_id, struct hnae_buf_ops *bops);
+struct hnae_handle *hnae_get_handle(struct device *owner_dev,
+				    const struct device_node *ae_node,
+				    u32 port_id,
+				    struct hnae_buf_ops *bops);
+
 void hnae_put_handle(struct hnae_handle *handle);
 int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
 void hnae_ae_unregister(struct hnae_ae_dev *dev);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index 522b264..a0070d0 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
 int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
 {
 	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
+	static atomic_t id = ATOMIC_INIT(-1);
 
 	switch (dsaf_dev->dsaf_ver) {
 	case AE_VERSION_1:
@@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
 	default:
 		break;
 	}
+
+	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d", DSAF_DEVICE_NAME,
+		 (int)atomic_inc_return(&id));
 	ae_dev->ops = &hns_dsaf_ops;
 	ae_dev->dev = dsaf_dev->dev;
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 1c33bd0..9439f04 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
 	int ret, i;
 	u32 desc_num;
 	u32 buf_size;
-	const char *name, *mode_str;
+	const char *mode_str;
 	struct device_node *np = dsaf_dev->dev->of_node;
 
 	if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
@@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
 	else
 		dsaf_dev->dsaf_ver = AE_VERSION_2;
 
-	ret = of_property_read_string(np, "dsa_name", &name);
-	if (ret) {
-		dev_err(dsaf_dev->dev, "get dsaf name fail, ret=%d!\n", ret);
-		return ret;
-	}
-	strncpy(dsaf_dev->ae_dev.name, name, AE_NAME_SIZE);
-	dsaf_dev->ae_dev.name[AE_NAME_SIZE - 1] = '\0';
-
 	ret = of_property_read_string(np, "mode", &mode_str);
 	if (ret) {
 		dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
index 31c312f..40205b9 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
@@ -18,6 +18,7 @@ struct hns_mac_cb;
 
 #define DSAF_DRV_NAME "hns_dsaf"
 #define DSAF_MOD_VERSION "v1.0"
+#define DSAF_DEVICE_NAME "dsaf"
 
 #define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 0e30846..340ca54 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
 	int ret;
 
 	h = hnae_get_handle(&priv->netdev->dev,
-			    priv->ae_name, priv->port_id, NULL);
+			    priv->ae_node, priv->port_id, NULL);
 	if (IS_ERR_OR_NULL(h)) {
 		ret = PTR_ERR(h);
 		dev_dbg(priv->dev, "has not handle, register notifier!\n");
@@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 	else
 		priv->enet_ver = AE_VERSION_2;
 
-	ret = of_property_read_string(node, "ae-name", &priv->ae_name);
-	if (ret)
-		goto out_read_string_fail;
+	priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
+	if (IS_ERR_OR_NULL(priv->ae_node)) {
+		ret = PTR_ERR(priv->ae_node);
+		dev_err(dev, "not find ae-handle\n");
+		goto out_read_handle_fai;
+	}
 
 	ret = of_property_read_u32(node, "port-id", &priv->port_id);
 	if (ret)
@@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 
 out_notify_fail:
 	(void)cancel_work_sync(&priv->service_task);
+out_read_handle_fai:
+
 out_read_string_fail:
 	free_netdev(ndev);
 	return ret;
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.h b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
index 4b75270..c68ab3d 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
@@ -51,7 +51,7 @@ struct hns_nic_ops {
 };
 
 struct hns_nic_priv {
-	const char *ae_name;
+	const struct device_node *ae_node;
 	u32 enet_ver;
 	u32 port_id;
 	int phy_mode;
-- 
2.4.1

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

* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-13  3:01 ` Kejian Yan
  0 siblings, 0 replies; 32+ messages in thread
From: Kejian Yan @ 2016-01-13  3:01 UTC (permalink / raw)
  To: davem, robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	catalin.marinas, will.deacon, huangdaode, liguozhu, arnd,
	fengguang.wu, salil.mehta, andriy.shevchenko, lisheng011
  Cc: haifeng.wei, netdev, devicetree, linux-kernel, linux-arm-kernel,
	linuxarm

This patch replace the assoication between dsaf and enet from string
matching to object reference. It requires the DTS to be updated within
BIOS. Thanks god it can be done for all released boards.

Signed-off-by: Kejian Yan <yankejian@huawei.com>
---
change log:
v2:
 merge the two patches into one to allow bisection.

v1:
 first submit.

v1 patch reference:
 https://lkml.org/lkml/2015/12/5/11
 https://lkml.org/lkml/2015/12/5/12
---
 .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
 .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------
 drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
 drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
 drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
 drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
 10 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
index 80411b2..ecacfa4 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
@@ -4,8 +4,6 @@ Required properties:
 - compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2".
   "hisilicon,hns-dsaf-v1" is for hip05.
   "hisilicon,hns-dsaf-v2" is for Hi1610 and Hi1612.
-- dsa-name: dsa fabric name who provide this interface.
-  should be "dsafX", X is the dsaf id.
 - mode: dsa fabric mode string. only support one of dsaf modes like these:
 		"2port-64vf",
 		"6port-16rss",
@@ -26,9 +24,8 @@ Required properties:
 
 Example:
 
-dsa: dsa@c7000000 {
+dsaf0: dsa@c7000000 {
 	compatible = "hisilicon,hns-dsaf-v1";
-	dsa_name = "dsaf0";
 	mode = "6port-16rss";
 	interrupt-parent = <&mbigen_dsa>;
 	reg = <0x0 0xC0000000 0x0 0x420000
diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
index 41d19be..e6a9d1c 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
@@ -4,8 +4,9 @@ Required properties:
 - compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2".
   "hisilicon,hns-nic-v1" is for hip05.
   "hisilicon,hns-nic-v2" is for Hi1610 and Hi1612.
-- ae-name: accelerator name who provides this interface,
-  is simply a name referring to the name of name in the accelerator node.
+- ae-handle: accelerator engine handle for hns,
+  specifies a reference to the associating hardware driver node.
+  see Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
 - port-id: is the index of port provided by DSAF (the accelerator). DSAF can
   connect to 8 PHYs. Port 0 to 1 are both used for adminstration purpose. They
   are called debug ports.
@@ -41,7 +42,7 @@ Example:
 
 	ethernet@0{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <0>;
 		local-mac-address = [a2 14 e4 4b 56 76];
 	};
diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
index 606dd5a..89c883e 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
@@ -23,9 +23,8 @@ soc0: soc@000000000 {
 		};
 	};
 
-	dsa: dsa@c7000000 {
+	dsaf0: dsa@c7000000 {
 		compatible = "hisilicon,hns-dsaf-v1";
-		dsa_name = "dsaf0";
 		mode = "6port-16rss";
 		interrupt-parent = <&mbigen_dsa>;
 
@@ -127,7 +126,7 @@ soc0: soc@000000000 {
 
 	eth0: ethernet@0{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <0>;
 		local-mac-address = [00 00 00 01 00 58];
 		status = "disabled";
@@ -135,14 +134,14 @@ soc0: soc@000000000 {
 	};
 	eth1: ethernet@1{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <1>;
 		status = "disabled";
 		dma-coherent;
 	};
 	eth2: ethernet@2{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <2>;
 		local-mac-address = [00 00 00 01 00 5a];
 		status = "disabled";
@@ -150,7 +149,7 @@ soc0: soc@000000000 {
 	};
 	eth3: ethernet@3{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <3>;
 		local-mac-address = [00 00 00 01 00 5b];
 		status = "disabled";
@@ -158,7 +157,7 @@ soc0: soc@000000000 {
 	};
 	eth4: ethernet@4{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <4>;
 		local-mac-address = [00 00 00 01 00 5c];
 		status = "disabled";
@@ -166,7 +165,7 @@ soc0: soc@000000000 {
 	};
 	eth5: ethernet@5{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <5>;
 		local-mac-address = [00 00 00 01 00 5d];
 		status = "disabled";
@@ -174,7 +173,7 @@ soc0: soc@000000000 {
 	};
 	eth6: ethernet@6{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <6>;
 		local-mac-address = [00 00 00 01 00 5e];
 		status = "disabled";
@@ -182,7 +181,7 @@ soc0: soc@000000000 {
 	};
 	eth7: ethernet@7{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <7>;
 		local-mac-address = [00 00 00 01 00 5f];
 		status = "disabled";
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
index b364529..3bfe36f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.c
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
@@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = {
 static int __ae_match(struct device *dev, const void *data)
 {
 	struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
-	const char *ae_id = data;
 
-	if (!strncmp(ae_id, hdev->name, AE_NAME_SIZE))
-		return 1;
-
-	return 0;
+	return hdev->dev->of_node == data;
 }
 
-static struct hnae_ae_dev *find_ae(const char *ae_id)
+static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
 {
 	struct device *dev;
 
-	WARN_ON(!ae_id);
+	WARN_ON(!ae_node);
 
-	dev = class_find_device(hnae_class, NULL, ae_id, __ae_match);
+	dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
 
 	return dev ? cls_to_ae_dev(dev) : NULL;
 }
@@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle);
  * return handle ptr or ERR_PTR
  */
 struct hnae_handle *hnae_get_handle(struct device *owner_dev,
-				    const char *ae_id, u32 port_id,
+				    const struct device_node *ae_node,
+				    u32 port_id,
 				    struct hnae_buf_ops *bops)
 {
 	struct hnae_ae_dev *dev;
@@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
 	int i, j;
 	int ret;
 
-	dev = find_ae(ae_id);
+	dev = find_ae(ae_node);
 	if (!dev)
 		return ERR_PTR(-ENODEV);
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
index 6ca94dc..1cbcb9f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -524,8 +524,11 @@ struct hnae_handle {
 
 #define ring_to_dev(ring) ((ring)->q->dev->dev)
 
-struct hnae_handle *hnae_get_handle(struct device *owner_dev, const char *ae_id,
-				    u32 port_id, struct hnae_buf_ops *bops);
+struct hnae_handle *hnae_get_handle(struct device *owner_dev,
+				    const struct device_node *ae_node,
+				    u32 port_id,
+				    struct hnae_buf_ops *bops);
+
 void hnae_put_handle(struct hnae_handle *handle);
 int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
 void hnae_ae_unregister(struct hnae_ae_dev *dev);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index 522b264..a0070d0 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
 int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
 {
 	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
+	static atomic_t id = ATOMIC_INIT(-1);
 
 	switch (dsaf_dev->dsaf_ver) {
 	case AE_VERSION_1:
@@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
 	default:
 		break;
 	}
+
+	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d", DSAF_DEVICE_NAME,
+		 (int)atomic_inc_return(&id));
 	ae_dev->ops = &hns_dsaf_ops;
 	ae_dev->dev = dsaf_dev->dev;
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 1c33bd0..9439f04 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
 	int ret, i;
 	u32 desc_num;
 	u32 buf_size;
-	const char *name, *mode_str;
+	const char *mode_str;
 	struct device_node *np = dsaf_dev->dev->of_node;
 
 	if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
@@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
 	else
 		dsaf_dev->dsaf_ver = AE_VERSION_2;
 
-	ret = of_property_read_string(np, "dsa_name", &name);
-	if (ret) {
-		dev_err(dsaf_dev->dev, "get dsaf name fail, ret=%d!\n", ret);
-		return ret;
-	}
-	strncpy(dsaf_dev->ae_dev.name, name, AE_NAME_SIZE);
-	dsaf_dev->ae_dev.name[AE_NAME_SIZE - 1] = '\0';
-
 	ret = of_property_read_string(np, "mode", &mode_str);
 	if (ret) {
 		dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
index 31c312f..40205b9 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
@@ -18,6 +18,7 @@ struct hns_mac_cb;
 
 #define DSAF_DRV_NAME "hns_dsaf"
 #define DSAF_MOD_VERSION "v1.0"
+#define DSAF_DEVICE_NAME "dsaf"
 
 #define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 0e30846..340ca54 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
 	int ret;
 
 	h = hnae_get_handle(&priv->netdev->dev,
-			    priv->ae_name, priv->port_id, NULL);
+			    priv->ae_node, priv->port_id, NULL);
 	if (IS_ERR_OR_NULL(h)) {
 		ret = PTR_ERR(h);
 		dev_dbg(priv->dev, "has not handle, register notifier!\n");
@@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 	else
 		priv->enet_ver = AE_VERSION_2;
 
-	ret = of_property_read_string(node, "ae-name", &priv->ae_name);
-	if (ret)
-		goto out_read_string_fail;
+	priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
+	if (IS_ERR_OR_NULL(priv->ae_node)) {
+		ret = PTR_ERR(priv->ae_node);
+		dev_err(dev, "not find ae-handle\n");
+		goto out_read_handle_fai;
+	}
 
 	ret = of_property_read_u32(node, "port-id", &priv->port_id);
 	if (ret)
@@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 
 out_notify_fail:
 	(void)cancel_work_sync(&priv->service_task);
+out_read_handle_fai:
+
 out_read_string_fail:
 	free_netdev(ndev);
 	return ret;
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.h b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
index 4b75270..c68ab3d 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
@@ -51,7 +51,7 @@ struct hns_nic_ops {
 };
 
 struct hns_nic_priv {
-	const char *ae_name;
+	const struct device_node *ae_node;
 	u32 enet_ver;
 	u32 port_id;
 	int phy_mode;
-- 
2.4.1

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

* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-13  3:01 ` Kejian Yan
  0 siblings, 0 replies; 32+ messages in thread
From: Kejian Yan @ 2016-01-13  3:01 UTC (permalink / raw)
  To: linux-arm-kernel

This patch replace the assoication between dsaf and enet from string
matching to object reference. It requires the DTS to be updated within
BIOS. Thanks god it can be done for all released boards.

Signed-off-by: Kejian Yan <yankejian@huawei.com>
---
change log:
v2:
 merge the two patches into one to allow bisection.

v1:
 first submit.

v1 patch reference:
 https://lkml.org/lkml/2015/12/5/11
 https://lkml.org/lkml/2015/12/5/12
---
 .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
 .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------
 drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
 drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
 drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
 drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
 10 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
index 80411b2..ecacfa4 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
@@ -4,8 +4,6 @@ Required properties:
 - compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2".
   "hisilicon,hns-dsaf-v1" is for hip05.
   "hisilicon,hns-dsaf-v2" is for Hi1610 and Hi1612.
-- dsa-name: dsa fabric name who provide this interface.
-  should be "dsafX", X is the dsaf id.
 - mode: dsa fabric mode string. only support one of dsaf modes like these:
 		"2port-64vf",
 		"6port-16rss",
@@ -26,9 +24,8 @@ Required properties:
 
 Example:
 
-dsa: dsa at c7000000 {
+dsaf0: dsa at c7000000 {
 	compatible = "hisilicon,hns-dsaf-v1";
-	dsa_name = "dsaf0";
 	mode = "6port-16rss";
 	interrupt-parent = <&mbigen_dsa>;
 	reg = <0x0 0xC0000000 0x0 0x420000
diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
index 41d19be..e6a9d1c 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
@@ -4,8 +4,9 @@ Required properties:
 - compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2".
   "hisilicon,hns-nic-v1" is for hip05.
   "hisilicon,hns-nic-v2" is for Hi1610 and Hi1612.
-- ae-name: accelerator name who provides this interface,
-  is simply a name referring to the name of name in the accelerator node.
+- ae-handle: accelerator engine handle for hns,
+  specifies a reference to the associating hardware driver node.
+  see Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
 - port-id: is the index of port provided by DSAF (the accelerator). DSAF can
   connect to 8 PHYs. Port 0 to 1 are both used for adminstration purpose. They
   are called debug ports.
@@ -41,7 +42,7 @@ Example:
 
 	ethernet@0{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <0>;
 		local-mac-address = [a2 14 e4 4b 56 76];
 	};
diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
index 606dd5a..89c883e 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
@@ -23,9 +23,8 @@ soc0: soc at 000000000 {
 		};
 	};
 
-	dsa: dsa at c7000000 {
+	dsaf0: dsa at c7000000 {
 		compatible = "hisilicon,hns-dsaf-v1";
-		dsa_name = "dsaf0";
 		mode = "6port-16rss";
 		interrupt-parent = <&mbigen_dsa>;
 
@@ -127,7 +126,7 @@ soc0: soc at 000000000 {
 
 	eth0: ethernet at 0{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <0>;
 		local-mac-address = [00 00 00 01 00 58];
 		status = "disabled";
@@ -135,14 +134,14 @@ soc0: soc at 000000000 {
 	};
 	eth1: ethernet at 1{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <1>;
 		status = "disabled";
 		dma-coherent;
 	};
 	eth2: ethernet at 2{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <2>;
 		local-mac-address = [00 00 00 01 00 5a];
 		status = "disabled";
@@ -150,7 +149,7 @@ soc0: soc at 000000000 {
 	};
 	eth3: ethernet at 3{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <3>;
 		local-mac-address = [00 00 00 01 00 5b];
 		status = "disabled";
@@ -158,7 +157,7 @@ soc0: soc at 000000000 {
 	};
 	eth4: ethernet at 4{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <4>;
 		local-mac-address = [00 00 00 01 00 5c];
 		status = "disabled";
@@ -166,7 +165,7 @@ soc0: soc at 000000000 {
 	};
 	eth5: ethernet at 5{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <5>;
 		local-mac-address = [00 00 00 01 00 5d];
 		status = "disabled";
@@ -174,7 +173,7 @@ soc0: soc at 000000000 {
 	};
 	eth6: ethernet at 6{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <6>;
 		local-mac-address = [00 00 00 01 00 5e];
 		status = "disabled";
@@ -182,7 +181,7 @@ soc0: soc at 000000000 {
 	};
 	eth7: ethernet at 7{
 		compatible = "hisilicon,hns-nic-v1";
-		ae-name = "dsaf0";
+		ae-handle = <&dsaf0>;
 		port-id = <7>;
 		local-mac-address = [00 00 00 01 00 5f];
 		status = "disabled";
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
index b364529..3bfe36f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.c
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
@@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = {
 static int __ae_match(struct device *dev, const void *data)
 {
 	struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
-	const char *ae_id = data;
 
-	if (!strncmp(ae_id, hdev->name, AE_NAME_SIZE))
-		return 1;
-
-	return 0;
+	return hdev->dev->of_node == data;
 }
 
-static struct hnae_ae_dev *find_ae(const char *ae_id)
+static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
 {
 	struct device *dev;
 
-	WARN_ON(!ae_id);
+	WARN_ON(!ae_node);
 
-	dev = class_find_device(hnae_class, NULL, ae_id, __ae_match);
+	dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
 
 	return dev ? cls_to_ae_dev(dev) : NULL;
 }
@@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle);
  * return handle ptr or ERR_PTR
  */
 struct hnae_handle *hnae_get_handle(struct device *owner_dev,
-				    const char *ae_id, u32 port_id,
+				    const struct device_node *ae_node,
+				    u32 port_id,
 				    struct hnae_buf_ops *bops)
 {
 	struct hnae_ae_dev *dev;
@@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
 	int i, j;
 	int ret;
 
-	dev = find_ae(ae_id);
+	dev = find_ae(ae_node);
 	if (!dev)
 		return ERR_PTR(-ENODEV);
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
index 6ca94dc..1cbcb9f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -524,8 +524,11 @@ struct hnae_handle {
 
 #define ring_to_dev(ring) ((ring)->q->dev->dev)
 
-struct hnae_handle *hnae_get_handle(struct device *owner_dev, const char *ae_id,
-				    u32 port_id, struct hnae_buf_ops *bops);
+struct hnae_handle *hnae_get_handle(struct device *owner_dev,
+				    const struct device_node *ae_node,
+				    u32 port_id,
+				    struct hnae_buf_ops *bops);
+
 void hnae_put_handle(struct hnae_handle *handle);
 int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
 void hnae_ae_unregister(struct hnae_ae_dev *dev);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index 522b264..a0070d0 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
 int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
 {
 	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
+	static atomic_t id = ATOMIC_INIT(-1);
 
 	switch (dsaf_dev->dsaf_ver) {
 	case AE_VERSION_1:
@@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
 	default:
 		break;
 	}
+
+	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d", DSAF_DEVICE_NAME,
+		 (int)atomic_inc_return(&id));
 	ae_dev->ops = &hns_dsaf_ops;
 	ae_dev->dev = dsaf_dev->dev;
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 1c33bd0..9439f04 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
 	int ret, i;
 	u32 desc_num;
 	u32 buf_size;
-	const char *name, *mode_str;
+	const char *mode_str;
 	struct device_node *np = dsaf_dev->dev->of_node;
 
 	if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
@@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
 	else
 		dsaf_dev->dsaf_ver = AE_VERSION_2;
 
-	ret = of_property_read_string(np, "dsa_name", &name);
-	if (ret) {
-		dev_err(dsaf_dev->dev, "get dsaf name fail, ret=%d!\n", ret);
-		return ret;
-	}
-	strncpy(dsaf_dev->ae_dev.name, name, AE_NAME_SIZE);
-	dsaf_dev->ae_dev.name[AE_NAME_SIZE - 1] = '\0';
-
 	ret = of_property_read_string(np, "mode", &mode_str);
 	if (ret) {
 		dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
index 31c312f..40205b9 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
@@ -18,6 +18,7 @@ struct hns_mac_cb;
 
 #define DSAF_DRV_NAME "hns_dsaf"
 #define DSAF_MOD_VERSION "v1.0"
+#define DSAF_DEVICE_NAME "dsaf"
 
 #define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 0e30846..340ca54 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
 	int ret;
 
 	h = hnae_get_handle(&priv->netdev->dev,
-			    priv->ae_name, priv->port_id, NULL);
+			    priv->ae_node, priv->port_id, NULL);
 	if (IS_ERR_OR_NULL(h)) {
 		ret = PTR_ERR(h);
 		dev_dbg(priv->dev, "has not handle, register notifier!\n");
@@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 	else
 		priv->enet_ver = AE_VERSION_2;
 
-	ret = of_property_read_string(node, "ae-name", &priv->ae_name);
-	if (ret)
-		goto out_read_string_fail;
+	priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
+	if (IS_ERR_OR_NULL(priv->ae_node)) {
+		ret = PTR_ERR(priv->ae_node);
+		dev_err(dev, "not find ae-handle\n");
+		goto out_read_handle_fai;
+	}
 
 	ret = of_property_read_u32(node, "port-id", &priv->port_id);
 	if (ret)
@@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 
 out_notify_fail:
 	(void)cancel_work_sync(&priv->service_task);
+out_read_handle_fai:
+
 out_read_string_fail:
 	free_netdev(ndev);
 	return ret;
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.h b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
index 4b75270..c68ab3d 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
@@ -51,7 +51,7 @@ struct hns_nic_ops {
 };
 
 struct hns_nic_priv {
-	const char *ae_name;
+	const struct device_node *ae_node;
 	u32 enet_ver;
 	u32 port_id;
 	int phy_mode;
-- 
2.4.1

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
  2016-01-13  2:54   ` David Miller
  (?)
@ 2016-01-13  3:00   ` Yankejian (Hackim Yim)
  -1 siblings, 0 replies; 32+ messages in thread
From: Yankejian (Hackim Yim) @ 2016-01-13  3:00 UTC (permalink / raw)
  To: David Miller
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	catalin.marinas, will.deacon, huangdaode, liguozhu, arnd,
	fengguang.wu, salil.mehta, andriy.shevchenko, lisheng011,
	haifeng.wei, netdev, devicetree, linux-kernel, linux-arm-kernel,
	linuxarm

[-- Attachment #1: Type: text/plain, Size: 318 bytes --]

Hi David,

   i am sorry for the /wrong operation. i will pay more attention next time. /

Best Regards,
Kejian Yan

On 2016/1/13 10:54, David Miller wrote:
> This is so confusing.  Why are you submitting a singleton patch and
> then a 2 patch series for the same exact hns driver?
>
> Please do not do this.
>
> .
>


[-- Attachment #2: Type: text/html, Size: 1052 bytes --]

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
  2016-01-13  3:01 ` Kejian Yan
@ 2016-01-13  2:54   ` David Miller
  -1 siblings, 0 replies; 32+ messages in thread
From: David Miller @ 2016-01-13  2:54 UTC (permalink / raw)
  To: yankejian
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	catalin.marinas, will.deacon, huangdaode, liguozhu, arnd,
	fengguang.wu, salil.mehta, andriy.shevchenko, lisheng011,
	haifeng.wei, netdev, devicetree, linux-kernel, linux-arm-kernel,
	linuxarm


This is so confusing.  Why are you submitting a singleton patch and
then a 2 patch series for the same exact hns driver?

Please do not do this.

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

* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-13  2:54   ` David Miller
  0 siblings, 0 replies; 32+ messages in thread
From: David Miller @ 2016-01-13  2:54 UTC (permalink / raw)
  To: linux-arm-kernel


This is so confusing.  Why are you submitting a singleton patch and
then a 2 patch series for the same exact hns driver?

Please do not do this.

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
  2016-01-13  3:01 ` Kejian Yan
  (?)
@ 2016-01-13  2:52   ` Yankejian (Hackim Yim)
  -1 siblings, 0 replies; 32+ messages in thread
From: Yankejian (Hackim Yim) @ 2016-01-13  2:52 UTC (permalink / raw)
  To: davem, robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	catalin.marinas, will.deacon, huangdaode, liguozhu, arnd,
	fengguang.wu, salil.mehta, andriy.shevchenko, lisheng011
  Cc: devicetree, netdev, linuxarm, linux-kernel, linux-arm-kernel

Dear all,
    please ignore this patchset.
    i am sorry. it is incorrect operation.

Best Regards,
Kejian Yan

On 2016/1/13 11:01, Kejian Yan wrote:
> This patch replace the assoication between dsaf and enet from string
> matching to object reference. It requires the DTS to be updated within
> BIOS. Thanks god it can be done for all released boards.
>
> Signed-off-by: Kejian Yan <yankejian@huawei.com>
> ---
> change log:
> v2:
>  merge the two patches into one to allow bisection.
>
> v1:
>  first submit.
>
> v1 patch reference:
>  https://lkml.org/lkml/2015/12/5/11
>  https://lkml.org/lkml/2015/12/5/12
> ---
>  .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
>  .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
>  arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
>  drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
>  drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
>  drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
>  10 files changed, 42 insertions(+), 43 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> index 80411b2..ecacfa4 100644
> --- a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> +++ b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> @@ -4,8 +4,6 @@ Required properties:
>  - compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2".
>    "hisilicon,hns-dsaf-v1" is for hip05.
>    "hisilicon,hns-dsaf-v2" is for Hi1610 and Hi1612.
> -- dsa-name: dsa fabric name who provide this interface.
> -  should be "dsafX", X is the dsaf id.
>  - mode: dsa fabric mode string. only support one of dsaf modes like these:
>  		"2port-64vf",
>  		"6port-16rss",
> @@ -26,9 +24,8 @@ Required properties:
>  
>  Example:
>  
> -dsa: dsa@c7000000 {
> +dsaf0: dsa@c7000000 {
>  	compatible = "hisilicon,hns-dsaf-v1";
> -	dsa_name = "dsaf0";
>  	mode = "6port-16rss";
>  	interrupt-parent = <&mbigen_dsa>;
>  	reg = <0x0 0xC0000000 0x0 0x420000
> diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> index 41d19be..e6a9d1c 100644
> --- a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> +++ b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> @@ -4,8 +4,9 @@ Required properties:
>  - compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2".
>    "hisilicon,hns-nic-v1" is for hip05.
>    "hisilicon,hns-nic-v2" is for Hi1610 and Hi1612.
> -- ae-name: accelerator name who provides this interface,
> -  is simply a name referring to the name of name in the accelerator node.
> +- ae-handle: accelerator engine handle for hns,
> +  specifies a reference to the associating hardware driver node.
> +  see Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
>  - port-id: is the index of port provided by DSAF (the accelerator). DSAF can
>    connect to 8 PHYs. Port 0 to 1 are both used for adminstration purpose. They
>    are called debug ports.
> @@ -41,7 +42,7 @@ Example:
>  
>  	ethernet@0{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <0>;
>  		local-mac-address = [a2 14 e4 4b 56 76];
>  	};
> diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> index 606dd5a..89c883e 100644
> --- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> +++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> @@ -23,9 +23,8 @@ soc0: soc@000000000 {
>  		};
>  	};
>  
> -	dsa: dsa@c7000000 {
> +	dsaf0: dsa@c7000000 {
>  		compatible = "hisilicon,hns-dsaf-v1";
> -		dsa_name = "dsaf0";
>  		mode = "6port-16rss";
>  		interrupt-parent = <&mbigen_dsa>;
>  
> @@ -127,7 +126,7 @@ soc0: soc@000000000 {
>  
>  	eth0: ethernet@0{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <0>;
>  		local-mac-address = [00 00 00 01 00 58];
>  		status = "disabled";
> @@ -135,14 +134,14 @@ soc0: soc@000000000 {
>  	};
>  	eth1: ethernet@1{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <1>;
>  		status = "disabled";
>  		dma-coherent;
>  	};
>  	eth2: ethernet@2{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <2>;
>  		local-mac-address = [00 00 00 01 00 5a];
>  		status = "disabled";
> @@ -150,7 +149,7 @@ soc0: soc@000000000 {
>  	};
>  	eth3: ethernet@3{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <3>;
>  		local-mac-address = [00 00 00 01 00 5b];
>  		status = "disabled";
> @@ -158,7 +157,7 @@ soc0: soc@000000000 {
>  	};
>  	eth4: ethernet@4{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <4>;
>  		local-mac-address = [00 00 00 01 00 5c];
>  		status = "disabled";
> @@ -166,7 +165,7 @@ soc0: soc@000000000 {
>  	};
>  	eth5: ethernet@5{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <5>;
>  		local-mac-address = [00 00 00 01 00 5d];
>  		status = "disabled";
> @@ -174,7 +173,7 @@ soc0: soc@000000000 {
>  	};
>  	eth6: ethernet@6{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <6>;
>  		local-mac-address = [00 00 00 01 00 5e];
>  		status = "disabled";
> @@ -182,7 +181,7 @@ soc0: soc@000000000 {
>  	};
>  	eth7: ethernet@7{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <7>;
>  		local-mac-address = [00 00 00 01 00 5f];
>  		status = "disabled";
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
> index b364529..3bfe36f 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
> @@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = {
>  static int __ae_match(struct device *dev, const void *data)
>  {
>  	struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
> -	const char *ae_id = data;
>  
> -	if (!strncmp(ae_id, hdev->name, AE_NAME_SIZE))
> -		return 1;
> -
> -	return 0;
> +	return hdev->dev->of_node == data;
>  }
>  
> -static struct hnae_ae_dev *find_ae(const char *ae_id)
> +static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
>  {
>  	struct device *dev;
>  
> -	WARN_ON(!ae_id);
> +	WARN_ON(!ae_node);
>  
> -	dev = class_find_device(hnae_class, NULL, ae_id, __ae_match);
> +	dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
>  
>  	return dev ? cls_to_ae_dev(dev) : NULL;
>  }
> @@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle);
>   * return handle ptr or ERR_PTR
>   */
>  struct hnae_handle *hnae_get_handle(struct device *owner_dev,
> -				    const char *ae_id, u32 port_id,
> +				    const struct device_node *ae_node,
> +				    u32 port_id,
>  				    struct hnae_buf_ops *bops)
>  {
>  	struct hnae_ae_dev *dev;
> @@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
>  	int i, j;
>  	int ret;
>  
> -	dev = find_ae(ae_id);
> +	dev = find_ae(ae_node);
>  	if (!dev)
>  		return ERR_PTR(-ENODEV);
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
> index 6ca94dc..1cbcb9f 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
> @@ -524,8 +524,11 @@ struct hnae_handle {
>  
>  #define ring_to_dev(ring) ((ring)->q->dev->dev)
>  
> -struct hnae_handle *hnae_get_handle(struct device *owner_dev, const char *ae_id,
> -				    u32 port_id, struct hnae_buf_ops *bops);
> +struct hnae_handle *hnae_get_handle(struct device *owner_dev,
> +				    const struct device_node *ae_node,
> +				    u32 port_id,
> +				    struct hnae_buf_ops *bops);
> +
>  void hnae_put_handle(struct hnae_handle *handle);
>  int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
>  void hnae_ae_unregister(struct hnae_ae_dev *dev);
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> index 522b264..a0070d0 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
>  int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>  {
>  	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
> +	static atomic_t id = ATOMIC_INIT(-1);
>  
>  	switch (dsaf_dev->dsaf_ver) {
>  	case AE_VERSION_1:
> @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>  	default:
>  		break;
>  	}
> +
> +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d", DSAF_DEVICE_NAME,
> +		 (int)atomic_inc_return(&id));
>  	ae_dev->ops = &hns_dsaf_ops;
>  	ae_dev->dev = dsaf_dev->dev;
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> index 1c33bd0..9439f04 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> @@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
>  	int ret, i;
>  	u32 desc_num;
>  	u32 buf_size;
> -	const char *name, *mode_str;
> +	const char *mode_str;
>  	struct device_node *np = dsaf_dev->dev->of_node;
>  
>  	if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
> @@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
>  	else
>  		dsaf_dev->dsaf_ver = AE_VERSION_2;
>  
> -	ret = of_property_read_string(np, "dsa_name", &name);
> -	if (ret) {
> -		dev_err(dsaf_dev->dev, "get dsaf name fail, ret=%d!\n", ret);
> -		return ret;
> -	}
> -	strncpy(dsaf_dev->ae_dev.name, name, AE_NAME_SIZE);
> -	dsaf_dev->ae_dev.name[AE_NAME_SIZE - 1] = '\0';
> -
>  	ret = of_property_read_string(np, "mode", &mode_str);
>  	if (ret) {
>  		dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> index 31c312f..40205b9 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> @@ -18,6 +18,7 @@ struct hns_mac_cb;
>  
>  #define DSAF_DRV_NAME "hns_dsaf"
>  #define DSAF_MOD_VERSION "v1.0"
> +#define DSAF_DEVICE_NAME "dsaf"
>  
>  #define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> index 0e30846..340ca54 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> @@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
>  	int ret;
>  
>  	h = hnae_get_handle(&priv->netdev->dev,
> -			    priv->ae_name, priv->port_id, NULL);
> +			    priv->ae_node, priv->port_id, NULL);
>  	if (IS_ERR_OR_NULL(h)) {
>  		ret = PTR_ERR(h);
>  		dev_dbg(priv->dev, "has not handle, register notifier!\n");
> @@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
>  	else
>  		priv->enet_ver = AE_VERSION_2;
>  
> -	ret = of_property_read_string(node, "ae-name", &priv->ae_name);
> -	if (ret)
> -		goto out_read_string_fail;
> +	priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
> +	if (IS_ERR_OR_NULL(priv->ae_node)) {
> +		ret = PTR_ERR(priv->ae_node);
> +		dev_err(dev, "not find ae-handle\n");
> +		goto out_read_handle_fai;
> +	}
>  
>  	ret = of_property_read_u32(node, "port-id", &priv->port_id);
>  	if (ret)
> @@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
>  
>  out_notify_fail:
>  	(void)cancel_work_sync(&priv->service_task);
> +out_read_handle_fai:
> +
>  out_read_string_fail:
>  	free_netdev(ndev);
>  	return ret;
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.h b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> index 4b75270..c68ab3d 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> @@ -51,7 +51,7 @@ struct hns_nic_ops {
>  };
>  
>  struct hns_nic_priv {
> -	const char *ae_name;
> +	const struct device_node *ae_node;
>  	u32 enet_ver;
>  	u32 port_id;
>  	int phy_mode;

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

* Re: [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-13  2:52   ` Yankejian (Hackim Yim)
  0 siblings, 0 replies; 32+ messages in thread
From: Yankejian (Hackim Yim) @ 2016-01-13  2:52 UTC (permalink / raw)
  To: davem, robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	catalin.marinas, will.deacon, huangdaode, liguozhu, arnd,
	fengguang.wu, salil.mehta, andriy.shevchenko, lisheng011
  Cc: devicetree, netdev, linuxarm, linux-kernel, linux-arm-kernel

Dear all,
    please ignore this patchset.
    i am sorry. it is incorrect operation.

Best Regards,
Kejian Yan

On 2016/1/13 11:01, Kejian Yan wrote:
> This patch replace the assoication between dsaf and enet from string
> matching to object reference. It requires the DTS to be updated within
> BIOS. Thanks god it can be done for all released boards.
>
> Signed-off-by: Kejian Yan <yankejian@huawei.com>
> ---
> change log:
> v2:
>  merge the two patches into one to allow bisection.
>
> v1:
>  first submit.
>
> v1 patch reference:
>  https://lkml.org/lkml/2015/12/5/11
>  https://lkml.org/lkml/2015/12/5/12
> ---
>  .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
>  .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
>  arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
>  drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
>  drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
>  drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
>  10 files changed, 42 insertions(+), 43 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> index 80411b2..ecacfa4 100644
> --- a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> +++ b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> @@ -4,8 +4,6 @@ Required properties:
>  - compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2".
>    "hisilicon,hns-dsaf-v1" is for hip05.
>    "hisilicon,hns-dsaf-v2" is for Hi1610 and Hi1612.
> -- dsa-name: dsa fabric name who provide this interface.
> -  should be "dsafX", X is the dsaf id.
>  - mode: dsa fabric mode string. only support one of dsaf modes like these:
>  		"2port-64vf",
>  		"6port-16rss",
> @@ -26,9 +24,8 @@ Required properties:
>  
>  Example:
>  
> -dsa: dsa@c7000000 {
> +dsaf0: dsa@c7000000 {
>  	compatible = "hisilicon,hns-dsaf-v1";
> -	dsa_name = "dsaf0";
>  	mode = "6port-16rss";
>  	interrupt-parent = <&mbigen_dsa>;
>  	reg = <0x0 0xC0000000 0x0 0x420000
> diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> index 41d19be..e6a9d1c 100644
> --- a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> +++ b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> @@ -4,8 +4,9 @@ Required properties:
>  - compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2".
>    "hisilicon,hns-nic-v1" is for hip05.
>    "hisilicon,hns-nic-v2" is for Hi1610 and Hi1612.
> -- ae-name: accelerator name who provides this interface,
> -  is simply a name referring to the name of name in the accelerator node.
> +- ae-handle: accelerator engine handle for hns,
> +  specifies a reference to the associating hardware driver node.
> +  see Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
>  - port-id: is the index of port provided by DSAF (the accelerator). DSAF can
>    connect to 8 PHYs. Port 0 to 1 are both used for adminstration purpose. They
>    are called debug ports.
> @@ -41,7 +42,7 @@ Example:
>  
>  	ethernet@0{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <0>;
>  		local-mac-address = [a2 14 e4 4b 56 76];
>  	};
> diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> index 606dd5a..89c883e 100644
> --- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> +++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> @@ -23,9 +23,8 @@ soc0: soc@000000000 {
>  		};
>  	};
>  
> -	dsa: dsa@c7000000 {
> +	dsaf0: dsa@c7000000 {
>  		compatible = "hisilicon,hns-dsaf-v1";
> -		dsa_name = "dsaf0";
>  		mode = "6port-16rss";
>  		interrupt-parent = <&mbigen_dsa>;
>  
> @@ -127,7 +126,7 @@ soc0: soc@000000000 {
>  
>  	eth0: ethernet@0{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <0>;
>  		local-mac-address = [00 00 00 01 00 58];
>  		status = "disabled";
> @@ -135,14 +134,14 @@ soc0: soc@000000000 {
>  	};
>  	eth1: ethernet@1{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <1>;
>  		status = "disabled";
>  		dma-coherent;
>  	};
>  	eth2: ethernet@2{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <2>;
>  		local-mac-address = [00 00 00 01 00 5a];
>  		status = "disabled";
> @@ -150,7 +149,7 @@ soc0: soc@000000000 {
>  	};
>  	eth3: ethernet@3{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <3>;
>  		local-mac-address = [00 00 00 01 00 5b];
>  		status = "disabled";
> @@ -158,7 +157,7 @@ soc0: soc@000000000 {
>  	};
>  	eth4: ethernet@4{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <4>;
>  		local-mac-address = [00 00 00 01 00 5c];
>  		status = "disabled";
> @@ -166,7 +165,7 @@ soc0: soc@000000000 {
>  	};
>  	eth5: ethernet@5{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <5>;
>  		local-mac-address = [00 00 00 01 00 5d];
>  		status = "disabled";
> @@ -174,7 +173,7 @@ soc0: soc@000000000 {
>  	};
>  	eth6: ethernet@6{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <6>;
>  		local-mac-address = [00 00 00 01 00 5e];
>  		status = "disabled";
> @@ -182,7 +181,7 @@ soc0: soc@000000000 {
>  	};
>  	eth7: ethernet@7{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <7>;
>  		local-mac-address = [00 00 00 01 00 5f];
>  		status = "disabled";
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
> index b364529..3bfe36f 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
> @@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = {
>  static int __ae_match(struct device *dev, const void *data)
>  {
>  	struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
> -	const char *ae_id = data;
>  
> -	if (!strncmp(ae_id, hdev->name, AE_NAME_SIZE))
> -		return 1;
> -
> -	return 0;
> +	return hdev->dev->of_node == data;
>  }
>  
> -static struct hnae_ae_dev *find_ae(const char *ae_id)
> +static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
>  {
>  	struct device *dev;
>  
> -	WARN_ON(!ae_id);
> +	WARN_ON(!ae_node);
>  
> -	dev = class_find_device(hnae_class, NULL, ae_id, __ae_match);
> +	dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
>  
>  	return dev ? cls_to_ae_dev(dev) : NULL;
>  }
> @@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle);
>   * return handle ptr or ERR_PTR
>   */
>  struct hnae_handle *hnae_get_handle(struct device *owner_dev,
> -				    const char *ae_id, u32 port_id,
> +				    const struct device_node *ae_node,
> +				    u32 port_id,
>  				    struct hnae_buf_ops *bops)
>  {
>  	struct hnae_ae_dev *dev;
> @@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
>  	int i, j;
>  	int ret;
>  
> -	dev = find_ae(ae_id);
> +	dev = find_ae(ae_node);
>  	if (!dev)
>  		return ERR_PTR(-ENODEV);
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
> index 6ca94dc..1cbcb9f 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
> @@ -524,8 +524,11 @@ struct hnae_handle {
>  
>  #define ring_to_dev(ring) ((ring)->q->dev->dev)
>  
> -struct hnae_handle *hnae_get_handle(struct device *owner_dev, const char *ae_id,
> -				    u32 port_id, struct hnae_buf_ops *bops);
> +struct hnae_handle *hnae_get_handle(struct device *owner_dev,
> +				    const struct device_node *ae_node,
> +				    u32 port_id,
> +				    struct hnae_buf_ops *bops);
> +
>  void hnae_put_handle(struct hnae_handle *handle);
>  int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
>  void hnae_ae_unregister(struct hnae_ae_dev *dev);
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> index 522b264..a0070d0 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
>  int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>  {
>  	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
> +	static atomic_t id = ATOMIC_INIT(-1);
>  
>  	switch (dsaf_dev->dsaf_ver) {
>  	case AE_VERSION_1:
> @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>  	default:
>  		break;
>  	}
> +
> +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d", DSAF_DEVICE_NAME,
> +		 (int)atomic_inc_return(&id));
>  	ae_dev->ops = &hns_dsaf_ops;
>  	ae_dev->dev = dsaf_dev->dev;
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> index 1c33bd0..9439f04 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> @@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
>  	int ret, i;
>  	u32 desc_num;
>  	u32 buf_size;
> -	const char *name, *mode_str;
> +	const char *mode_str;
>  	struct device_node *np = dsaf_dev->dev->of_node;
>  
>  	if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
> @@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
>  	else
>  		dsaf_dev->dsaf_ver = AE_VERSION_2;
>  
> -	ret = of_property_read_string(np, "dsa_name", &name);
> -	if (ret) {
> -		dev_err(dsaf_dev->dev, "get dsaf name fail, ret=%d!\n", ret);
> -		return ret;
> -	}
> -	strncpy(dsaf_dev->ae_dev.name, name, AE_NAME_SIZE);
> -	dsaf_dev->ae_dev.name[AE_NAME_SIZE - 1] = '\0';
> -
>  	ret = of_property_read_string(np, "mode", &mode_str);
>  	if (ret) {
>  		dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> index 31c312f..40205b9 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> @@ -18,6 +18,7 @@ struct hns_mac_cb;
>  
>  #define DSAF_DRV_NAME "hns_dsaf"
>  #define DSAF_MOD_VERSION "v1.0"
> +#define DSAF_DEVICE_NAME "dsaf"
>  
>  #define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> index 0e30846..340ca54 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> @@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
>  	int ret;
>  
>  	h = hnae_get_handle(&priv->netdev->dev,
> -			    priv->ae_name, priv->port_id, NULL);
> +			    priv->ae_node, priv->port_id, NULL);
>  	if (IS_ERR_OR_NULL(h)) {
>  		ret = PTR_ERR(h);
>  		dev_dbg(priv->dev, "has not handle, register notifier!\n");
> @@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
>  	else
>  		priv->enet_ver = AE_VERSION_2;
>  
> -	ret = of_property_read_string(node, "ae-name", &priv->ae_name);
> -	if (ret)
> -		goto out_read_string_fail;
> +	priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
> +	if (IS_ERR_OR_NULL(priv->ae_node)) {
> +		ret = PTR_ERR(priv->ae_node);
> +		dev_err(dev, "not find ae-handle\n");
> +		goto out_read_handle_fai;
> +	}
>  
>  	ret = of_property_read_u32(node, "port-id", &priv->port_id);
>  	if (ret)
> @@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
>  
>  out_notify_fail:
>  	(void)cancel_work_sync(&priv->service_task);
> +out_read_handle_fai:
> +
>  out_read_string_fail:
>  	free_netdev(ndev);
>  	return ret;
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.h b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> index 4b75270..c68ab3d 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> @@ -51,7 +51,7 @@ struct hns_nic_ops {
>  };
>  
>  struct hns_nic_priv {
> -	const char *ae_name;
> +	const struct device_node *ae_node;
>  	u32 enet_ver;
>  	u32 port_id;
>  	int phy_mode;

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

* [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf
@ 2016-01-13  2:52   ` Yankejian (Hackim Yim)
  0 siblings, 0 replies; 32+ messages in thread
From: Yankejian (Hackim Yim) @ 2016-01-13  2:52 UTC (permalink / raw)
  To: linux-arm-kernel

Dear all,
    please ignore this patchset.
    i am sorry. it is incorrect operation.

Best Regards,
Kejian Yan

On 2016/1/13 11:01, Kejian Yan wrote:
> This patch replace the assoication between dsaf and enet from string
> matching to object reference. It requires the DTS to be updated within
> BIOS. Thanks god it can be done for all released boards.
>
> Signed-off-by: Kejian Yan <yankejian@huawei.com>
> ---
> change log:
> v2:
>  merge the two patches into one to allow bisection.
>
> v1:
>  first submit.
>
> v1 patch reference:
>  https://lkml.org/lkml/2015/12/5/11
>  https://lkml.org/lkml/2015/12/5/12
> ---
>  .../devicetree/bindings/net/hisilicon-hns-dsaf.txt    |  5 +----
>  .../devicetree/bindings/net/hisilicon-hns-nic.txt     |  7 ++++---
>  arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi          | 19 +++++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.c             | 17 +++++++----------
>  drivers/net/ethernet/hisilicon/hns/hnae.h             |  7 +++++--
>  drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c     |  4 ++++
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c    | 10 +---------
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h    |  1 +
>  drivers/net/ethernet/hisilicon/hns/hns_enet.c         | 13 +++++++++----
>  drivers/net/ethernet/hisilicon/hns/hns_enet.h         |  2 +-
>  10 files changed, 42 insertions(+), 43 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> index 80411b2..ecacfa4 100644
> --- a/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> +++ b/Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
> @@ -4,8 +4,6 @@ Required properties:
>  - compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2".
>    "hisilicon,hns-dsaf-v1" is for hip05.
>    "hisilicon,hns-dsaf-v2" is for Hi1610 and Hi1612.
> -- dsa-name: dsa fabric name who provide this interface.
> -  should be "dsafX", X is the dsaf id.
>  - mode: dsa fabric mode string. only support one of dsaf modes like these:
>  		"2port-64vf",
>  		"6port-16rss",
> @@ -26,9 +24,8 @@ Required properties:
>  
>  Example:
>  
> -dsa: dsa at c7000000 {
> +dsaf0: dsa at c7000000 {
>  	compatible = "hisilicon,hns-dsaf-v1";
> -	dsa_name = "dsaf0";
>  	mode = "6port-16rss";
>  	interrupt-parent = <&mbigen_dsa>;
>  	reg = <0x0 0xC0000000 0x0 0x420000
> diff --git a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> index 41d19be..e6a9d1c 100644
> --- a/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> +++ b/Documentation/devicetree/bindings/net/hisilicon-hns-nic.txt
> @@ -4,8 +4,9 @@ Required properties:
>  - compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2".
>    "hisilicon,hns-nic-v1" is for hip05.
>    "hisilicon,hns-nic-v2" is for Hi1610 and Hi1612.
> -- ae-name: accelerator name who provides this interface,
> -  is simply a name referring to the name of name in the accelerator node.
> +- ae-handle: accelerator engine handle for hns,
> +  specifies a reference to the associating hardware driver node.
> +  see Documentation/devicetree/bindings/net/hisilicon-hns-dsaf.txt
>  - port-id: is the index of port provided by DSAF (the accelerator). DSAF can
>    connect to 8 PHYs. Port 0 to 1 are both used for adminstration purpose. They
>    are called debug ports.
> @@ -41,7 +42,7 @@ Example:
>  
>  	ethernet at 0{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <0>;
>  		local-mac-address = [a2 14 e4 4b 56 76];
>  	};
> diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> index 606dd5a..89c883e 100644
> --- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> +++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
> @@ -23,9 +23,8 @@ soc0: soc at 000000000 {
>  		};
>  	};
>  
> -	dsa: dsa at c7000000 {
> +	dsaf0: dsa at c7000000 {
>  		compatible = "hisilicon,hns-dsaf-v1";
> -		dsa_name = "dsaf0";
>  		mode = "6port-16rss";
>  		interrupt-parent = <&mbigen_dsa>;
>  
> @@ -127,7 +126,7 @@ soc0: soc at 000000000 {
>  
>  	eth0: ethernet at 0{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <0>;
>  		local-mac-address = [00 00 00 01 00 58];
>  		status = "disabled";
> @@ -135,14 +134,14 @@ soc0: soc at 000000000 {
>  	};
>  	eth1: ethernet at 1{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <1>;
>  		status = "disabled";
>  		dma-coherent;
>  	};
>  	eth2: ethernet at 2{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <2>;
>  		local-mac-address = [00 00 00 01 00 5a];
>  		status = "disabled";
> @@ -150,7 +149,7 @@ soc0: soc at 000000000 {
>  	};
>  	eth3: ethernet at 3{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <3>;
>  		local-mac-address = [00 00 00 01 00 5b];
>  		status = "disabled";
> @@ -158,7 +157,7 @@ soc0: soc at 000000000 {
>  	};
>  	eth4: ethernet at 4{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <4>;
>  		local-mac-address = [00 00 00 01 00 5c];
>  		status = "disabled";
> @@ -166,7 +165,7 @@ soc0: soc at 000000000 {
>  	};
>  	eth5: ethernet at 5{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <5>;
>  		local-mac-address = [00 00 00 01 00 5d];
>  		status = "disabled";
> @@ -174,7 +173,7 @@ soc0: soc at 000000000 {
>  	};
>  	eth6: ethernet at 6{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <6>;
>  		local-mac-address = [00 00 00 01 00 5e];
>  		status = "disabled";
> @@ -182,7 +181,7 @@ soc0: soc at 000000000 {
>  	};
>  	eth7: ethernet at 7{
>  		compatible = "hisilicon,hns-nic-v1";
> -		ae-name = "dsaf0";
> +		ae-handle = <&dsaf0>;
>  		port-id = <7>;
>  		local-mac-address = [00 00 00 01 00 5f];
>  		status = "disabled";
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
> index b364529..3bfe36f 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
> @@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = {
>  static int __ae_match(struct device *dev, const void *data)
>  {
>  	struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
> -	const char *ae_id = data;
>  
> -	if (!strncmp(ae_id, hdev->name, AE_NAME_SIZE))
> -		return 1;
> -
> -	return 0;
> +	return hdev->dev->of_node == data;
>  }
>  
> -static struct hnae_ae_dev *find_ae(const char *ae_id)
> +static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
>  {
>  	struct device *dev;
>  
> -	WARN_ON(!ae_id);
> +	WARN_ON(!ae_node);
>  
> -	dev = class_find_device(hnae_class, NULL, ae_id, __ae_match);
> +	dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
>  
>  	return dev ? cls_to_ae_dev(dev) : NULL;
>  }
> @@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle);
>   * return handle ptr or ERR_PTR
>   */
>  struct hnae_handle *hnae_get_handle(struct device *owner_dev,
> -				    const char *ae_id, u32 port_id,
> +				    const struct device_node *ae_node,
> +				    u32 port_id,
>  				    struct hnae_buf_ops *bops)
>  {
>  	struct hnae_ae_dev *dev;
> @@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
>  	int i, j;
>  	int ret;
>  
> -	dev = find_ae(ae_id);
> +	dev = find_ae(ae_node);
>  	if (!dev)
>  		return ERR_PTR(-ENODEV);
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
> index 6ca94dc..1cbcb9f 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hnae.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
> @@ -524,8 +524,11 @@ struct hnae_handle {
>  
>  #define ring_to_dev(ring) ((ring)->q->dev->dev)
>  
> -struct hnae_handle *hnae_get_handle(struct device *owner_dev, const char *ae_id,
> -				    u32 port_id, struct hnae_buf_ops *bops);
> +struct hnae_handle *hnae_get_handle(struct device *owner_dev,
> +				    const struct device_node *ae_node,
> +				    u32 port_id,
> +				    struct hnae_buf_ops *bops);
> +
>  void hnae_put_handle(struct hnae_handle *handle);
>  int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
>  void hnae_ae_unregister(struct hnae_ae_dev *dev);
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> index 522b264..a0070d0 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
> @@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
>  int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>  {
>  	struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
> +	static atomic_t id = ATOMIC_INIT(-1);
>  
>  	switch (dsaf_dev->dsaf_ver) {
>  	case AE_VERSION_1:
> @@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
>  	default:
>  		break;
>  	}
> +
> +	snprintf(ae_dev->name, AE_NAME_SIZE, "%s%d", DSAF_DEVICE_NAME,
> +		 (int)atomic_inc_return(&id));
>  	ae_dev->ops = &hns_dsaf_ops;
>  	ae_dev->dev = dsaf_dev->dev;
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> index 1c33bd0..9439f04 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
> @@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
>  	int ret, i;
>  	u32 desc_num;
>  	u32 buf_size;
> -	const char *name, *mode_str;
> +	const char *mode_str;
>  	struct device_node *np = dsaf_dev->dev->of_node;
>  
>  	if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
> @@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
>  	else
>  		dsaf_dev->dsaf_ver = AE_VERSION_2;
>  
> -	ret = of_property_read_string(np, "dsa_name", &name);
> -	if (ret) {
> -		dev_err(dsaf_dev->dev, "get dsaf name fail, ret=%d!\n", ret);
> -		return ret;
> -	}
> -	strncpy(dsaf_dev->ae_dev.name, name, AE_NAME_SIZE);
> -	dsaf_dev->ae_dev.name[AE_NAME_SIZE - 1] = '\0';
> -
>  	ret = of_property_read_string(np, "mode", &mode_str);
>  	if (ret) {
>  		dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> index 31c312f..40205b9 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
> @@ -18,6 +18,7 @@ struct hns_mac_cb;
>  
>  #define DSAF_DRV_NAME "hns_dsaf"
>  #define DSAF_MOD_VERSION "v1.0"
> +#define DSAF_DEVICE_NAME "dsaf"
>  
>  #define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> index 0e30846..340ca54 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> @@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
>  	int ret;
>  
>  	h = hnae_get_handle(&priv->netdev->dev,
> -			    priv->ae_name, priv->port_id, NULL);
> +			    priv->ae_node, priv->port_id, NULL);
>  	if (IS_ERR_OR_NULL(h)) {
>  		ret = PTR_ERR(h);
>  		dev_dbg(priv->dev, "has not handle, register notifier!\n");
> @@ -1880,9 +1880,12 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
>  	else
>  		priv->enet_ver = AE_VERSION_2;
>  
> -	ret = of_property_read_string(node, "ae-name", &priv->ae_name);
> -	if (ret)
> -		goto out_read_string_fail;
> +	priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
> +	if (IS_ERR_OR_NULL(priv->ae_node)) {
> +		ret = PTR_ERR(priv->ae_node);
> +		dev_err(dev, "not find ae-handle\n");
> +		goto out_read_handle_fai;
> +	}
>  
>  	ret = of_property_read_u32(node, "port-id", &priv->port_id);
>  	if (ret)
> @@ -1945,6 +1948,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
>  
>  out_notify_fail:
>  	(void)cancel_work_sync(&priv->service_task);
> +out_read_handle_fai:
> +
>  out_read_string_fail:
>  	free_netdev(ndev);
>  	return ret;
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.h b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> index 4b75270..c68ab3d 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
> @@ -51,7 +51,7 @@ struct hns_nic_ops {
>  };
>  
>  struct hns_nic_priv {
> -	const char *ae_name;
> +	const struct device_node *ae_node;
>  	u32 enet_ver;
>  	u32 port_id;
>  	int phy_mode;

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

end of thread, other threads:[~2016-01-20 11:12 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-13  3:14 [PATCH v2 next-next] net: hns: enet specifies a reference to dsaf Kejian Yan
2016-01-13  3:14 ` Kejian Yan
2016-01-13  3:14 ` Kejian Yan
2016-01-14  3:00 ` Yisen Zhuang
2016-01-14  3:00   ` Yisen Zhuang
2016-01-14  3:00   ` Yisen Zhuang
2016-01-14  9:43   ` Andy Shevchenko
2016-01-14  9:43     ` Andy Shevchenko
2016-01-14  9:43     ` Andy Shevchenko
2016-01-18 11:35     ` Yankejian (Hackim Yim)
2016-01-18 11:35       ` Yankejian (Hackim Yim)
2016-01-18 11:35       ` Yankejian (Hackim Yim)
2016-01-18 11:35       ` Yankejian (Hackim Yim)
2016-01-20  6:49     ` Yankejian (Hackim Yim)
2016-01-20  9:36       ` Andy Shevchenko
2016-01-20  9:36         ` Andy Shevchenko
2016-01-20  9:36         ` Andy Shevchenko
2016-01-20 11:10         ` Yankejian (Hackim Yim)
2016-01-20 11:10           ` Yankejian (Hackim Yim)
2016-01-20 11:10           ` Yankejian (Hackim Yim)
2016-01-15  2:28 ` Rob Herring
2016-01-15  2:28   ` Rob Herring
2016-01-15  2:28   ` Rob Herring
  -- strict thread matches above, loose matches on Subject: below --
2016-01-13  3:01 Kejian Yan
2016-01-13  3:01 ` Kejian Yan
2016-01-13  3:01 ` Kejian Yan
2016-01-13  2:52 ` Yankejian (Hackim Yim)
2016-01-13  2:52   ` Yankejian (Hackim Yim)
2016-01-13  2:52   ` Yankejian (Hackim Yim)
2016-01-13  2:54 ` David Miller
2016-01-13  2:54   ` David Miller
2016-01-13  3:00   ` Yankejian (Hackim Yim)

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.