Commit 48189d6a authored by yankejian's avatar yankejian Committed by David S. Miller

net: hns: enet specifies a reference to dsaf

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: default avatarKejian Yan <yankejian@huawei.com>
Acked-by: default avatarRob Herring <robh@kernel.org>
Acked-by: default avatarYisen Zhuang <yisen.zhuang@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e62a123b
...@@ -4,8 +4,6 @@ Required properties: ...@@ -4,8 +4,6 @@ Required properties:
- compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2". - compatible: should be "hisilicon,hns-dsaf-v1" or "hisilicon,hns-dsaf-v2".
"hisilicon,hns-dsaf-v1" is for hip05. "hisilicon,hns-dsaf-v1" is for hip05.
"hisilicon,hns-dsaf-v2" is for Hi1610 and Hi1612. "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: - mode: dsa fabric mode string. only support one of dsaf modes like these:
"2port-64vf", "2port-64vf",
"6port-16rss", "6port-16rss",
...@@ -26,9 +24,8 @@ Required properties: ...@@ -26,9 +24,8 @@ Required properties:
Example: Example:
dsa: dsa@c7000000 { dsaf0: dsa@c7000000 {
compatible = "hisilicon,hns-dsaf-v1"; compatible = "hisilicon,hns-dsaf-v1";
dsa_name = "dsaf0";
mode = "6port-16rss"; mode = "6port-16rss";
interrupt-parent = <&mbigen_dsa>; interrupt-parent = <&mbigen_dsa>;
reg = <0x0 0xC0000000 0x0 0x420000 reg = <0x0 0xC0000000 0x0 0x420000
......
...@@ -4,8 +4,9 @@ Required properties: ...@@ -4,8 +4,9 @@ Required properties:
- compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2". - compatible: "hisilicon,hns-nic-v1" or "hisilicon,hns-nic-v2".
"hisilicon,hns-nic-v1" is for hip05. "hisilicon,hns-nic-v1" is for hip05.
"hisilicon,hns-nic-v2" is for Hi1610 and Hi1612. "hisilicon,hns-nic-v2" is for Hi1610 and Hi1612.
- ae-name: accelerator name who provides this interface, - ae-handle: accelerator engine handle for hns,
is simply a name referring to the name of name in the accelerator node. 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 - 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 connect to 8 PHYs. Port 0 to 1 are both used for adminstration purpose. They
are called debug ports. are called debug ports.
...@@ -41,7 +42,7 @@ Example: ...@@ -41,7 +42,7 @@ Example:
ethernet@0{ ethernet@0{
compatible = "hisilicon,hns-nic-v1"; compatible = "hisilicon,hns-nic-v1";
ae-name = "dsaf0"; ae-handle = <&dsaf0>;
port-id = <0>; port-id = <0>;
local-mac-address = [a2 14 e4 4b 56 76]; local-mac-address = [a2 14 e4 4b 56 76];
}; };
...@@ -23,9 +23,8 @@ soc0_phy1: ethernet-phy@1 { ...@@ -23,9 +23,8 @@ soc0_phy1: ethernet-phy@1 {
}; };
}; };
dsa: dsa@c7000000 { dsaf0: dsa@c7000000 {
compatible = "hisilicon,hns-dsaf-v1"; compatible = "hisilicon,hns-dsaf-v1";
dsa_name = "dsaf0";
mode = "6port-16rss"; mode = "6port-16rss";
interrupt-parent = <&mbigen_dsa>; interrupt-parent = <&mbigen_dsa>;
...@@ -127,7 +126,7 @@ dsa: dsa@c7000000 { ...@@ -127,7 +126,7 @@ dsa: dsa@c7000000 {
eth0: ethernet@0{ eth0: ethernet@0{
compatible = "hisilicon,hns-nic-v1"; compatible = "hisilicon,hns-nic-v1";
ae-name = "dsaf0"; ae-handle = <&dsaf0>;
port-id = <0>; port-id = <0>;
local-mac-address = [00 00 00 01 00 58]; local-mac-address = [00 00 00 01 00 58];
status = "disabled"; status = "disabled";
...@@ -135,14 +134,14 @@ eth0: ethernet@0{ ...@@ -135,14 +134,14 @@ eth0: ethernet@0{
}; };
eth1: ethernet@1{ eth1: ethernet@1{
compatible = "hisilicon,hns-nic-v1"; compatible = "hisilicon,hns-nic-v1";
ae-name = "dsaf0"; ae-handle = <&dsaf0>;
port-id = <1>; port-id = <1>;
status = "disabled"; status = "disabled";
dma-coherent; dma-coherent;
}; };
eth2: ethernet@2{ eth2: ethernet@2{
compatible = "hisilicon,hns-nic-v1"; compatible = "hisilicon,hns-nic-v1";
ae-name = "dsaf0"; ae-handle = <&dsaf0>;
port-id = <2>; port-id = <2>;
local-mac-address = [00 00 00 01 00 5a]; local-mac-address = [00 00 00 01 00 5a];
status = "disabled"; status = "disabled";
...@@ -150,7 +149,7 @@ eth2: ethernet@2{ ...@@ -150,7 +149,7 @@ eth2: ethernet@2{
}; };
eth3: ethernet@3{ eth3: ethernet@3{
compatible = "hisilicon,hns-nic-v1"; compatible = "hisilicon,hns-nic-v1";
ae-name = "dsaf0"; ae-handle = <&dsaf0>;
port-id = <3>; port-id = <3>;
local-mac-address = [00 00 00 01 00 5b]; local-mac-address = [00 00 00 01 00 5b];
status = "disabled"; status = "disabled";
...@@ -158,7 +157,7 @@ eth3: ethernet@3{ ...@@ -158,7 +157,7 @@ eth3: ethernet@3{
}; };
eth4: ethernet@4{ eth4: ethernet@4{
compatible = "hisilicon,hns-nic-v1"; compatible = "hisilicon,hns-nic-v1";
ae-name = "dsaf0"; ae-handle = <&dsaf0>;
port-id = <4>; port-id = <4>;
local-mac-address = [00 00 00 01 00 5c]; local-mac-address = [00 00 00 01 00 5c];
status = "disabled"; status = "disabled";
...@@ -166,7 +165,7 @@ eth4: ethernet@4{ ...@@ -166,7 +165,7 @@ eth4: ethernet@4{
}; };
eth5: ethernet@5{ eth5: ethernet@5{
compatible = "hisilicon,hns-nic-v1"; compatible = "hisilicon,hns-nic-v1";
ae-name = "dsaf0"; ae-handle = <&dsaf0>;
port-id = <5>; port-id = <5>;
local-mac-address = [00 00 00 01 00 5d]; local-mac-address = [00 00 00 01 00 5d];
status = "disabled"; status = "disabled";
...@@ -174,7 +173,7 @@ eth5: ethernet@5{ ...@@ -174,7 +173,7 @@ eth5: ethernet@5{
}; };
eth6: ethernet@6{ eth6: ethernet@6{
compatible = "hisilicon,hns-nic-v1"; compatible = "hisilicon,hns-nic-v1";
ae-name = "dsaf0"; ae-handle = <&dsaf0>;
port-id = <6>; port-id = <6>;
local-mac-address = [00 00 00 01 00 5e]; local-mac-address = [00 00 00 01 00 5e];
status = "disabled"; status = "disabled";
...@@ -182,7 +181,7 @@ eth6: ethernet@6{ ...@@ -182,7 +181,7 @@ eth6: ethernet@6{
}; };
eth7: ethernet@7{ eth7: ethernet@7{
compatible = "hisilicon,hns-nic-v1"; compatible = "hisilicon,hns-nic-v1";
ae-name = "dsaf0"; ae-handle = <&dsaf0>;
port-id = <7>; port-id = <7>;
local-mac-address = [00 00 00 01 00 5f]; local-mac-address = [00 00 00 01 00 5f];
status = "disabled"; status = "disabled";
......
...@@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = { ...@@ -95,21 +95,17 @@ static struct hnae_buf_ops hnae_bops = {
static int __ae_match(struct device *dev, const void *data) static int __ae_match(struct device *dev, const void *data)
{ {
struct hnae_ae_dev *hdev = cls_to_ae_dev(dev); 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 hdev->dev->of_node == data;
return 1;
return 0;
} }
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; 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; return dev ? cls_to_ae_dev(dev) : NULL;
} }
...@@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle); ...@@ -316,7 +312,8 @@ EXPORT_SYMBOL(hnae_reinit_handle);
* return handle ptr or ERR_PTR * return handle ptr or ERR_PTR
*/ */
struct hnae_handle *hnae_get_handle(struct device *owner_dev, 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_buf_ops *bops)
{ {
struct hnae_ae_dev *dev; struct hnae_ae_dev *dev;
...@@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev, ...@@ -324,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
int i, j; int i, j;
int ret; int ret;
dev = find_ae(ae_id); dev = find_ae(ae_node);
if (!dev) if (!dev)
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
......
...@@ -524,8 +524,11 @@ struct hnae_handle { ...@@ -524,8 +524,11 @@ struct hnae_handle {
#define ring_to_dev(ring) ((ring)->q->dev->dev) #define ring_to_dev(ring) ((ring)->q->dev->dev)
struct hnae_handle *hnae_get_handle(struct device *owner_dev, const char *ae_id, struct hnae_handle *hnae_get_handle(struct device *owner_dev,
u32 port_id, struct hnae_buf_ops *bops); const struct device_node *ae_node,
u32 port_id,
struct hnae_buf_ops *bops);
void hnae_put_handle(struct hnae_handle *handle); void hnae_put_handle(struct hnae_handle *handle);
int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner); int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
void hnae_ae_unregister(struct hnae_ae_dev *dev); void hnae_ae_unregister(struct hnae_ae_dev *dev);
......
...@@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = { ...@@ -847,6 +847,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev) int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
{ {
struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev; struct hnae_ae_dev *ae_dev = &dsaf_dev->ae_dev;
static atomic_t id = ATOMIC_INIT(-1);
switch (dsaf_dev->dsaf_ver) { switch (dsaf_dev->dsaf_ver) {
case AE_VERSION_1: case AE_VERSION_1:
...@@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev) ...@@ -858,6 +859,9 @@ int hns_dsaf_ae_init(struct dsaf_device *dsaf_dev)
default: default:
break; 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->ops = &hns_dsaf_ops;
ae_dev->dev = dsaf_dev->dev; ae_dev->dev = dsaf_dev->dev;
......
...@@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev) ...@@ -35,7 +35,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
int ret, i; int ret, i;
u32 desc_num; u32 desc_num;
u32 buf_size; u32 buf_size;
const char *name, *mode_str; const char *mode_str;
struct device_node *np = dsaf_dev->dev->of_node; struct device_node *np = dsaf_dev->dev->of_node;
if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1")) if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
...@@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev) ...@@ -43,14 +43,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
else else
dsaf_dev->dsaf_ver = AE_VERSION_2; 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); ret = of_property_read_string(np, "mode", &mode_str);
if (ret) { if (ret) {
dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret); dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
......
...@@ -18,6 +18,7 @@ struct hns_mac_cb; ...@@ -18,6 +18,7 @@ struct hns_mac_cb;
#define DSAF_DRV_NAME "hns_dsaf" #define DSAF_DRV_NAME "hns_dsaf"
#define DSAF_MOD_VERSION "v1.0" #define DSAF_MOD_VERSION "v1.0"
#define DSAF_DEVICE_NAME "dsaf"
#define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000 #define HNS_DSAF_DEBUG_NW_REG_OFFSET 0x100000
......
...@@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev) ...@@ -1802,7 +1802,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
int ret; int ret;
h = hnae_get_handle(&priv->netdev->dev, 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)) { if (IS_ERR_OR_NULL(h)) {
ret = PTR_ERR(h); ret = PTR_ERR(h);
dev_dbg(priv->dev, "has not handle, register notifier!\n"); dev_dbg(priv->dev, "has not handle, register notifier!\n");
...@@ -1880,13 +1880,16 @@ static int hns_nic_dev_probe(struct platform_device *pdev) ...@@ -1880,13 +1880,16 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
else else
priv->enet_ver = AE_VERSION_2; priv->enet_ver = AE_VERSION_2;
ret = of_property_read_string(node, "ae-name", &priv->ae_name); priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
if (ret) if (IS_ERR_OR_NULL(priv->ae_node)) {
goto out_read_string_fail; ret = PTR_ERR(priv->ae_node);
dev_err(dev, "not find ae-handle\n");
goto out_read_prop_fail;
}
ret = of_property_read_u32(node, "port-id", &priv->port_id); ret = of_property_read_u32(node, "port-id", &priv->port_id);
if (ret) if (ret)
goto out_read_string_fail; goto out_read_prop_fail;
hns_init_mac_addr(ndev); hns_init_mac_addr(ndev);
...@@ -1945,7 +1948,7 @@ static int hns_nic_dev_probe(struct platform_device *pdev) ...@@ -1945,7 +1948,7 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
out_notify_fail: out_notify_fail:
(void)cancel_work_sync(&priv->service_task); (void)cancel_work_sync(&priv->service_task);
out_read_string_fail: out_read_prop_fail:
free_netdev(ndev); free_netdev(ndev);
return ret; return ret;
} }
......
...@@ -51,7 +51,7 @@ struct hns_nic_ops { ...@@ -51,7 +51,7 @@ struct hns_nic_ops {
}; };
struct hns_nic_priv { struct hns_nic_priv {
const char *ae_name; const struct device_node *ae_node;
u32 enet_ver; u32 enet_ver;
u32 port_id; u32 port_id;
int phy_mode; int phy_mode;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment