[PATCH net-next v5 1/2] net: hns: support deferred probe when can not obtain irq

2017-04-27 Thread Yankejian
From: lipeng 

In the hip06 and hip07 SoCs, the interrupt lines from the
DSAF controllers are connected to mbigen hw module.
The mbigen module is probed with module_init, and, as such,
is not guaranteed to probe before the HNS driver. So we need
to support deferred probe.

Signed-off-by: lipeng 
Reviewed-by: Yisen Zhuang 
Reviewed-by: Matthias Brugger 
---
change log:
V4 -> V5:
1. Float on net-next;

V3 -> V4:
1. Delete redundant commit message;
2. add Reviewed-by: Matthias Brugger ;

V2 -> V3:
1. Check return value when  platform_get_irq in hns_rcb_get_cfg;
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c | 4 +++-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c | 8 +++-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h | 2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
index eba406b..93e71e2 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
@@ -510,7 +510,9 @@ int hns_ppe_init(struct dsaf_device *dsaf_dev)
 
hns_ppe_get_cfg(dsaf_dev->ppe_common[i]);
 
-   hns_rcb_get_cfg(dsaf_dev->rcb_common[i]);
+   ret = hns_rcb_get_cfg(dsaf_dev->rcb_common[i]);
+   if (ret)
+   goto get_cfg_fail;
}
 
for (i = 0; i < HNS_PPE_COM_NUM; i++)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
index c20a0f4..e2e2853 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
@@ -492,7 +492,7 @@ static int hns_rcb_get_base_irq_idx(struct rcb_common_cb 
*rcb_common)
  *hns_rcb_get_cfg - get rcb config
  *@rcb_common: rcb common device
  */
-void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
+int hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
 {
struct ring_pair_cb *ring_pair_cb;
u32 i;
@@ -517,10 +517,16 @@ void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
ring_pair_cb->virq[HNS_RCB_IRQ_IDX_RX] =
is_ver1 ? platform_get_irq(pdev, base_irq_idx + i * 2 + 1) :
  platform_get_irq(pdev, base_irq_idx + i * 3);
+   if ((ring_pair_cb->virq[HNS_RCB_IRQ_IDX_TX] == -EPROBE_DEFER) ||
+   (ring_pair_cb->virq[HNS_RCB_IRQ_IDX_RX] == -EPROBE_DEFER))
+   return -EPROBE_DEFER;
+
ring_pair_cb->q.phy_base =
RCB_COMM_BASE_TO_RING_BASE(rcb_common->phy_base, i);
hns_rcb_ring_pair_get_cfg(ring_pair_cb);
}
+
+   return 0;
 }
 
 /**
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
index a664ee8..6028164 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
@@ -121,7 +121,7 @@ struct rcb_common_cb {
 void hns_rcb_common_free_cfg(struct dsaf_device *dsaf_dev, u32 comm_index);
 int hns_rcb_common_init_hw(struct rcb_common_cb *rcb_common);
 void hns_rcb_start(struct hnae_queue *q, u32 val);
-void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common);
+int hns_rcb_get_cfg(struct rcb_common_cb *rcb_common);
 void hns_rcb_get_queue_mode(enum dsaf_mode dsaf_mode,
u16 *max_vfn, u16 *max_q_per_vf);
 
-- 
1.9.1



[PATCH net-next v5 0/2] net: hns: bug fix for HNS driver

2017-04-27 Thread Yankejian
From: lipeng 

This patchset add support defered dsaf probe when mdio and
mbigen module is not insmod.

For more details, please refer to individual patch.

change log:
V4 - > V5:
1. Float on net-next;
2. Delete patch "net: hns: fixed bug that skb used after kfree"
   from this patchset;

V3 -> V4:
1. Delete redundant commit message;
2. Add Reviewed-by: Matthias Brugger ;

V2 -> V3:
1. Check return value when  platform_get_irq in hns_rcb_get_cfg;

V1 -> V2:
1. Return appropriate errno in hns_mac_register_phy;

lipeng (2):
  net: hns: support deferred probe when can not obtain irq
  net: hns: support deferred probe when no mdio

 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 39 +++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c |  4 ++-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c |  8 -
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h |  2 +-
 4 files changed, 44 insertions(+), 9 deletions(-)

-- 
1.9.1



[PATCH net-next v5 2/2] net: hns: support deferred probe when no mdio

2017-04-27 Thread Yankejian
From: lipeng 

In the hip06 and hip07 SoCs, phy connect to mdio bus.The mdio
module is probed with module_init, and, as such,
is not guaranteed to probe before the HNS driver. So we need
to support deferred probe.

We check for probe deferral in the mac init, so we not init DSAF
when there is no mdio, and free all resource, to later learn that
we need to defer the probe.

Signed-off-by: lipeng 
Reviewed-by: Yisen Zhuang 
Reviewed-by: Matthias Brugger 
---
change log:
V4 -> V5:
1. Float on net-next;

V1 -> V2:
1. Return appropriate errno in hns_mac_register_phy;
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 39 +++
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 0c1f56e..8b5cdf4 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -696,6 +696,8 @@ static int hns_mac_init_ex(struct hns_mac_cb *mac_cb)
rc = phy_device_register(phy);
if (rc) {
phy_device_free(phy);
+   dev_err(&mdio->dev, "registered phy fail at address %i\n",
+   addr);
return -ENODEV;
}
 
@@ -706,7 +708,7 @@ static int hns_mac_init_ex(struct hns_mac_cb *mac_cb)
return 0;
 }
 
-static void hns_mac_register_phy(struct hns_mac_cb *mac_cb)
+static int hns_mac_register_phy(struct hns_mac_cb *mac_cb)
 {
struct acpi_reference_args args;
struct platform_device *pdev;
@@ -716,24 +718,39 @@ static void hns_mac_register_phy(struct hns_mac_cb 
*mac_cb)
 
/* Loop over the child nodes and register a phy_device for each one */
if (!to_acpi_device_node(mac_cb->fw_port))
-   return;
+   return -ENODEV;
 
rc = acpi_node_get_property_reference(
mac_cb->fw_port, "mdio-node", 0, &args);
if (rc)
-   return;
+   return rc;
 
addr = hns_mac_phy_parse_addr(mac_cb->dev, mac_cb->fw_port);
if (addr < 0)
-   return;
+   return addr;
 
/* dev address in adev */
pdev = hns_dsaf_find_platform_device(acpi_fwnode_handle(args.adev));
+   if (!pdev) {
+   dev_err(mac_cb->dev, "mac%d mdio pdev is NULL\n",
+   mac_cb->mac_id);
+   return  -EINVAL;
+   }
+
mii_bus = platform_get_drvdata(pdev);
+   if (!mii_bus) {
+   dev_err(mac_cb->dev,
+   "mac%d mdio is NULL, dsaf will probe again later\n",
+   mac_cb->mac_id);
+   return -EPROBE_DEFER;
+   }
+
rc = hns_mac_register_phydev(mii_bus, mac_cb, addr);
if (!rc)
dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n",
mac_cb->mac_id, addr);
+
+   return rc;
 }
 
 #define MAC_MEDIA_TYPE_MAX_LEN 16
@@ -754,7 +771,7 @@ static void hns_mac_register_phy(struct hns_mac_cb *mac_cb)
  *@np:device node
  * return: 0 --success, negative --fail
  */
-static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
+static int hns_mac_get_info(struct hns_mac_cb *mac_cb)
 {
struct device_node *np;
struct regmap *syscon;
@@ -864,7 +881,15 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
}
}
} else if (is_acpi_node(mac_cb->fw_port)) {
-   hns_mac_register_phy(mac_cb);
+   ret = hns_mac_register_phy(mac_cb);
+   /*
+* Mac can work well if there is phy or not.If the port don't
+* connect with phy, the return value will be ignored. Only
+* when there is phy but can't find mdio bus, the return value
+* will be handled.
+*/
+   if (ret == -EPROBE_DEFER)
+   return ret;
} else {
dev_err(mac_cb->dev, "mac%d cannot find phy node\n",
mac_cb->mac_id);
@@ -1026,6 +1051,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
dsaf_dev->mac_cb[port_id] = mac_cb;
}
}
+
/* init mac_cb for all port */
for (port_id = 0; port_id < max_port_num; port_id++) {
mac_cb = dsaf_dev->mac_cb[port_id];
@@ -1035,6 +1061,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
ret = hns_mac_get_cfg(dsaf_dev, mac_cb);
if (ret)
return ret;
+
ret = hns_mac_init_ex(mac_cb);
if (ret)
return ret;
-- 
1.9.1



[PATCH net v4 3/3] net: hns: fixed bug that skb used after kfree

2017-04-26 Thread Yankejian
From: lipeng 

There is KASAN warning which turn out it's a skb used after free:

BUG: KASAN: use-after-free in hns_nic_net_xmit_hw+0x62c/0x940...
[17659.112635]  alloc_debug_processing+0x18c/0x1a0
[17659.117208]  __slab_alloc+0x52c/0x560
[17659.120909]  kmem_cache_alloc_node+0xac/0x2c0
[17659.125309]  __alloc_skb+0x6c/0x260
[17659.128837]  tcp_send_ack+0x8c/0x280
[17659.132449]  __tcp_ack_snd_check+0x9c/0xf0
[17659.136587]  tcp_rcv_established+0x5a4/0xa70
[17659.140899]  tcp_v4_do_rcv+0x27c/0x620
[17659.144687]  tcp_prequeue_process+0x108/0x170
[17659.149085]  tcp_recvmsg+0x940/0x1020
[17659.152787]  inet_recvmsg+0x124/0x180
[17659.156488]  sock_recvmsg+0x64/0x80
[17659.160012]  SyS_recvfrom+0xd8/0x180
[17659.163626]  __sys_trace_return+0x0/0x4
[17659.167506] INFO: Freed in kfree_skbmem+0xa0/0xb0 age=23 cpu=1 pid=13
[17659.174000]  free_debug_processing+0x1d4/0x2c0
[17659.178486]  __slab_free+0x240/0x390
[17659.182100]  kmem_cache_free+0x24c/0x270
[17659.186062]  kfree_skbmem+0xa0/0xb0
[17659.189587]  __kfree_skb+0x28/0x40
[17659.193025]  napi_gro_receive+0x168/0x1c0
[17659.197074]  hns_nic_rx_up_pro+0x58/0x90
[17659.201038]  hns_nic_rx_poll_one+0x518/0xbc0
[17659.205352]  hns_nic_common_poll+0x94/0x140
[17659.209576]  net_rx_action+0x458/0x5e0
[17659.213363]  __do_softirq+0x1b8/0x480
[17659.217062]  run_ksoftirqd+0x64/0x80
[17659.220679]  smpboot_thread_fn+0x224/0x310
[17659.224821]  kthread+0x150/0x170
[17659.228084]  ret_from_fork+0x10/0x40

BUG: KASAN: use-after-free in hns_nic_net_xmit+0x8c/0xc0...
[17751.080490]  __slab_alloc+0x52c/0x560
[17751.084188]  kmem_cache_alloc+0x244/0x280
[17751.088238]  __build_skb+0x40/0x150
[17751.091764]  build_skb+0x28/0x100
[17751.095115]  __alloc_rx_skb+0x94/0x150
[17751.098900]  __napi_alloc_skb+0x34/0x90
[17751.102776]  hns_nic_rx_poll_one+0x180/0xbc0
[17751.107097]  hns_nic_common_poll+0x94/0x140
[17751.111333]  net_rx_action+0x458/0x5e0
[17751.115123]  __do_softirq+0x1b8/0x480
[17751.118823]  run_ksoftirqd+0x64/0x80
[17751.122437]  smpboot_thread_fn+0x224/0x310
[17751.126575]  kthread+0x150/0x170
[17751.129838]  ret_from_fork+0x10/0x40
[17751.133454] INFO: Freed in kfree_skbmem+0xa0/0xb0 age=19 cpu=7 pid=43
[17751.139951]  free_debug_processing+0x1d4/0x2c0
[17751.144436]  __slab_free+0x240/0x390
[17751.148051]  kmem_cache_free+0x24c/0x270
[17751.152014]  kfree_skbmem+0xa0/0xb0
[17751.155543]  __kfree_skb+0x28/0x40
[17751.159022]  napi_gro_receive+0x168/0x1c0
[17751.163074]  hns_nic_rx_up_pro+0x58/0x90
[17751.167041]  hns_nic_rx_poll_one+0x518/0xbc0
[17751.171358]  hns_nic_common_poll+0x94/0x140
[17751.175585]  net_rx_action+0x458/0x5e0
[17751.179373]  __do_softirq+0x1b8/0x480
[17751.183076]  run_ksoftirqd+0x64/0x80
[17751.186691]  smpboot_thread_fn+0x224/0x310
[17751.190826]  kthread+0x150/0x170
[17751.194093]  ret_from_fork+0x10/0x40

in drivers/net/ethernet/hisilicon/hns/hns_enet.c

static netdev_tx_t hns_nic_net_xmit(struct sk_buff *skb,
struct net_device *ndev)
{
struct hns_nic_priv *priv = netdev_priv(ndev);
int ret;

assert(skb->queue_mapping < ndev->ae_handle->q_num);
ret = hns_nic_net_xmit_hw(ndev, skb,
  &tx_ring_data(priv, skb->queue_mapping));
if (ret == NETDEV_TX_OK) {
netif_trans_update(ndev);
ndev->stats.tx_bytes += skb->len;
ndev->stats.tx_packets++;
}
 return (netdev_tx_t)ret;
}

skb maybe freed in hns_nic_net_xmit_hw() and return NETDEV_TX_OK:

out_err_tx_ok:

dev_kfree_skb_any(skb);
return NETDEV_TX_OK;

This patch fix this bug.

Reported-by: Jun He 
Signed-off-by: lipeng 
Reviewed-by: Yisen Zhuang 
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 22 ++
 drivers/net/ethernet/hisilicon/hns/hns_enet.h |  6 +++---
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c 
b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index fca37e2..1e04df6 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -300,9 +300,9 @@ static void fill_tso_desc(struct hnae_ring *ring, void 
*priv,
 mtu);
 }
 
-int hns_nic_net_xmit_hw(struct net_device *ndev,
-   struct sk_buff *skb,
-   struct hns_nic_ring_data *ring_data)
+netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
+  

[PATCH net v4 0/3] net: hns: bug fix for HNS driver

2017-04-26 Thread Yankejian
From: lipeng 

The first two patches [1/3] [2/3] of this serie add support defered
dsaf probe when mdio and mbigen module is not insmod. The third
patch [3/3] fixes a bug that skb still be used after freed, which will
cuase panic.

For more details, please refer to individual patch.

change log:
V3 -> V4:
1. Delete redundant commit message;
2. add Reviewed-by: Matthias Brugger ;

V2 -> V3:
1. Check return value when  platform_get_irq in hns_rcb_get_cfg;

V1 -> V2:
1. Return appropriate errno in hns_mac_register_phy;

lipeng (3):
  net: hns: support deferred probe when can not obtain irq
  net: hns: support deferred probe when no mdio
  net: hns: fixed bug that skb used after kfree

 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 39 +++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c |  4 ++-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c |  8 -
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h |  2 +-
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 22 ++---
 drivers/net/ethernet/hisilicon/hns/hns_enet.h |  6 ++--
 6 files changed, 57 insertions(+), 24 deletions(-)

-- 
1.9.1



[PATCH net v4 2/3] net: hns: support deferred probe when no mdio

2017-04-26 Thread Yankejian
From: lipeng 

In the hip06 and hip07 SoCs, phy connect to mdio bus.The mdio
module is probed with module_init, and, as such,
is not guaranteed to probe before the HNS driver. So we need
to support deferred probe.

We check for probe deferral in the mac init, so we not init DSAF
when there is no mdio, and free all resource, to later learn that
we need to defer the probe.

Signed-off-by: lipeng 
Reviewed-by: Yisen Zhuang 
Reviewed-by: Matthias Brugger 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 39 +++
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index bdd8cdd..8c00e09 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -735,6 +735,8 @@ static int hns_mac_init_ex(struct hns_mac_cb *mac_cb)
rc = phy_device_register(phy);
if (rc) {
phy_device_free(phy);
+   dev_err(&mdio->dev, "registered phy fail at address %i\n",
+   addr);
return -ENODEV;
}
 
@@ -745,7 +747,7 @@ static int hns_mac_init_ex(struct hns_mac_cb *mac_cb)
return 0;
 }
 
-static void hns_mac_register_phy(struct hns_mac_cb *mac_cb)
+static int hns_mac_register_phy(struct hns_mac_cb *mac_cb)
 {
struct acpi_reference_args args;
struct platform_device *pdev;
@@ -755,24 +757,39 @@ static void hns_mac_register_phy(struct hns_mac_cb 
*mac_cb)
 
/* Loop over the child nodes and register a phy_device for each one */
if (!to_acpi_device_node(mac_cb->fw_port))
-   return;
+   return -ENODEV;
 
rc = acpi_node_get_property_reference(
mac_cb->fw_port, "mdio-node", 0, &args);
if (rc)
-   return;
+   return rc;
 
addr = hns_mac_phy_parse_addr(mac_cb->dev, mac_cb->fw_port);
if (addr < 0)
-   return;
+   return addr;
 
/* dev address in adev */
pdev = hns_dsaf_find_platform_device(acpi_fwnode_handle(args.adev));
+   if (!pdev) {
+   dev_err(mac_cb->dev, "mac%d mdio pdev is NULL\n",
+   mac_cb->mac_id);
+   return  -EINVAL;
+   }
+
mii_bus = platform_get_drvdata(pdev);
+   if (!mii_bus) {
+   dev_err(mac_cb->dev,
+   "mac%d mdio is NULL, dsaf will probe again later\n",
+   mac_cb->mac_id);
+   return -EPROBE_DEFER;
+   }
+
rc = hns_mac_register_phydev(mii_bus, mac_cb, addr);
if (!rc)
dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n",
mac_cb->mac_id, addr);
+
+   return rc;
 }
 
 #define MAC_MEDIA_TYPE_MAX_LEN 16
@@ -793,7 +810,7 @@ static void hns_mac_register_phy(struct hns_mac_cb *mac_cb)
  *@np:device node
  * return: 0 --success, negative --fail
  */
-static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
+static int hns_mac_get_info(struct hns_mac_cb *mac_cb)
 {
struct device_node *np;
struct regmap *syscon;
@@ -903,7 +920,15 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
}
}
} else if (is_acpi_node(mac_cb->fw_port)) {
-   hns_mac_register_phy(mac_cb);
+   ret = hns_mac_register_phy(mac_cb);
+   /*
+* Mac can work well if there is phy or not.If the port don't
+* connect with phy, the return value will be ignored. Only
+* when there is phy but can't find mdio bus, the return value
+* will be handled.
+*/
+   if (ret == -EPROBE_DEFER)
+   return ret;
} else {
dev_err(mac_cb->dev, "mac%d cannot find phy node\n",
mac_cb->mac_id);
@@ -1065,6 +1090,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
dsaf_dev->mac_cb[port_id] = mac_cb;
}
}
+
/* init mac_cb for all port */
for (port_id = 0; port_id < max_port_num; port_id++) {
mac_cb = dsaf_dev->mac_cb[port_id];
@@ -1074,6 +1100,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
ret = hns_mac_get_cfg(dsaf_dev, mac_cb);
if (ret)
return ret;
+
ret = hns_mac_init_ex(mac_cb);
if (ret)
return ret;
-- 
1.9.1



[PATCH net v4 1/3] net: hns: support deferred probe when can not obtain irq

2017-04-26 Thread Yankejian
From: lipeng 

In the hip06 and hip07 SoCs, the interrupt lines from the
DSAF controllers are connected to mbigen hw module.
The mbigen module is probed with module_init, and, as such,
is not guaranteed to probe before the HNS driver. So we need
to support deferred probe.

Signed-off-by: lipeng 
Reviewed-by: Yisen Zhuang 
Reviewed-by: Matthias Brugger 
---
change log:
V3 -> V4:
1. Delete redundant commit message;
2. add Reviewed-by: Matthias Brugger ;

V2 -> V3:
1. Check return value when  platform_get_irq in hns_rcb_get_cfg;
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c | 4 +++-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c | 8 +++-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h | 2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
index 6ea8722..a41cf95 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
@@ -510,7 +510,9 @@ int hns_ppe_init(struct dsaf_device *dsaf_dev)
 
hns_ppe_get_cfg(dsaf_dev->ppe_common[i]);
 
-   hns_rcb_get_cfg(dsaf_dev->rcb_common[i]);
+   ret = hns_rcb_get_cfg(dsaf_dev->rcb_common[i]);
+   if (ret)
+   goto get_rcb_cfg_fail;
}
 
for (i = 0; i < HNS_PPE_COM_NUM; i++)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
index f0ed80d6..673a5d3 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
@@ -452,7 +452,7 @@ static int hns_rcb_get_base_irq_idx(struct rcb_common_cb 
*rcb_common)
  *hns_rcb_get_cfg - get rcb config
  *@rcb_common: rcb common device
  */
-void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
+int hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
 {
struct ring_pair_cb *ring_pair_cb;
u32 i;
@@ -477,10 +477,16 @@ void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
ring_pair_cb->virq[HNS_RCB_IRQ_IDX_RX] =
is_ver1 ? platform_get_irq(pdev, base_irq_idx + i * 2 + 1) :
  platform_get_irq(pdev, base_irq_idx + i * 3);
+   if ((ring_pair_cb->virq[HNS_RCB_IRQ_IDX_TX] == -EPROBE_DEFER) ||
+   (ring_pair_cb->virq[HNS_RCB_IRQ_IDX_RX] == -EPROBE_DEFER))
+   return -EPROBE_DEFER;
+
ring_pair_cb->q.phy_base =
RCB_COMM_BASE_TO_RING_BASE(rcb_common->phy_base, i);
hns_rcb_ring_pair_get_cfg(ring_pair_cb);
}
+
+   return 0;
 }
 
 /**
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
index 99b4e1b..3d7b484 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
@@ -110,7 +110,7 @@ struct rcb_common_cb {
 void hns_rcb_common_free_cfg(struct dsaf_device *dsaf_dev, u32 comm_index);
 int hns_rcb_common_init_hw(struct rcb_common_cb *rcb_common);
 void hns_rcb_start(struct hnae_queue *q, u32 val);
-void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common);
+int hns_rcb_get_cfg(struct rcb_common_cb *rcb_common);
 void hns_rcb_get_queue_mode(enum dsaf_mode dsaf_mode,
u16 *max_vfn, u16 *max_q_per_vf);
 
-- 
1.9.1



[PATCH net v3 3/3] net: hns: fixed bug that skb used after kfree

2017-04-25 Thread Yankejian
From: lipeng 

There is KASAN warning which turn out it's a skb used after free:

BUG: KASAN: use-after-free in hns_nic_net_xmit_hw+0x62c/0x940...
[17659.112635]  alloc_debug_processing+0x18c/0x1a0
[17659.117208]  __slab_alloc+0x52c/0x560
[17659.120909]  kmem_cache_alloc_node+0xac/0x2c0
[17659.125309]  __alloc_skb+0x6c/0x260
[17659.128837]  tcp_send_ack+0x8c/0x280
[17659.132449]  __tcp_ack_snd_check+0x9c/0xf0
[17659.136587]  tcp_rcv_established+0x5a4/0xa70
[17659.140899]  tcp_v4_do_rcv+0x27c/0x620
[17659.144687]  tcp_prequeue_process+0x108/0x170
[17659.149085]  tcp_recvmsg+0x940/0x1020
[17659.152787]  inet_recvmsg+0x124/0x180
[17659.156488]  sock_recvmsg+0x64/0x80
[17659.160012]  SyS_recvfrom+0xd8/0x180
[17659.163626]  __sys_trace_return+0x0/0x4
[17659.167506] INFO: Freed in kfree_skbmem+0xa0/0xb0 age=23 cpu=1 pid=13
[17659.174000]  free_debug_processing+0x1d4/0x2c0
[17659.178486]  __slab_free+0x240/0x390
[17659.182100]  kmem_cache_free+0x24c/0x270
[17659.186062]  kfree_skbmem+0xa0/0xb0
[17659.189587]  __kfree_skb+0x28/0x40
[17659.193025]  napi_gro_receive+0x168/0x1c0
[17659.197074]  hns_nic_rx_up_pro+0x58/0x90
[17659.201038]  hns_nic_rx_poll_one+0x518/0xbc0
[17659.205352]  hns_nic_common_poll+0x94/0x140
[17659.209576]  net_rx_action+0x458/0x5e0
[17659.213363]  __do_softirq+0x1b8/0x480
[17659.217062]  run_ksoftirqd+0x64/0x80
[17659.220679]  smpboot_thread_fn+0x224/0x310
[17659.224821]  kthread+0x150/0x170
[17659.228084]  ret_from_fork+0x10/0x40

BUG: KASAN: use-after-free in hns_nic_net_xmit+0x8c/0xc0...
[17751.080490]  __slab_alloc+0x52c/0x560
[17751.084188]  kmem_cache_alloc+0x244/0x280
[17751.088238]  __build_skb+0x40/0x150
[17751.091764]  build_skb+0x28/0x100
[17751.095115]  __alloc_rx_skb+0x94/0x150
[17751.098900]  __napi_alloc_skb+0x34/0x90
[17751.102776]  hns_nic_rx_poll_one+0x180/0xbc0
[17751.107097]  hns_nic_common_poll+0x94/0x140
[17751.111333]  net_rx_action+0x458/0x5e0
[17751.115123]  __do_softirq+0x1b8/0x480
[17751.118823]  run_ksoftirqd+0x64/0x80
[17751.122437]  smpboot_thread_fn+0x224/0x310
[17751.126575]  kthread+0x150/0x170
[17751.129838]  ret_from_fork+0x10/0x40
[17751.133454] INFO: Freed in kfree_skbmem+0xa0/0xb0 age=19 cpu=7 pid=43
[17751.139951]  free_debug_processing+0x1d4/0x2c0
[17751.144436]  __slab_free+0x240/0x390
[17751.148051]  kmem_cache_free+0x24c/0x270
[17751.152014]  kfree_skbmem+0xa0/0xb0
[17751.155543]  __kfree_skb+0x28/0x40
[17751.159022]  napi_gro_receive+0x168/0x1c0
[17751.163074]  hns_nic_rx_up_pro+0x58/0x90
[17751.167041]  hns_nic_rx_poll_one+0x518/0xbc0
[17751.171358]  hns_nic_common_poll+0x94/0x140
[17751.175585]  net_rx_action+0x458/0x5e0
[17751.179373]  __do_softirq+0x1b8/0x480
[17751.183076]  run_ksoftirqd+0x64/0x80
[17751.186691]  smpboot_thread_fn+0x224/0x310
[17751.190826]  kthread+0x150/0x170
[17751.194093]  ret_from_fork+0x10/0x40

in drivers/net/ethernet/hisilicon/hns/hns_enet.c

static netdev_tx_t hns_nic_net_xmit(struct sk_buff *skb,
struct net_device *ndev)
{
struct hns_nic_priv *priv = netdev_priv(ndev);
int ret;

assert(skb->queue_mapping < ndev->ae_handle->q_num);
ret = hns_nic_net_xmit_hw(ndev, skb,
  &tx_ring_data(priv, skb->queue_mapping));
if (ret == NETDEV_TX_OK) {
netif_trans_update(ndev);
ndev->stats.tx_bytes += skb->len;
ndev->stats.tx_packets++;
}
 return (netdev_tx_t)ret;
}

skb maybe freed in hns_nic_net_xmit_hw() and return NETDEV_TX_OK:

out_err_tx_ok:

dev_kfree_skb_any(skb);
return NETDEV_TX_OK;

This patch fix this bug.

Reported-by: Jun He 
Signed-off-by: lipeng 
Reviewed-by: Yisen Zhuang 
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 22 ++
 drivers/net/ethernet/hisilicon/hns/hns_enet.h |  6 +++---
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c 
b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index fca37e2..1e04df6 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -300,9 +300,9 @@ static void fill_tso_desc(struct hnae_ring *ring, void 
*priv,
 mtu);
 }
 
-int hns_nic_net_xmit_hw(struct net_device *ndev,
-   struct sk_buff *skb,
-   struct hns_nic_ring_data *ring_data)
+netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
+  

[PATCH net v3 0/3] net: hns: bug fix for HNS driver

2017-04-25 Thread Yankejian
From: lipeng 

The first two patches [1/3] [2/3] of this serie add support defered
dsaf probe when mdio and mbigen module is not insmod. The third
patch [3/3] fixes a bug that skb still be used after freed, which will
cuase panic.

For more details, please refer to individual patch.

change log:
V2 -> V3:
1. Check return value when  platform_get_irq in hns_rcb_get_cfg;

V1 -> V2:
1. Return appropriate errno in hns_mac_register_phy;

lipeng (3):
  net: hns: support deferred probe when can not obtain irq
  net: hns: support deferred probe when no mdio
  net: hns: fixed bug that skb used after kfree

 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 39 +++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c |  4 ++-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c |  8 -
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h |  2 +-
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 22 ++---
 drivers/net/ethernet/hisilicon/hns/hns_enet.h |  6 ++--
 6 files changed, 57 insertions(+), 24 deletions(-)

-- 
1.9.1



[PATCH net v3 2/3] net: hns: support deferred probe when no mdio

2017-04-25 Thread Yankejian
From: lipeng 

In the hip06 and hip07 SoCs, phy connect to mdio bus.The mdio
module is probed with module_init, and, as such,
is not guaranteed to probe before the HNS driver. So we need
to support deferred probe.

We check for probe deferral in the mac init, so we not init DSAF
when there is no mdio, and free all resource, to later learn that
we need to defer the probe.

Signed-off-by: lipeng 
Reviewed-by: Yisen Zhuang 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 39 +++
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index bdd8cdd..8c00e09 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -735,6 +735,8 @@ static int hns_mac_init_ex(struct hns_mac_cb *mac_cb)
rc = phy_device_register(phy);
if (rc) {
phy_device_free(phy);
+   dev_err(&mdio->dev, "registered phy fail at address %i\n",
+   addr);
return -ENODEV;
}
 
@@ -745,7 +747,7 @@ static int hns_mac_init_ex(struct hns_mac_cb *mac_cb)
return 0;
 }
 
-static void hns_mac_register_phy(struct hns_mac_cb *mac_cb)
+static int hns_mac_register_phy(struct hns_mac_cb *mac_cb)
 {
struct acpi_reference_args args;
struct platform_device *pdev;
@@ -755,24 +757,39 @@ static void hns_mac_register_phy(struct hns_mac_cb 
*mac_cb)
 
/* Loop over the child nodes and register a phy_device for each one */
if (!to_acpi_device_node(mac_cb->fw_port))
-   return;
+   return -ENODEV;
 
rc = acpi_node_get_property_reference(
mac_cb->fw_port, "mdio-node", 0, &args);
if (rc)
-   return;
+   return rc;
 
addr = hns_mac_phy_parse_addr(mac_cb->dev, mac_cb->fw_port);
if (addr < 0)
-   return;
+   return addr;
 
/* dev address in adev */
pdev = hns_dsaf_find_platform_device(acpi_fwnode_handle(args.adev));
+   if (!pdev) {
+   dev_err(mac_cb->dev, "mac%d mdio pdev is NULL\n",
+   mac_cb->mac_id);
+   return  -EINVAL;
+   }
+
mii_bus = platform_get_drvdata(pdev);
+   if (!mii_bus) {
+   dev_err(mac_cb->dev,
+   "mac%d mdio is NULL, dsaf will probe again later\n",
+   mac_cb->mac_id);
+   return -EPROBE_DEFER;
+   }
+
rc = hns_mac_register_phydev(mii_bus, mac_cb, addr);
if (!rc)
dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n",
mac_cb->mac_id, addr);
+
+   return rc;
 }
 
 #define MAC_MEDIA_TYPE_MAX_LEN 16
@@ -793,7 +810,7 @@ static void hns_mac_register_phy(struct hns_mac_cb *mac_cb)
  *@np:device node
  * return: 0 --success, negative --fail
  */
-static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
+static int hns_mac_get_info(struct hns_mac_cb *mac_cb)
 {
struct device_node *np;
struct regmap *syscon;
@@ -903,7 +920,15 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
}
}
} else if (is_acpi_node(mac_cb->fw_port)) {
-   hns_mac_register_phy(mac_cb);
+   ret = hns_mac_register_phy(mac_cb);
+   /*
+* Mac can work well if there is phy or not.If the port don't
+* connect with phy, the return value will be ignored. Only
+* when there is phy but can't find mdio bus, the return value
+* will be handled.
+*/
+   if (ret == -EPROBE_DEFER)
+   return ret;
} else {
dev_err(mac_cb->dev, "mac%d cannot find phy node\n",
mac_cb->mac_id);
@@ -1065,6 +1090,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
dsaf_dev->mac_cb[port_id] = mac_cb;
}
}
+
/* init mac_cb for all port */
for (port_id = 0; port_id < max_port_num; port_id++) {
mac_cb = dsaf_dev->mac_cb[port_id];
@@ -1074,6 +1100,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
ret = hns_mac_get_cfg(dsaf_dev, mac_cb);
if (ret)
return ret;
+
ret = hns_mac_init_ex(mac_cb);
if (ret)
return ret;
-- 
1.9.1



[PATCH net v3 1/3] net: hns: support deferred probe when can not obtain irq

2017-04-25 Thread Yankejian
From: lipeng 

In the hip06 and hip07 SoCs, the interrupt lines from the
DSAF controllers are connected to mbigen hw module.
The mbigen module is probed with module_init, and, as such,
is not guaranteed to probe before the HNS driver. So we need
to support deferred probe.

We check for probe deferral in the hw layer probe, so we not
probe into the main layer and memories, etc., to later learn
that we need to defer the probe.

Signed-off-by: lipeng 
Reviewed-by: Yisen Zhuang 
---
V2 -> V3:
1. Check return value when  platform_get_irq in hns_rcb_get_cfg;
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c | 4 +++-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c | 8 +++-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h | 2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
index 6ea8722..a41cf95 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
@@ -510,7 +510,9 @@ int hns_ppe_init(struct dsaf_device *dsaf_dev)
 
hns_ppe_get_cfg(dsaf_dev->ppe_common[i]);
 
-   hns_rcb_get_cfg(dsaf_dev->rcb_common[i]);
+   ret = hns_rcb_get_cfg(dsaf_dev->rcb_common[i]);
+   if (ret)
+   goto get_rcb_cfg_fail;
}
 
for (i = 0; i < HNS_PPE_COM_NUM; i++)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
index f0ed80d6..673a5d3 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
@@ -452,7 +452,7 @@ static int hns_rcb_get_base_irq_idx(struct rcb_common_cb 
*rcb_common)
  *hns_rcb_get_cfg - get rcb config
  *@rcb_common: rcb common device
  */
-void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
+int hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
 {
struct ring_pair_cb *ring_pair_cb;
u32 i;
@@ -477,10 +477,16 @@ void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
ring_pair_cb->virq[HNS_RCB_IRQ_IDX_RX] =
is_ver1 ? platform_get_irq(pdev, base_irq_idx + i * 2 + 1) :
  platform_get_irq(pdev, base_irq_idx + i * 3);
+   if ((ring_pair_cb->virq[HNS_RCB_IRQ_IDX_TX] == -EPROBE_DEFER) ||
+   (ring_pair_cb->virq[HNS_RCB_IRQ_IDX_RX] == -EPROBE_DEFER))
+   return -EPROBE_DEFER;
+
ring_pair_cb->q.phy_base =
RCB_COMM_BASE_TO_RING_BASE(rcb_common->phy_base, i);
hns_rcb_ring_pair_get_cfg(ring_pair_cb);
}
+
+   return 0;
 }
 
 /**
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
index 99b4e1b..3d7b484 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
@@ -110,7 +110,7 @@ struct rcb_common_cb {
 void hns_rcb_common_free_cfg(struct dsaf_device *dsaf_dev, u32 comm_index);
 int hns_rcb_common_init_hw(struct rcb_common_cb *rcb_common);
 void hns_rcb_start(struct hnae_queue *q, u32 val);
-void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common);
+int hns_rcb_get_cfg(struct rcb_common_cb *rcb_common);
 void hns_rcb_get_queue_mode(enum dsaf_mode dsaf_mode,
u16 *max_vfn, u16 *max_q_per_vf);
 
-- 
1.9.1



[PATCH net v2 2/3] net: hns: support deferred probe when no mdio

2017-04-21 Thread Yankejian
From: lipeng 

In the hip06 and hip07 SoCs, phy connect to mdio bus.The mdio
module is probed with module_init, and, as such,
is not guaranteed to probe before the HNS driver. So we need
to support deferred probe.

We check for probe deferral in the mac init, so we not init DSAF
when there is no mdio, and free all resource, to later learn that
we need to defer the probe.

Signed-off-by: lipeng 
Reviewed-by: Yisen Zhuang 

---
change log:
V1 -> V2:
1. Return appropriate errno in hns_mac_register_phy;
---
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 39 +++
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index bdd8cdd..8c00e09 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -735,6 +735,8 @@ static int hns_mac_init_ex(struct hns_mac_cb *mac_cb)
rc = phy_device_register(phy);
if (rc) {
phy_device_free(phy);
+   dev_err(&mdio->dev, "registered phy fail at address %i\n",
+   addr);
return -ENODEV;
}
 
@@ -745,7 +747,7 @@ static int hns_mac_init_ex(struct hns_mac_cb *mac_cb)
return 0;
 }
 
-static void hns_mac_register_phy(struct hns_mac_cb *mac_cb)
+static int hns_mac_register_phy(struct hns_mac_cb *mac_cb)
 {
struct acpi_reference_args args;
struct platform_device *pdev;
@@ -755,24 +757,39 @@ static void hns_mac_register_phy(struct hns_mac_cb 
*mac_cb)
 
/* Loop over the child nodes and register a phy_device for each one */
if (!to_acpi_device_node(mac_cb->fw_port))
-   return;
+   return -ENODEV;
 
rc = acpi_node_get_property_reference(
mac_cb->fw_port, "mdio-node", 0, &args);
if (rc)
-   return;
+   return rc;
 
addr = hns_mac_phy_parse_addr(mac_cb->dev, mac_cb->fw_port);
if (addr < 0)
-   return;
+   return addr;
 
/* dev address in adev */
pdev = hns_dsaf_find_platform_device(acpi_fwnode_handle(args.adev));
+   if (!pdev) {
+   dev_err(mac_cb->dev, "mac%d mdio pdev is NULL\n",
+   mac_cb->mac_id);
+   return  -EINVAL;
+   }
+
mii_bus = platform_get_drvdata(pdev);
+   if (!mii_bus) {
+   dev_err(mac_cb->dev,
+   "mac%d mdio is NULL, dsaf will probe again later\n",
+   mac_cb->mac_id);
+   return -EPROBE_DEFER;
+   }
+
rc = hns_mac_register_phydev(mii_bus, mac_cb, addr);
if (!rc)
dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n",
mac_cb->mac_id, addr);
+
+   return rc;
 }
 
 #define MAC_MEDIA_TYPE_MAX_LEN 16
@@ -793,7 +810,7 @@ static void hns_mac_register_phy(struct hns_mac_cb *mac_cb)
  *@np:device node
  * return: 0 --success, negative --fail
  */
-static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
+static int hns_mac_get_info(struct hns_mac_cb *mac_cb)
 {
struct device_node *np;
struct regmap *syscon;
@@ -903,7 +920,15 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
}
}
} else if (is_acpi_node(mac_cb->fw_port)) {
-   hns_mac_register_phy(mac_cb);
+   ret = hns_mac_register_phy(mac_cb);
+   /*
+* Mac can work well if there is phy or not.If the port don't
+* connect with phy, the return value will be ignored. Only
+* when there is phy but can't find mdio bus, the return value
+* will be handled.
+*/
+   if (ret == -EPROBE_DEFER)
+   return ret;
} else {
dev_err(mac_cb->dev, "mac%d cannot find phy node\n",
mac_cb->mac_id);
@@ -1065,6 +1090,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
dsaf_dev->mac_cb[port_id] = mac_cb;
}
}
+
/* init mac_cb for all port */
for (port_id = 0; port_id < max_port_num; port_id++) {
mac_cb = dsaf_dev->mac_cb[port_id];
@@ -1074,6 +1100,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
ret = hns_mac_get_cfg(dsaf_dev, mac_cb);
if (ret)
return ret;
+
ret = hns_mac_init_ex(mac_cb);
if (ret)
return ret;
-- 
1.9.1



[PATCH net v2 1/3] net: hns: support deferred probe when can not obtain irq

2017-04-21 Thread Yankejian
From: lipeng 

In the hip06 and hip07 SoCs, the interrupt lines from the
DSAF controllers are connected to mbigen hw module.
The mbigen module is probed with module_init, and, as such,
is not guaranteed to probe before the HNS driver. So we need
to support deferred probe.

We check for probe deferral in the hw layer probe, so we not
probe into the main layer and memories, etc., to later learn
that we need to defer the probe.

Signed-off-by: lipeng 
Reviewed-by: Yisen Zhuang 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 403ea9d..2da5b42 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -2971,6 +2971,18 @@ static int hns_dsaf_probe(struct platform_device *pdev)
struct dsaf_device *dsaf_dev;
int ret;
 
+   /*
+* Check if we should defer the probe before we probe the
+* dsaf, as it's hard to defer later on.
+*/
+   ret = platform_get_irq(pdev, 0);
+   if (ret < 0) {
+   if (ret != -EPROBE_DEFER)
+   dev_err(&pdev->dev, "Cannot obtain irq\n");
+
+   return ret;
+   }
+
dsaf_dev = hns_dsaf_alloc_dev(&pdev->dev, sizeof(struct dsaf_drv_priv));
if (IS_ERR(dsaf_dev)) {
ret = PTR_ERR(dsaf_dev);
-- 
1.9.1



[PATCH net v2 0/3] net: hns: bug fix for HNS driver

2017-04-21 Thread Yankejian
From: lipeng 

This series adds support defered probe when mdio or mbigen module
insmod behind HNS driver, and fixes a bug that a skb has been
freed, but it may be still used in driver.

change log:
V1 -> V2:
1. Return appropriate errno in hns_mac_register_phy;

lipeng (3):
  net: hns: support deferred probe when can not obtain irq
  net: hns: support deferred probe when no mdio
  net: hns: fixed bug that skb used after kfree

 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  | 39 ++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 12 +++
 drivers/net/ethernet/hisilicon/hns/hns_enet.c  | 22 ++--
 drivers/net/ethernet/hisilicon/hns/hns_enet.h  |  6 ++--
 4 files changed, 58 insertions(+), 21 deletions(-)

-- 
1.9.1



[PATCH net v3 3/3] net: hns: fixed bug that skb used after kfree

2017-04-21 Thread Yankejian
From: lipeng 

There is KASAN warning which turn out it's a skb used after free:

BUG: KASAN: use-after-free in hns_nic_net_xmit_hw+0x62c/0x940...
[17659.112635]  alloc_debug_processing+0x18c/0x1a0
[17659.117208]  __slab_alloc+0x52c/0x560
[17659.120909]  kmem_cache_alloc_node+0xac/0x2c0
[17659.125309]  __alloc_skb+0x6c/0x260
[17659.128837]  tcp_send_ack+0x8c/0x280
[17659.132449]  __tcp_ack_snd_check+0x9c/0xf0
[17659.136587]  tcp_rcv_established+0x5a4/0xa70
[17659.140899]  tcp_v4_do_rcv+0x27c/0x620
[17659.144687]  tcp_prequeue_process+0x108/0x170
[17659.149085]  tcp_recvmsg+0x940/0x1020
[17659.152787]  inet_recvmsg+0x124/0x180
[17659.156488]  sock_recvmsg+0x64/0x80
[17659.160012]  SyS_recvfrom+0xd8/0x180
[17659.163626]  __sys_trace_return+0x0/0x4
[17659.167506] INFO: Freed in kfree_skbmem+0xa0/0xb0 age=23 cpu=1 pid=13
[17659.174000]  free_debug_processing+0x1d4/0x2c0
[17659.178486]  __slab_free+0x240/0x390
[17659.182100]  kmem_cache_free+0x24c/0x270
[17659.186062]  kfree_skbmem+0xa0/0xb0
[17659.189587]  __kfree_skb+0x28/0x40
[17659.193025]  napi_gro_receive+0x168/0x1c0
[17659.197074]  hns_nic_rx_up_pro+0x58/0x90
[17659.201038]  hns_nic_rx_poll_one+0x518/0xbc0
[17659.205352]  hns_nic_common_poll+0x94/0x140
[17659.209576]  net_rx_action+0x458/0x5e0
[17659.213363]  __do_softirq+0x1b8/0x480
[17659.217062]  run_ksoftirqd+0x64/0x80
[17659.220679]  smpboot_thread_fn+0x224/0x310
[17659.224821]  kthread+0x150/0x170
[17659.228084]  ret_from_fork+0x10/0x40

BUG: KASAN: use-after-free in hns_nic_net_xmit+0x8c/0xc0...
[17751.080490]  __slab_alloc+0x52c/0x560
[17751.084188]  kmem_cache_alloc+0x244/0x280
[17751.088238]  __build_skb+0x40/0x150
[17751.091764]  build_skb+0x28/0x100
[17751.095115]  __alloc_rx_skb+0x94/0x150
[17751.098900]  __napi_alloc_skb+0x34/0x90
[17751.102776]  hns_nic_rx_poll_one+0x180/0xbc0
[17751.107097]  hns_nic_common_poll+0x94/0x140
[17751.111333]  net_rx_action+0x458/0x5e0
[17751.115123]  __do_softirq+0x1b8/0x480
[17751.118823]  run_ksoftirqd+0x64/0x80
[17751.122437]  smpboot_thread_fn+0x224/0x310
[17751.126575]  kthread+0x150/0x170
[17751.129838]  ret_from_fork+0x10/0x40
[17751.133454] INFO: Freed in kfree_skbmem+0xa0/0xb0 age=19 cpu=7 pid=43
[17751.139951]  free_debug_processing+0x1d4/0x2c0
[17751.144436]  __slab_free+0x240/0x390
[17751.148051]  kmem_cache_free+0x24c/0x270
[17751.152014]  kfree_skbmem+0xa0/0xb0
[17751.155543]  __kfree_skb+0x28/0x40
[17751.159022]  napi_gro_receive+0x168/0x1c0
[17751.163074]  hns_nic_rx_up_pro+0x58/0x90
[17751.167041]  hns_nic_rx_poll_one+0x518/0xbc0
[17751.171358]  hns_nic_common_poll+0x94/0x140
[17751.175585]  net_rx_action+0x458/0x5e0
[17751.179373]  __do_softirq+0x1b8/0x480
[17751.183076]  run_ksoftirqd+0x64/0x80
[17751.186691]  smpboot_thread_fn+0x224/0x310
[17751.190826]  kthread+0x150/0x170
[17751.194093]  ret_from_fork+0x10/0x40

in drivers/net/ethernet/hisilicon/hns/hns_enet.c

static netdev_tx_t hns_nic_net_xmit(struct sk_buff *skb,
struct net_device *ndev)
{
struct hns_nic_priv *priv = netdev_priv(ndev);
int ret;

assert(skb->queue_mapping < ndev->ae_handle->q_num);
ret = hns_nic_net_xmit_hw(ndev, skb,
  &tx_ring_data(priv, skb->queue_mapping));
if (ret == NETDEV_TX_OK) {
netif_trans_update(ndev);
ndev->stats.tx_bytes += skb->len;
ndev->stats.tx_packets++;
}
 return (netdev_tx_t)ret;
}

skb maybe freed in hns_nic_net_xmit_hw() and return NETDEV_TX_OK:

out_err_tx_ok:

dev_kfree_skb_any(skb);
return NETDEV_TX_OK;

This patch fix this bug.

Reported-by: Jun He 
Signed-off-by: lipeng 
Reviewed-by: Yisen Zhuang 
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 22 ++
 drivers/net/ethernet/hisilicon/hns/hns_enet.h |  6 +++---
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c 
b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index fca37e2..1e04df6 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -300,9 +300,9 @@ static void fill_tso_desc(struct hnae_ring *ring, void 
*priv,
 mtu);
 }
 
-int hns_nic_net_xmit_hw(struct net_device *ndev,
-   struct sk_buff *skb,
-   struct hns_nic_ring_data *ring_data)
+netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
+  

[PATCH net-next 1/3] net: hns: support deferred probe when can not obtain irq

2017-04-18 Thread Yankejian
From: lipeng 

In the hip06 and hip07 SoCs, the interrupt lines from the
DSAF controllers are connected to mbigen hw module.
The mbigen module is probed with module_init, and, as such,
is not guaranteed to probe before the HNS driver. So we need
to support deferred probe.

We check for probe deferral in the hw layer probe, so we not
probe into the main layer and memories, etc., to later learn
that we need to defer the probe.

Signed-off-by: lipeng 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 403ea9d..2da5b42 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -2971,6 +2971,18 @@ static int hns_dsaf_probe(struct platform_device *pdev)
struct dsaf_device *dsaf_dev;
int ret;
 
+   /*
+* Check if we should defer the probe before we probe the
+* dsaf, as it's hard to defer later on.
+*/
+   ret = platform_get_irq(pdev, 0);
+   if (ret < 0) {
+   if (ret != -EPROBE_DEFER)
+   dev_err(&pdev->dev, "Cannot obtain irq\n");
+
+   return ret;
+   }
+
dsaf_dev = hns_dsaf_alloc_dev(&pdev->dev, sizeof(struct dsaf_drv_priv));
if (IS_ERR(dsaf_dev)) {
ret = PTR_ERR(dsaf_dev);
-- 
1.9.1



[PATCH net-next 2/3] net: hns: support deferred probe when no mdio

2017-04-18 Thread Yankejian
From: lipeng 

In the hip06 and hip07 SoCs, phy connect to mdio bus.The mdio
module is probed with module_init, and, as such,
is not guaranteed to probe before the HNS driver. So we need
to support deferred probe.

We check for probe deferral in the mac init, so we not init DSAF
when there is no mdio, and free all resource, to later learn that
we need to defer the probe.

Signed-off-by: lipeng 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 34 +++
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index bdd8cdd..284ebfe 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -735,6 +735,8 @@ static int hns_mac_init_ex(struct hns_mac_cb *mac_cb)
rc = phy_device_register(phy);
if (rc) {
phy_device_free(phy);
+   dev_err(&mdio->dev, "registered phy fail at address %i\n",
+   addr);
return -ENODEV;
}
 
@@ -745,7 +747,7 @@ static int hns_mac_init_ex(struct hns_mac_cb *mac_cb)
return 0;
 }
 
-static void hns_mac_register_phy(struct hns_mac_cb *mac_cb)
+static int hns_mac_register_phy(struct hns_mac_cb *mac_cb)
 {
struct acpi_reference_args args;
struct platform_device *pdev;
@@ -755,24 +757,39 @@ static void hns_mac_register_phy(struct hns_mac_cb 
*mac_cb)
 
/* Loop over the child nodes and register a phy_device for each one */
if (!to_acpi_device_node(mac_cb->fw_port))
-   return;
+   return 0;
 
rc = acpi_node_get_property_reference(
mac_cb->fw_port, "mdio-node", 0, &args);
if (rc)
-   return;
+   return 0;
 
addr = hns_mac_phy_parse_addr(mac_cb->dev, mac_cb->fw_port);
if (addr < 0)
-   return;
+   return 0;
 
/* dev address in adev */
pdev = hns_dsaf_find_platform_device(acpi_fwnode_handle(args.adev));
+   if (!pdev) {
+   dev_err(mac_cb->dev, "mac%d mdio pdev is NULL\n",
+   mac_cb->mac_id);
+   return 0;
+   }
+
mii_bus = platform_get_drvdata(pdev);
+   if (!mii_bus) {
+   dev_err(mac_cb->dev,
+   "mac%d mdio is NULL, dsaf will probe again later\n",
+   mac_cb->mac_id);
+   return -EPROBE_DEFER;
+   }
+
rc = hns_mac_register_phydev(mii_bus, mac_cb, addr);
if (!rc)
dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n",
mac_cb->mac_id, addr);
+
+   return rc;
 }
 
 #define MAC_MEDIA_TYPE_MAX_LEN 16
@@ -793,7 +810,7 @@ static void hns_mac_register_phy(struct hns_mac_cb *mac_cb)
  *@np:device node
  * return: 0 --success, negative --fail
  */
-static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
+static int hns_mac_get_info(struct hns_mac_cb *mac_cb)
 {
struct device_node *np;
struct regmap *syscon;
@@ -903,7 +920,10 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
}
}
} else if (is_acpi_node(mac_cb->fw_port)) {
-   hns_mac_register_phy(mac_cb);
+   ret = hns_mac_register_phy(mac_cb);
+
+   if (ret)
+   return ret;
} else {
dev_err(mac_cb->dev, "mac%d cannot find phy node\n",
mac_cb->mac_id);
@@ -1065,6 +1085,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
dsaf_dev->mac_cb[port_id] = mac_cb;
}
}
+
/* init mac_cb for all port */
for (port_id = 0; port_id < max_port_num; port_id++) {
mac_cb = dsaf_dev->mac_cb[port_id];
@@ -1074,6 +1095,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
ret = hns_mac_get_cfg(dsaf_dev, mac_cb);
if (ret)
return ret;
+
ret = hns_mac_init_ex(mac_cb);
if (ret)
return ret;
-- 
1.9.1



[PATCH net-next 0/3] net: hns: add deferred probe and fix a bug

2017-04-18 Thread Yankejian
This series adds support defered probe to avoid no mdio scene, and will
fix a bug that skb may be freed several times.

lipeng (3):
  net: hns: support deferred probe when can not obtain irq
  net: hns: support deferred probe when no mdio
  net: hns: fixed bug that skb used after kfree

 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  | 34 ++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 12 
 drivers/net/ethernet/hisilicon/hns/hns_enet.c  | 22 +++---
 drivers/net/ethernet/hisilicon/hns/hns_enet.h  |  6 ++--
 4 files changed, 53 insertions(+), 21 deletions(-)

-- 
1.9.1



[PATCH net-next 3/3] net: hns: fixed bug that skb used after kfree

2017-04-18 Thread Yankejian
From: lipeng 

There is KASAN warning which turn out it's a skb used after free:

BUG: KASAN: use-after-free in hns_nic_net_xmit_hw+0x62c/0x940...
[17659.112635]  alloc_debug_processing+0x18c/0x1a0
[17659.117208]  __slab_alloc+0x52c/0x560
[17659.120909]  kmem_cache_alloc_node+0xac/0x2c0
[17659.125309]  __alloc_skb+0x6c/0x260
[17659.128837]  tcp_send_ack+0x8c/0x280
[17659.132449]  __tcp_ack_snd_check+0x9c/0xf0
[17659.136587]  tcp_rcv_established+0x5a4/0xa70
[17659.140899]  tcp_v4_do_rcv+0x27c/0x620
[17659.144687]  tcp_prequeue_process+0x108/0x170
[17659.149085]  tcp_recvmsg+0x940/0x1020
[17659.152787]  inet_recvmsg+0x124/0x180
[17659.156488]  sock_recvmsg+0x64/0x80
[17659.160012]  SyS_recvfrom+0xd8/0x180
[17659.163626]  __sys_trace_return+0x0/0x4
[17659.167506] INFO: Freed in kfree_skbmem+0xa0/0xb0 age=23 cpu=1 pid=13
[17659.174000]  free_debug_processing+0x1d4/0x2c0
[17659.178486]  __slab_free+0x240/0x390
[17659.182100]  kmem_cache_free+0x24c/0x270
[17659.186062]  kfree_skbmem+0xa0/0xb0
[17659.189587]  __kfree_skb+0x28/0x40
[17659.193025]  napi_gro_receive+0x168/0x1c0
[17659.197074]  hns_nic_rx_up_pro+0x58/0x90
[17659.201038]  hns_nic_rx_poll_one+0x518/0xbc0
[17659.205352]  hns_nic_common_poll+0x94/0x140
[17659.209576]  net_rx_action+0x458/0x5e0
[17659.213363]  __do_softirq+0x1b8/0x480
[17659.217062]  run_ksoftirqd+0x64/0x80
[17659.220679]  smpboot_thread_fn+0x224/0x310
[17659.224821]  kthread+0x150/0x170
[17659.228084]  ret_from_fork+0x10/0x40

BUG: KASAN: use-after-free in hns_nic_net_xmit+0x8c/0xc0...
[17751.080490]  __slab_alloc+0x52c/0x560
[17751.084188]  kmem_cache_alloc+0x244/0x280
[17751.088238]  __build_skb+0x40/0x150
[17751.091764]  build_skb+0x28/0x100
[17751.095115]  __alloc_rx_skb+0x94/0x150
[17751.098900]  __napi_alloc_skb+0x34/0x90
[17751.102776]  hns_nic_rx_poll_one+0x180/0xbc0
[17751.107097]  hns_nic_common_poll+0x94/0x140
[17751.111333]  net_rx_action+0x458/0x5e0
[17751.115123]  __do_softirq+0x1b8/0x480
[17751.118823]  run_ksoftirqd+0x64/0x80
[17751.122437]  smpboot_thread_fn+0x224/0x310
[17751.126575]  kthread+0x150/0x170
[17751.129838]  ret_from_fork+0x10/0x40
[17751.133454] INFO: Freed in kfree_skbmem+0xa0/0xb0 age=19 cpu=7 pid=43
[17751.139951]  free_debug_processing+0x1d4/0x2c0
[17751.144436]  __slab_free+0x240/0x390
[17751.148051]  kmem_cache_free+0x24c/0x270
[17751.152014]  kfree_skbmem+0xa0/0xb0
[17751.155543]  __kfree_skb+0x28/0x40
[17751.159022]  napi_gro_receive+0x168/0x1c0
[17751.163074]  hns_nic_rx_up_pro+0x58/0x90
[17751.167041]  hns_nic_rx_poll_one+0x518/0xbc0
[17751.171358]  hns_nic_common_poll+0x94/0x140
[17751.175585]  net_rx_action+0x458/0x5e0
[17751.179373]  __do_softirq+0x1b8/0x480
[17751.183076]  run_ksoftirqd+0x64/0x80
[17751.186691]  smpboot_thread_fn+0x224/0x310
[17751.190826]  kthread+0x150/0x170
[17751.194093]  ret_from_fork+0x10/0x40

in drivers/net/ethernet/hisilicon/hns/hns_enet.c

static netdev_tx_t hns_nic_net_xmit(struct sk_buff *skb,
struct net_device *ndev)
{
struct hns_nic_priv *priv = netdev_priv(ndev);
int ret;

assert(skb->queue_mapping < ndev->ae_handle->q_num);
ret = hns_nic_net_xmit_hw(ndev, skb,
  &tx_ring_data(priv, skb->queue_mapping));
if (ret == NETDEV_TX_OK) {
netif_trans_update(ndev);
ndev->stats.tx_bytes += skb->len;
ndev->stats.tx_packets++;
}
 return (netdev_tx_t)ret;
}

skb maybe freed in hns_nic_net_xmit_hw() and return NETDEV_TX_OK:

out_err_tx_ok:

dev_kfree_skb_any(skb);
return NETDEV_TX_OK;

This patch fix this bug.

Reported-by: Jun He 
Signed-off-by: lipeng 
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 22 ++
 drivers/net/ethernet/hisilicon/hns/hns_enet.h |  6 +++---
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c 
b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index fca37e2..1e04df6 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -300,9 +300,9 @@ static void fill_tso_desc(struct hnae_ring *ring, void 
*priv,
 mtu);
 }
 
-int hns_nic_net_xmit_hw(struct net_device *ndev,
-   struct sk_buff *skb,
-   struct hns_nic_ring_data *ring_data)
+netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
+   struct sk_

Re: [PATCH net-next 9/9] net: hns: get reset registers from DT

2016-06-29 Thread Yankejian (Hackim Yim)
On 2016/6/29 17:11, David Miller wrote:
> From: Yisen Zhuang 
> Date: Mon, 27 Jun 2016 17:54:15 +0800
>
>> @@ -361,9 +371,10 @@ static int hns_mdio_reset(struct mii_bus *bus)
>>  return -ENODEV;
>>  }
>>  
>> +sc_reg = &mdio_dev->sc_reg;
>>  /* 1. reset req, and read reset st check */
>> -ret = mdio_sc_cfg_reg_write(mdio_dev, MDIO_SC_RESET_REQ, 0x1,
>> -MDIO_SC_RESET_ST, 0x1,
>> +ret = mdio_sc_cfg_reg_write(mdio_dev, sc_reg->mdio_reset_req, 0x1,
>> +sc_reg->mdio_reset_st, 0x1,
>>  MDIO_CHECK_SET_ST);
>>  if (ret) {
>>  dev_err(&bus->dev, "MDIO reset fail\n");
> What in the world are you doing to the indentation here?
>
> Please read your patches before actually sending them, such things
> will be quite obvious by simple visual inspection.
>
> .
>
Hi David,
i am sorry for my carelessness. i will pay more attention next time.
Thanks for pointing it our

-- 
MBR,
Yankejian (Hackim Yim)




Re: [patch net-next 01/11] net: hisilicon: add support of acpi for hns-mdio

2016-05-16 Thread Yankejian (Hackim Yim)


On 2016/5/13 20:59, Andy Shevchenko wrote:
> On Fri, 2016-05-13 at 16:19 +0800, Yisen Zhuang wrote:
>> From: Kejian Yan 
>>
>> hns-mdio needs to register itself to mii-bus. The info of the device
>> can
>> be read by both OF and ACPI.
>> HNS tries to call Linux PHY driver to help access PHY-devices, the HNS
>> hardware topology is as below. The MDIO controller may control several
>> PHY-devices, and each PHY-device connects to a MAC device. The MDIO
>> will
>> be registered to mdiobus, then PHY-devices will register when each mac
>> find PHY device.
>>cpu
>> |
>> |
>>  ---
>> |   |   |
>> |   |   |
>> |  dsaf |
>>MDIO |  MDIO
>> |  ---  |
>> | | | |   | |
>> | | | |   | |
>> |MAC   MAC   MAC MAC|
>> | | | |   | |
>>   | | |   | 
>>  ||||||   ||
>>  PHY   PHY   PHY PHY
>>
>> And the driver can handle reset sequence by _DSD method in DSDT in
>> ACPI case.
>>
>> Signed-off-by: Kejian Yan 
>> Signed-off-by: Yisen Zhuang 
>> ---
>>  drivers/net/ethernet/hisilicon/hns_mdio.c | 145 ++---
>> -
>>  1 file changed, 90 insertions(+), 55 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns_mdio.c
>> b/drivers/net/ethernet/hisilicon/hns_mdio.c
>> index 765ddb3..4b779df 100644
>> --- a/drivers/net/ethernet/hisilicon/hns_mdio.c
>> +++ b/drivers/net/ethernet/hisilicon/hns_mdio.c
>> @@ -7,6 +7,7 @@
>>   * (at your option) any later version.
>>   */
>>  
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -354,64 +355,72 @@ static int hns_mdio_reset(struct mii_bus *bus)
>>  struct hns_mdio_device *mdio_dev = (struct hns_mdio_device
>> *)bus->priv;
>>  int ret;
>>  
>> -if (!mdio_dev->subctrl_vbase) {
>> -dev_err(&bus->dev, "mdio sys ctl reg has not
>> maped\n");
>> -return -ENODEV;
>> -}
>> -
>> -/*1. reset req, and read reset st check*/
>> -ret = mdio_sc_cfg_reg_write(mdio_dev, MDIO_SC_RESET_REQ, 0x1,
>> -MDIO_SC_RESET_ST, 0x1,
>> -MDIO_CHECK_SET_ST);
>> -if (ret) {
>> -dev_err(&bus->dev, "MDIO reset fail\n");
>> -return ret;
>> -}
>> +if (IS_ENABLED(CONFIG_OF) && bus->parent->of_node) {
> Can you keep indentation the same?
>
> Also I suggest to use struct fwnode_handle, and this will be something
> like
>
> if (is_of_node(...))
ok, thanks Andy. i will fix it in next submit

>
>> +if (!mdio_dev->subctrl_vbase) {
>> +dev_err(&bus->dev, "mdio sys ctl reg has not
>> maped\n");
>> +return -ENODEV;
>> +}
>>  
>> -/*2. dis clk, and read clk st check*/
>> -ret = mdio_sc_cfg_reg_write(mdio_dev, MDIO_SC_CLK_DIS,
>> -0x1, MDIO_SC_CLK_ST, 0x1,
>> -MDIO_CHECK_CLR_ST);
>> -if (ret) {
>> -dev_err(&bus->dev, "MDIO dis clk fail\n");
>> -return ret;
>> -}
>> +/*1. reset req, and read reset st check*/
>> +ret = mdio_sc_cfg_reg_write(mdio_dev,
>> MDIO_SC_RESET_REQ, 0x1,
>> +MDIO_SC_RESET_ST, 0x1,
>> +MDIO_CHECK_SET_ST);
>> +if (ret) {
>> +dev_err(&bus->dev, "MDIO reset fail\n");
>> +return ret;
>> +}
>>  
>> -/*3. reset dreq, and read reset st check*/
>> -ret = mdio_sc_cfg_reg_write(mdio_dev, MDIO_SC_RESET_DREQ,
>> 0x1,
>> -MDIO_SC_RESET_ST, 0x1,
>> -MDIO_CHECK_CLR_ST);
>> -if (ret) {
>> -dev_err(&bus->dev, "MDIO dis clk fail\n");
>> -return ret;
>> -}
>> +/*2. dis clk, and read clk st check*/
>> +ret = mdio_sc_cfg_reg_write(mdio_dev,
>> MDIO_SC_CLK_DIS,
>> +0x1, MDIO_SC_CLK_ST, 0x1,
>> +MDIO_CHECK_CLR_ST);
>> +if (ret) {
>> +dev_err(&bus->dev, "MDIO dis clk fail\n");
>> +return ret;
>> +}
>>  
>> -/*4. en clk, and read clk st check*/
>> -ret = mdio_sc_cfg_reg_write(mdio_dev, MDIO_SC_CLK_EN,
>> -0x1, MDIO_SC_CLK_ST, 0x1,
>> -MDIO_CHECK_SET_ST);
>> -if (ret)
>> -dev_err(&bus->dev, "MDIO en clk fail\n");
>> +/*3. reset dreq, and 

Re: [patch net-next 07/11] net: hns: dsaf adds support of acpi

2016-05-15 Thread Yankejian (Hackim Yim)


On 2016/5/13 21:12, Andy Shevchenko wrote:
> On Fri, 2016-05-13 at 16:19 +0800, Yisen Zhuang wrote:
>> From: Kejian Yan 
>>
>> Dsaf needs to get configuration parameter by ACPI, so this patch add
>> support of ACPI.
>>
> Looks like at some point better to split driver to core part, and PCI
> and ACPI/DT/platform code.
>
> Too many changes where IS_ENABLED() involved shows as I can imagine bad
> architecture / split of the driver.

Hi Andy,
Actully, we use the unified function asap. The routine in DT/ACPI maybe 
difference. Some routine
will be treated in BIOS in ACPI case, but it will be treated in OS in DT case, 
so we need to distinguish
it.
And we will try to reduce the use of IS_ENABLED().

Thanks very much for your suggestions, Andy

Kejian




Re: [patch net-next 06/11] ACPI: bus: move acpi_match_device_ids() to linux/acpi.h

2016-05-15 Thread Yankejian (Hackim Yim)


On 2016/5/13 21:15, Andy Shevchenko wrote:
> On Fri, 2016-05-13 at 16:19 +0800, Yisen Zhuang wrote:
>> From: Hanjun Guo 
>>
>> acpi_match_device_ids() will be used for drivers to match
>> different hardware versions, it will be compiled in non-ACPI
>> case, but acpi_match_device_ids() in acpi_bus.h and it can
>> only be used in ACPI case, so move it to linux/acpi.h and
>> introduce a stub function for it.
> I somehow doubt this is right move.
>
> Like I said in the previous comment the architectural split might make
> this a bit better.
>
> You might use 
>
> #ifdef IS_ENABLED(CONFIG_ACPI)
> #else
> #endif
>
> only once to some big part of code. If kernel is build without ACPI
> support you even will not have this in your driver at all.

Hi Andy,

Thanks for your suggestions. It will add stub function instead in next submit.


> -- 
> Andy Shevchenko 
> Intel Finland Oy
>
>
> .
>




Re: [patch net-next 05/11] net: hns: add uniform interface for phy connection

2016-05-15 Thread Yankejian (Hackim Yim)


On 2016/5/13 21:07, Andy Shevchenko wrote:
> On Fri, 2016-05-13 at 16:19 +0800, Yisen Zhuang wrote:
>> From: Kejian Yan 
>>
>> As device_node is only used by OF case, HNS needs to treat the others
>> cases including ACPI. It needs to use uniform ways to handle both of
>> OF and ACPI. This patch chooses phy_device, and of_phy_connect and
>> of_phy_attach are only used by OF case. It needs to add uniform
>> interface
>> to handle that sequence by both OF and ACPI.
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
>> @@ -987,6 +987,41 @@ static void hns_nic_adjust_link(struct net_device
>> *ndev)
>>  h->dev->ops->adjust_link(h, ndev->phydev->speed, ndev-
>>> phydev->duplex);
>>  }
>>  
>> +static
>> +struct phy_device *hns_nic_phy_attach(struct net_device *dev,
>> +  struct phy_device *phy,
>> +  u32 flags,
>> +  phy_interface_t iface)
>> +{
>> +int ret;
>> +
>> +if (!phy)
>> +return NULL;
> No need to use defensive programming here.
>
>> +
>> +ret = phy_attach_direct(dev, phy, flags, iface);
>> +
>> +return ret ? NULL : phy;
> Shouldn't it return an error?
>
>
>> +}
>> +
>> +static
>> +struct phy_device *hns_nic_phy_connect(struct net_device *dev,
>> +   struct phy_device *phy,
>> +   void (*hndlr)(struct
>> net_device *),
>> +   u32 flags,
>> +   phy_interface_t iface)
>> +{
>> +int ret;
>> +
>> +if (!phy)
>> +return NULL;
>> +
>> +phy->dev_flags = flags;
>> +
>> +ret = phy_connect_direct(dev, phy, hndlr, iface);
>> +
>> +return ret ? NULL : phy;
>> +}
>> +
> For now looks that above functions are redundant and you may call them
> directly in below code.

Hi Andy,
Thanks for you suggestions, it will be fixed in next submit

MBR,
Kejian

>>  /**
>>   *hns_nic_init_phy - init phy
>>   *@ndev: net device
>> @@ -996,16 +1031,17 @@ static void hns_nic_adjust_link(struct
>> net_device *ndev)
>>  int hns_nic_init_phy(struct net_device *ndev, struct hnae_handle *h)
>>  {
>>  struct hns_nic_priv *priv = netdev_priv(ndev);
>> -struct phy_device *phy_dev = NULL;
>> +struct phy_device *phy_dev = h->phy_dev;
>>  
>> -if (!h->phy_node)
>> +if (!h->phy_dev)
>>  return 0;
>>  
>>  if (h->phy_if != PHY_INTERFACE_MODE_XGMII)
>> -phy_dev = of_phy_connect(ndev, h->phy_node,
>> - hns_nic_adjust_link, 0, h-
>>> phy_if);
>> +phy_dev = hns_nic_phy_connect(ndev, phy_dev,
>> +  hns_nic_adjust_link,
>> +  0, h->phy_if);
>>  else
>> -phy_dev = of_phy_attach(ndev, h->phy_node, 0, h-
>>> phy_if);
>> +phy_dev = hns_nic_phy_attach(ndev, phy_dev, 0, h-
>>> phy_if);
>




Re: [PATCH V2 net 0/4] net: hns: bugs fix about hns driver

2016-03-14 Thread Yankejian (Hackim Yim)

On 2016/3/12 0:56, David Miller wrote:
> This does not work.
>
> I will not allow two sets of people sending me patches in parallel to the
> same driver at the same time.
>
> Have one person manage the maintainence of this driver and consolidate the
> patch submissions to me.
>
> Thanks.
>
> .
>

Hi David,
 
Thanks for your reply. we will upstream the patches one by one. And we will ask 
Daode Huang to help us
to upsream.

MBR, Kejian





Re: [PATCH v3 net-next 0/2] net: hns: get and set RSS indirection table by using ethtool

2016-03-13 Thread Yankejian (Hackim Yim)


On 2016/3/11 17:01, Andy Shevchenko wrote:
> On Fri, 2016-03-11 at 11:25 +0800, Kejian Yan wrote:
>> When we use ethtool to retrieves or configure the receive flow hash 
>> indirection table, ethtool needs to call .get_rxnfc to get the ring
>> number
>> so this patchset implements the .get_rxnfc and fixes the bug that we
>> can
>> not get the tatal table each time.
>>
> FWIW:
>
> Reviewed-by: Andy Shevchenko 
Hi Andy,
I'm sorry for missing it.i will fix it in next submit.

MBR, Kejian

>> ---
>> change log:
>> PATCH v3:
>>  - This patchset fixes the building warning and error
>>
>> PATCH v2:
>>  - This patchset fixes the comments provided by Andy Shevchenko > Shevchenko>
>>
>> PATCH v1:
>>  - first submit
>>
>> Kejian Yan (2):
>>   net: hns: fix return value of the function about rss
>>   net: hns: fixes a bug of RSS
>>
>>  drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c |  8 ---
>>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c |  2 +-
>>  drivers/net/ethernet/hisilicon/hns/hns_ethtool.c  | 28
>> ---
>>  3 files changed, 26 insertions(+), 12 deletions(-)
>>




Re: [PATCH 2/3] net: hns: add Hisilicon RoCE support

2016-03-13 Thread Yankejian (Hackim Yim)


On 2016/3/12 18:43, Leon Romanovsky wrote:
> On Fri, Mar 11, 2016 at 06:37:10PM +0800, Lijun Ou wrote:
>> It added hns_dsaf_roce_reset routine for roce driver.
>> RoCE is a feature of hns.
>> In hip06 SOC, in roce reset process, it's needed to configure
>> dsaf channel reset,port and sl map info.
>>
>> Signed-off-by: Lijun Ou 
>> Signed-off-by: Wei Hu(Xavier) 
>> Signed-off-by: Lisheng 
>> ---
>>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 84 
>> ++
>>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h | 14 
>>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 62 +---
>>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h  | 13 
>>  4 files changed, 163 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c 
>> b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
>> index 38fc5be..a0f0d4f 100644
>> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
>> @@ -12,6 +12,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -2593,6 +2594,89 @@ static struct platform_driver g_dsaf_driver = {
>>  
>>  module_platform_driver(g_dsaf_driver);
>>  
>> +/**
>> + * hns_dsaf_roce_reset - reset dsaf and roce
>> + * @dsaf_fwnode: Pointer to framework node for the dasf
>> + * @val: 0 - request reset , 1 - drop reset
>> + * retuen 0 - success , negative --fail
>> + */
>> +int hns_dsaf_roce_reset(struct fwnode_handle *dsaf_fwnode, u32 val)
>> +{
>> +struct dsaf_device *dsaf_dev;
>> +struct platform_device *pdev;
>> +unsigned int mp;
>> +unsigned int sl;
>> +unsigned int credit;
>> +int i;
>> +const u32 port_map[DSAF_ROCE_CREDIT_CHN][DSAF_ROCE_CHAN_MODE] = {
>> +{0, 0, 0},
>> +{1, 0, 0},
>> +{2, 1, 0},
>> +{3, 1, 0},
>> +{4, 2, 1},
>> +{4, 2, 1},
>> +{5, 3, 1},
>> +{5, 3, 1},
>> +};
>> +const u32 sl_map[DSAF_ROCE_CREDIT_CHN][DSAF_ROCE_CHAN_MODE] = {
>> +{0, 0, 0},
>> +{0, 1, 1},
>> +{0, 0, 2},
>> +{0, 1, 3},
>> +{0, 0, 0},
>> +{1, 1, 1},
>> +{0, 0, 2},
>> +{1, 1, 3},
>> +};
> Do you have a plan to send a version with enums/defines for this
> numbers? Especially for _CHAN_MODE.
>
> .

Hi leon,

it seems the enums is added in hns_dsaf_main.h, as belows:

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
index 5fea226..c917b9a 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
@@ -40,6 +40,16 @@ struct hns_mac_cb;
 #define DSAF_DUMP_REGS_NUM 504
 #define DSAF_STATIC_NUM 28
 
+#define DSAF_ROCE_CREDIT_CHN 8
+#define DSAF_ROCE_CHAN_MODE 3
+
+enum dsaf_roce_port_port_mode {
+   DSAF_ROCE_6PORT_MODE,
+   DSAF_ROCE_4PORT_MODE,
+   DSAF_ROCE_2PORT_MODE,
+   DSAF_ROCE_CHAN_MODE_NUM
+};
+

MBR, Kejian








Re: [patch net 2/2] net: hns: fixes a bug of RSS

2016-03-10 Thread Yankejian (Hackim Yim)


On 2016/3/10 16:24, Andy Shevchenko wrote:
> On Thu, 2016-03-10 at 10:16 +0800, Kejian Yan wrote:
>> If trying to get receive flow hash indirection table by ethtool, it
>> needs
>> to call .get_rxnfc to get ring number first. So this patch implements
>> the
>> .get_rxnfc of ethtool. And the data type of rss_indir_table is u32,
>> it has
>> to be multiply by the width of data type when using memcpy.
> +static int hns_get_rxnfc(struct net_device *netdev,
>> + struct ethtool_rxnfc *cmd,
>> + u32 *rule_locs)
>> +{
>> +struct hns_nic_priv *priv = netdev_priv(netdev);
>> +int ret = 0;
>> +
>> +switch (cmd->cmd) {
>> +case ETHTOOL_GRXRINGS:
>> +cmd->data = priv->ae_handle->q_num;
>> +break;
>> +default:
>> +ret = -EOPNOTSUPP;
>> +break;
>> +}
>> +
>> +return ret;
> Redundant ret variable.
>
> switch (value) {
> case X:
>  break;
> default:
>  return -ERRNO;
> }
>
> return 0;

ok, thanks. i will fix it in next submit.

>> +}




Re: [patch net 1/2] net: hns: fix return value of the function about rss

2016-03-10 Thread Yankejian (Hackim Yim)


On 2016/3/10 16:11, Andy Shevchenko wrote:
> On Thu, 2016-03-10 at 10:16 +0800, Kejian Yan wrote:
>> Both .get_rxfh and .get_rxfh are always return 0, it should return
>> result
>> from hardware when getting or setting rss. And the rss function
>> should
>> return the correct data type.
>>
> @@ -1213,7 +1213,7 @@ hns_get_rss(struct net_device *netdev, u32
>> *indir, u8 *key, u8 *hfunc)
>>  
>>
>>  ret = ops->get_rss(priv->ae_handle, indir, key, hfunc);
>>  
>> -return 0;
>> +return ret;
> All three can be one line.

ok, thanks!

>> @@ -1241,7 +1241,7 @@ hns_set_rss(struct net_device *netdev, const
>> u32 *indir, const u8 *key,
>>  
>>  ret = ops->set_rss(priv->ae_handle, indir, key, hfunc);
>>  
>> -return 0;
>> +return ret;
> Ditto.
>
ok, thanks!



Re: [PATCH net] net: hns: fix the bug about loopback

2016-03-03 Thread Yankejian (Hackim Yim)


On 2016/3/3 21:39, Andy Shevchenko wrote:
> On Thu, 2016-03-03 at 20:02 +0800, Kejian Yan wrote:
>> It will always be passed if the soc is tested the loopback cases.
>> This
>> patch will fix this bug.
> Few style related comments.
>
>> @@ -686,6 +690,10 @@ static int hns_ae_config_loopback(struct
>> hnae_handle *handle,
>>  default:
>>  ret = -EINVAL;
>>  }
>> +
>> +if (!ret)
>> +hns_dsaf_set_inner_lb(mac_cb->dsaf_dev, mac_cb-
>>> mac_id, en);
>> +
>>  return ret;
> if (ret)
>  return ret;
>
> whatever();
> return 0;

Hi, Andy,
Thanks for your suggestion. I think it should be return ret. the other case 
will be return the value from hardware.
it can tell callers if the operation is successful or not.

Best Regards

>>  }
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
>> @@ -230,6 +230,30 @@ static void hns_dsaf_mix_def_qid_cfg(struct
>> dsaf_device *dsaf_dev)
>>  }
>>  }
>>  
>> +static void hns_dsaf_inner_qid_cfg(struct dsaf_device *dsaf_dev)
>> +{
>> +u16 max_q_per_vf, max_vfn;
>> +u32 q_id = 0, q_num_per_port;
>> +u32 mac_id;
>> +
>> +if (AE_IS_VER1(dsaf_dev->dsaf_ver))
>> +return;
>> +
>> +hns_rcb_get_queue_mode(dsaf_dev->dsaf_mode,
>> +   HNS_DSAF_COMM_SERVICE_NW_IDX,
>> +   &max_vfn, &max_q_per_vf);
>> +q_num_per_port = max_vfn * max_q_per_vf;
>> +
>> +for (mac_id = 0, q_id = 0; mac_id < DSAF_SERVICE_NW_NUM; 
> q_id is already assigned to 0. Get rid of either.

Thanks. I will fix it in next submit

>> mac_id++) {
>> +dsaf_set_dev_field(dsaf_dev,
>> +   DSAFV2_SERDES_LBK_0_REG + 0x4 *
>> mac_id,
>> +   DSAFV2_SERDES_LBK_QID_M,
>> +   DSAFV2_SERDES_LBK_QID_S,
>> +   q_id);
>> +q_id += q_num_per_port;
>> +}
>> +}
>  
>> +void hns_dsaf_set_inner_lb(struct dsaf_device *dsaf_dev, u32 mac_id,
>> u32 en)
>> +{
>> +if (AE_IS_VER1(dsaf_dev->dsaf_ver) ||
>> +dsaf_dev->mac_cb[mac_id].mac_type == HNAE_PORT_DEBUG)
>> +return;
>> +
>> +dsaf_set_dev_bit(dsaf_dev, DSAFV2_SERDES_LBK_0_REG + 0x4 *
>> mac_id,
> 0x4 -> 4 (it's about register width, right?)

Thanks. I will fix it in next submit

>> + DSAFV2_SERDES_LBK_EN_B, !!en);
>> +}
>>  #define PPEV2_CFG_RSS_TBL_4N3_S 24
>>  #define PPEV2_CFG_RSS_TBL_4N3_M (((1UL << 5) - 1) <<
>> PPEV2_CFG_RSS_TBL_4N3_S)
>>  
>> +#define DSAFV2_SERDES_LBK_EN_B  8
>> +#define DSAFV2_SERDES_LBK_QID_S 0
>> +#define DSAFV2_SERDES_LBK_QID_M \
>> +(((1UL << DSAFV2_SERDES_LBK_EN_B) - 1) <<
>> DSAFV2_SERDES_LBK_QID_S)
> Why not like above?
>
> #define DSAFV2_SERDES_LBK_QID_M   (((1UL << 8) - 1)
> << DSAFV2_SERDES_LBK_QID_S)

to keep the unifying style, i will fix it in next submit.

>> +static void __lb_fill_txt_skb_buff(struct net_device *ndev,
>> +   struct sk_buff *skb)
>> +{
>> +struct hns_nic_priv *priv = netdev_priv(ndev);
>> +struct hnae_handle *h = priv->ae_handle;
>> +u32 frame_size;
>> +
>> +frame_size = skb->len;
>> +memset(skb->data, 0xFF, frame_size);
>> +
>> +if ((!AE_IS_VER1(priv->enet_ver)) &&
>> +(h->port_type == HNAE_PORT_SERVICE)) {
>> +memcpy(skb->data, ndev->dev_addr, 6);
> ether_addr_copy() ?

ok, thanks.i will fix it in next submit.



>> +skb->data[5] += 0x1f;
> This has to be explained.
>
>> +}
>> +
>> +frame_size &= ~1ul;
> And how 1ul is different to plain 1 here?

the bit width must be 32bit

>
>> +memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 -
>> 1);
>> +memset(&skb->data[frame_size / 2 + 10], 0xBE, frame_size / 2
>> - 11);
>> +memset(&skb->data[frame_size / 2 + 12], 0xAF, frame_size / 2
>> - 13);
> Magic numbers have to be explained.
> Also, what is the logic to overwrite the data if frame_size is big
> enough?

the caller, who generates the frame, ensure that it will not be overwritten. it 
is only one caller in the system.

>> +}
>> +




Re: [PATCH v2 next 1/2] dts: hisi: fixes no syscon error when init mdio

2015-12-09 Thread Yankejian (Hackim Yim)


On 2015/12/8 23:25, Rob Herring wrote:
> On Mon, Dec 07, 2015 at 04:25:06PM +0800, yankejian wrote:
>> Signed-nux start up, we get the log below:
>> "Hi-HNS_MDIO 803c.mdio: no syscon hisilicon,peri-c-subctrl
>>  mdio_bus mdio@803c: mdio sys ctl reg has not maped   "
>>
>> the source code about the subctrl is dealled with syscon, but dts doesn't.
> The source...
>
> s/dealled/dealt/
Thanks for pointing it out. it will be changed in patch v3.
Best Regards,
yankejian

>> it cause such fault. so this patch adds the syscon info on dts files to
>> fixes it. and it adds documentation for the devicetree bindings used by
> Capitalization please.

Thanks a lot for pointing it out. i will pay attention to that next time.
Best Regards,
yankejian
>> DT files of Hisilicon Hip05-D02 development board.
>>
>> Signed-off-by: yankejian 
>> ---
>> change log:
>> v2:
>>  1) updates the related documented in the binding as well
>>  2) use the normal naming conventions using '-' instead of '_'
>>
>> v1:
>>  initial version
>> ---
>>  .../devicetree/bindings/arm/hisilicon/hisilicon.txt  | 16 
>> 
>>  arch/arm64/boot/dts/hisilicon/hip05.dtsi |  5 +
>>  arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi |  4 ++--
>>  3 files changed, 23 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt 
>> b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
>> index 6ac7c00..9f05767 100644
>> --- a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
>> +++ b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
>> @@ -187,6 +187,22 @@ Example:
>>  reg = <0xb000 0x1>;
>>  };
>>  
>> +Hisilicon HiP05 PERISUB system controller
>> +
>> +Required properties:
>> +- compatible : "hisilicon,peri-c-subctrl", "syscon";
>> +- reg : Register address and size
>> +
>> +The HiP05 PERISUB system controller is shared by peripheral controllers in
>> +HiP05 Soc to implement some basic configurations. the peripheral
>> +controllers include mdio, ddr, iic, uart, timer and so on.
>> +
>> +Example:
>> +/* for HiP05 PCIe-SAS system */
>> +peri-c-subctrl: sub-ctrl-c@8000 {
> s/sub-ctrl-c/syscon/
Thanks for pointing it out. it will be changed in patch v3.
Best Regards,
yankejian
>
>> +compatible = "hisilicon,peri-c-subctrl", "syscon";
>> +reg = <0x0 0x8000 0x0 0x1>;
>> +};
>>  ---
>>  Hisilicon CPU controller
>>  
>> diff --git a/arch/arm64/boot/dts/hisilicon/hip05.dtsi 
>> b/arch/arm64/boot/dts/hisilicon/hip05.dtsi
>> index 4ff16d0..5fec740 100644
>> --- a/arch/arm64/boot/dts/hisilicon/hip05.dtsi
>> +++ b/arch/arm64/boot/dts/hisilicon/hip05.dtsi
>> @@ -246,6 +246,11 @@
>>  clock-frequency = <2>;
>>  };
>>  
>> +peri_c_subctrl: sub-ctrl-c@8000 {
>> +compatible = "hisilicon,peri-c-subctrl", "syscon";
>> +reg = < 0x0 0x8000 0x0 0x1>;
>> +};
>> +
>>  uart0: uart@8030 {
>>  compatible = "snps,dw-apb-uart";
>>  reg = <0x0 0x8030 0x0 0x1>;
>> diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi 
>> b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
>> index 606dd5a..da7b6e6 100644
>> --- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
>> +++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
>> @@ -10,8 +10,8 @@ soc0: soc@0 {
>>  #address-cells = <1>;
>>  #size-cells = <0>;
>>  compatible = "hisilicon,hns-mdio";
>> -reg = <0x0 0x803c 0x0 0x1
>> -   0x0 0x8000 0x0 0x1>;
>> +reg = <0x0 0x803c 0x0 0x1>;
>> +subctrl-vbase = <&peri_c_subctrl>;
>>  
>>  soc0_phy0: ethernet-phy@0 {
>>  reg = <0x0>;
>> -- 
>> 1.9.1
>>
> .
>


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


Re: [PATCH net-next 1/2] net: hns: enet specisies a reference to dsaf

2015-12-09 Thread Yankejian (Hackim Yim)


On 2015/12/9 2:10, Florian Fainelli wrote:
> Subject: s/specisies/specifies/?

Thanks for pointing it out. i will change it in next patchset.

Best Regards,
yankejian

> On 04/12/15 23:59, yankejian wrote:
>> enet is associating with dasf. before this patch, the association is
>> the same strings between ae-name and dsa-name. in a general way, enet
>> specifies a reference to dsaf should be a good idea. so this patch
>> deletes the ae-name in enet, and adds parsing the ae-handle
>> from DT to set the associating with dsaf.
>>
>> Signed-off-by: yankejian 
>> ---
> [snip]
>
>> 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);
> of_find_net_device_by_node might be used for this maybe?
it needs return hnae_ae_dev so we didn't decide to use 
of_find_net_device_by_node.
Thanks



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


Re: arRe: [PATCH net-next 2/2] net: hns: enet specisies a reference to dsaf (config and documents)

2015-12-09 Thread Yankejian (Hackim Yim)


On 2015/12/9 18:00, Arnd Bergmann wrote:
> On Wednesday 09 December 2015 17:25:13 Yankejian wrote:
>>  thanks a lot for pointing it out.
>>
>>  It is great regret that this change breaks compatibility with old dtbs.
>>  this is a new driver which is run on developing boards, and all the
>>  clients' boards are developing boards. So we provide them a method to
>>  update the firmware on the board, once we update the dtsi and kernel,
>>  we require our clients to update the existed firmware and kernel.
>>  Therefore, these changes is actually under control. Shall we treat this
>>  by this way?
> Ok, if you can show that the incompatible change is safe to do, that's
> fine. Just put the explanation above into the patch description to
> document that you have considered the effects of the change, and
> to ensure that it gets done atomically.
>
> Also, you have to merge the two patches into one to allow bisection,
> or do a series of three patches that need to be applied in order:
>
> 1. add ae-handle property
> 2. change driver to use that property
> 3. remove ae-name property
>
>   Arnd
>
> .
>
Ok, thanks for your good advices.
i will change it in V2 PATCH.

Bset Regards
yankejian

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


Re: arRe: [PATCH net-next 2/2] net: hns: enet specisies a reference to dsaf (config and documents)

2015-12-09 Thread Yankejian (Hackim Yim)


On 2015/12/7 17:40, Arnd Bergmann wrote:
> On Monday 07 December 2015 15:14:13 Yankejian wrote:
>> On 2015/12/6 6:19, Arnd Bergmann wrote:
>>> On Saturday 05 December 2015 14:10:56 yankejian wrote:
>>>> 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@c700 {
>>>> +dsaf0: dsa@c700 {
>>>> compatible = "hisilicon,hns-dsaf-v1";
>>>> -   dsa_name = "dsaf0";
>>>> mode = "6port-16rss";
>>>> interrupt-parent = <&mbigen_dsa>;
>>>> reg = <0x0 0xC000 0x0 0x42
>>>> 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:
>>>>  
>>>>
>>> This looks like an incompatible change, as you add and remove
>>> required properties. Is there a way to support both the old and
>>> the new style?
>>>
>>>   Arnd
>>>
>>> .
>> Hi Arnd,
>> Thanks for your suggestions.  it must be set the same strings in dsaf node 
>> and every enet node before.
>> it seems inappropriate. as Rob Herring  's suggestions, 
>> that would solve associating
>> enet with a particular dsaf. so we discus the solution with Yisen Zhuang 
>> .
>> we decide to use the new way instead of the old one.
> I agree the new form looks better than the original way, but I'm worried
> about the migration path. You don't explain in the patch description
> how you want to ensure that nothing breaks for existing systems.
>
> We generally try to avoid doing incompatible changes altogether and
> prefer to keep backwards compatibility, unless we can prove that no
> other systems exist that would get impacted by the change.
>
> Are you sure that nobody ships a DTB file for this hardware with their
> firmware that would now require an incompatible update which in turn
> breaks old kernels?
>
> Are you sure that there is no hardware using the same dsa hardware
> with out-of-tree dts files that need to make the same change but might
> not be aware of the change?
>
>   Arnd
>
> .
 
 hi Arnd.

 thanks a lot for pointing it out.

 It is great regret that this change breaks compatibility with old dtbs.
 this is a new driver which is run on developing boards, and all the
 clients' boards are developing boards. So we provide them a method to
 update the firmware on the board, once we update the dtsi and kernel,
 we require our clients to update the existed firmware and kernel.
 Therefore, these changes is actually under control. Shall we treat this
 by this way?

 thanks very much.


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


Re: [PATCH net-next 2/2] net: hns: enet specisies a reference to dsaf (config and documents)

2015-12-08 Thread Yankejian (Hackim Yim)


On 2015/12/7 22:12, Rob Herring wrote:
> On Sat, Dec 05, 2015 at 03:59:16PM +0800, yankejian wrote:
>> when enet specisies a reference to dsaf, the correlative config and
> s/when/When/
ok,i will pay attention to it on patch v3.
thanks.
>> documents needs to update. this patch updates the correlative dtsi file
> s/this/This/
ok,i will pay attention to it on patch v3.
thanks.
>> and bindings documents .
> ^
> extra space
>
> This change breaks compatibility with old dtbs. IIRC, this is all new, 
> so maybe it doesn't matter, but you should be explicit that you are 
> doing that.
>
ok,i will pay attention to it on patch v3.
thanks.
>> Signed-off-by: yankejian 
>> ---
>>  .../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 
>> +--
>>  3 files changed, 14 insertions(+), 17 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@c700 {
>> +dsaf0: dsa@c700 {
>>  compatible = "hisilicon,hns-dsaf-v1";
>> -dsa_name = "dsaf0";
>>  mode = "6port-16rss";
>>  interrupt-parent = <&mbigen_dsa>;
>>  reg = <0x0 0xC000 0x0 0x42
>> 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@0 {
>>  };
>>  };
>>  
>> -dsa: dsa@c700 {
>> +dsaf0: dsa@c700 {
>>  compatible = "hisilicon,hns-dsaf-v1";
>> -dsa_name = "dsaf0";
>>  mode = "6port-16rss";
>>  interrupt-parent = <&mbigen_dsa>;
>>  
>> @@ -127,7 +126,7 @@ soc0: soc@0 {
>>  
>>  eth0: ethernet@0{
>>  compatible = "hisilicon,hns-nic-v1";
>> -ae-name = "dsaf0";
>> +ae-handle = <&dsaf0>

Re: [PATCH net-next] net: hns: optimize XGE capability by reducing cpu usage

2015-12-07 Thread Yankejian (Hackim Yim)


On 2015/12/8 14:30, Du, Fan wrote:
>
>
> On 2015/12/8 14:22, Yankejian (Hackim Yim) wrote:
>>
>> On 2015/12/7 16:58, Du, Fan wrote:
>>> >
>>> >
>>> >On 2015/12/5 15:32, yankejian wrote:
>>>> >>here is the patch raising the performance of XGE by:
>>>> >>1)changes the way page management method for enet momery, and
>>>> >>2)reduces the count of rmb, and
>>>> >>3)adds Memory prefetching
>>> >
>>> >Any numbers on how much it boost performance?
>>> >
>> it is almost the same as 82599.
>
> I mean how much it improves performance *BEFORE* and *AFTER* this patch
> for Huawei XGE chip, because the commit log states it "raising the 
> performance",
> but did give numbers of the testing.
>
> .
>
Hi Du Fan,
the bandwidth's raising is not obviously, but the cpu usage degracing up to 50%


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


Re: [PATCH net-next] net: hns: optimize XGE capability by reducing cpu usage

2015-12-07 Thread Yankejian (Hackim Yim)


On 2015/12/7 16:58, Du, Fan wrote:
>
>
> On 2015/12/5 15:32, yankejian wrote:
>> here is the patch raising the performance of XGE by:
>> 1)changes the way page management method for enet momery, and
>> 2)reduces the count of rmb, and
>> 3)adds Memory prefetching
>
> Any numbers on how much it boost performance?
>

it is almost the same as 82599.

>> Signed-off-by: yankejian 
>> ---
>>   drivers/net/ethernet/hisilicon/hns/hnae.h |  5 +-
>>   drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c |  1 -
>>   drivers/net/ethernet/hisilicon/hns/hns_enet.c | 79 
>> +++
>>   3 files changed, 55 insertions(+), 30 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h 
>> b/drivers/net/ethernet/hisilicon/hns/hnae.h
>> index d1f3316..6ca94dc 100644
>> --- a/drivers/net/ethernet/hisilicon/hns/hnae.h
>> +++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
>> @@ -341,7 +341,8 @@ struct hnae_queue {
>>   void __iomem *io_base;
>>   phys_addr_t phy_base;
>>   struct hnae_ae_dev *dev;/* the device who use this queue */
>> -struct hnae_ring rx_ring, tx_ring;
>> +struct hnae_ring rx_ring cacheline_internodealigned_in_smp;
>> +struct hnae_ring tx_ring cacheline_internodealigned_in_smp;
>>   struct hnae_handle *handle;
>>   };
>>
>> @@ -597,11 +598,9 @@ static inline void hnae_replace_buffer(struct hnae_ring 
>> *ring, int i,
>>  struct hnae_desc_cb *res_cb)
>>   {
>>   struct hnae_buf_ops *bops = ring->q->handle->bops;
>> -struct hnae_desc_cb tmp_cb = ring->desc_cb[i];
>>
>>   bops->unmap_buffer(ring, &ring->desc_cb[i]);
>>   ring->desc_cb[i] = *res_cb;
>> -*res_cb = tmp_cb;
>>   ring->desc[i].addr = (__le64)ring->desc_cb[i].dma;
>>   ring->desc[i].rx.ipoff_bnum_pid_flag = 0;
>>   }
>> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c 
>> b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>> index 77c6edb..522b264 100644
>> --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
>> @@ -341,7 +341,6 @@ void hns_ae_toggle_ring_irq(struct hnae_ring *ring, u32 
>> mask)
>>   else
>>   flag = RCB_INT_FLAG_RX;
>>
>> -hns_rcb_int_clr_hw(ring->q, flag);
>>   hns_rcb_int_ctrl_hw(ring->q, flag, mask);
>>   }
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c 
>> b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
>> index cad2663..e2be510 100644
>> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
>> @@ -33,6 +33,7 @@
>>
>>   #define RCB_IRQ_NOT_INITED 0
>>   #define RCB_IRQ_INITED 1
>> +#define HNS_BUFFER_SIZE_2048 2048
>>
>>   #define BD_MAX_SEND_SIZE 8191
>>   #define SKB_TMP_LEN(SKB) \
>> @@ -491,13 +492,51 @@ static unsigned int hns_nic_get_headlen(unsigned char 
>> *data, u32 flag,
>>   return max_size;
>>   }
>>
>> -static void
>> -hns_nic_reuse_page(struct hnae_desc_cb *desc_cb, int tsize, int last_offset)
>> +static void hns_nic_reuse_page(struct sk_buff *skb, int i,
>> +   struct hnae_ring *ring, int pull_len,
>> +   struct hnae_desc_cb *desc_cb)
>>   {
>> +struct hnae_desc *desc;
>> +int truesize, size;
>> +int last_offset = 0;
>> +
>> +desc = &ring->desc[ring->next_to_clean];
>> +size = le16_to_cpu(desc->rx.size);
>> +
>> +#if (PAGE_SIZE < 8192)
>> +if (hnae_buf_size(ring) == HNS_BUFFER_SIZE_2048) {
>> +truesize = hnae_buf_size(ring);
>> +} else {
>> +truesize = ALIGN(size, L1_CACHE_BYTES);
>> +last_offset = hnae_page_size(ring) - hnae_buf_size(ring);
>> +}
>> +
>> +#else
>> +truesize = ALIGN(size, L1_CACHE_BYTES);
>> +last_offset = hnae_page_size(ring) - hnae_buf_size(ring);
>> +#endif
>> +
>> +skb_add_rx_frag(skb, i, desc_cb->priv, desc_cb->page_offset + pull_len,
>> +size - pull_len, truesize - pull_len);
>> +
>>/* avoid re-using remote pages,flag default unreuse */
>>   if (likely(page_to_nid(desc_cb->priv) == numa_node_id())) {
>> +#if (PAGE_SIZE < 8192)
>> +if (hnae_buf_size(ring) == HNS_BUFFER_SIZE_2048) {
>> +/* if we are only owner of page we can reu

Re: [PATCH RESEND net-next 3/3] arm64: hip05-d02: Document devicetree bindings for Hisilicon D02 Board

2015-12-07 Thread Yankejian (Hackim Yim)


On 2015/12/7 21:48, Bintian wrote:
> On 2015/12/7 21:16, Rob Herring wrote:
>> On Sat, Dec 05, 2015 at 03:54:48PM +0800, yankejian wrote:
>>> This patch adds documentation for the devicetree bindings used by the
>>> DT files of Hisilicon Hip05-D02 development board.
>>>
>>> Signed-off-by: yankejian 
> You may need to configure as  "Kejian Yan " :)
>
> BR,
>
> Bintian

agree, thanks

BR,
Kejian Yan

>>> ---
>>>   .../devicetree/bindings/arm/hisilicon/hisilicon.txt  | 16 
>>> 
>>>   1 file changed, 16 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt 
>>> b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
>>> index 6ac7c00..5318d78 100644
>>> --- a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
>>> +++ b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
>>> @@ -187,6 +187,22 @@ Example:
>>>   reg = <0xb000 0x1>;
>>>   };
>>>   +Hisilicon HiP05 PERISUB system controller
>>> +
>>> +Required properties:
>>> +- compatible : "hisilicon,peri-c-subctrl", "syscon";
>> This should be more specific and have the SOC name in it.
>>
>>> +- reg : Register address and size
>>> +
>>> +The HiP05 PERISUB system controller is shared by peripheral controllers in
>>> +HiP05 Soc to implement some basic configurations. the peripheral
>>> + controllers include mdio, ddr, iic, uart, timer and so on.
>>> +
>>> +Example:
>>> +/* for HiP05 PCIe-SAS system */
>>> +pcie_sas: system_controller@0xb000 {
>>> +compatible = "hisilicon,pcie-sas-subctrl", "syscon";
>> The example doesn't match.
>>
Thanks for this. I have changed this in PATCH V2 already floated.

BR
Kejian Yan
>>> +reg = <0xb000 0x1>;
>>> +};
>>>   ---
>>>   Hisilicon CPU controller
>>>   -- 
>>> 1.9.1
>>>
>>> -- 
>>> To unsubscribe from this list: send the line "unsubscribe devicetree" in
>>> the body of a message to majord...@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> -- 
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>>
>> .
>>
>
>
>
> .
>


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


Re: [PATCH net-next] net: hns: optimize XGE capability by reducing cpu usage

2015-12-07 Thread Yankejian (Hackim Yim)


On 2015/12/7 17:05, Joe Perches wrote:
> On Mon, 2015-12-07 at 16:58 +0800, Yankejian (Hackim Yim) wrote:
>> On 2015/12/7 11:32, Joe Perches wrote:
>>> On Sun, 2015-12-06 at 22:29 -0500, David Miller wrote:
>>>>> From: yankejian 
>>>>> Date: Sat, 5 Dec 2015 15:32:29 +0800
>>>>>
>>>>>>> +#if (PAGE_SIZE < 8192)
>>>>>>> + if (hnae_buf_size(ring) == HNS_BUFFER_SIZE_2048) {
>>>>>>> + truesize = hnae_buf_size(ring);
>>>>>>> + } else {
>>>>>>> + truesize = ALIGN(size, L1_CACHE_BYTES);
>>>>>>> + last_offset = hnae_page_size(ring) - hnae_buf_size(ring);
>>>>>>> + }
>>>>>>> +
>>>>>>> +#else
>>>>>>> + truesize = ALIGN(size, L1_CACHE_BYTES);
>>>>>>> + last_offset = hnae_page_size(ring) - hnae_buf_size(ring);
>>>>>>> +#endif
>>>>> This is not indented properly, and it looks terrible.
>>> And it makes one curious as to why last_offset isn't set
>>> in the first block.
>> Hi Joe,
> Hello.
>
>> if hnae_buf_size que equal to HNS_BUFFER_SIZE, last_offset is useless in the 
>> routines of this function.
>> so it is ignored in the first block. thanks for your suggestion.
> More to the point, last_offset is initialized to 0.
>
> It'd be clearer not to initialize it at all and
thanks, that is a good idea.

> set it to 0 in the first block and not overwrite
> the initialization in each subsequent block.
because it is useless, i think we'd better ignored it.

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


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


Re: [PATCH net-next] net: hns: optimize XGE capability by reducing cpu usage

2015-12-07 Thread Yankejian (Hackim Yim)

On 2015/12/7 11:32, Joe Perches wrote:
> On Sun, 2015-12-06 at 22:29 -0500, David Miller wrote:
>> > From: yankejian 
>> > Date: Sat, 5 Dec 2015 15:32:29 +0800
>> > 
>>> > > +#if (PAGE_SIZE < 8192)
>>> > > + if (hnae_buf_size(ring) == HNS_BUFFER_SIZE_2048) {
>>> > > + truesize = hnae_buf_size(ring);
>>> > > + } else {
>>> > > + truesize = ALIGN(size, L1_CACHE_BYTES);
>>> > > + last_offset = hnae_page_size(ring) - hnae_buf_size(ring);
>>> > > + }
>>> > > +
>>> > > +#else
>>> > > + truesize = ALIGN(size, L1_CACHE_BYTES);
>>> > > + last_offset = hnae_page_size(ring) - hnae_buf_size(ring);
>>> > > +#endif
>> > 
>> > This is not indented properly, and it looks terrible.
> And it makes one curious as to why last_offset isn't set
> in the first block.

Hi Joe,
if hnae_buf_size que equal to HNS_BUFFER_SIZE, last_offset is useless in the 
routines of this function.
so it is ignored in the first block. thanks for your suggestion.

Best regards,
yankejian


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


Re: [PATCH net-next] net: hns: optimize XGE capability by reducing cpu usage

2015-12-07 Thread Yankejian (Hackim Yim)


On 2015/12/7 11:29, David Miller wrote:
> From: yankejian 
> Date: Sat, 5 Dec 2015 15:32:29 +0800
>
>> +#if (PAGE_SIZE < 8192)
>> +if (hnae_buf_size(ring) == HNS_BUFFER_SIZE_2048) {
>> +truesize = hnae_buf_size(ring);
>> +} else {
>> +truesize = ALIGN(size, L1_CACHE_BYTES);
>> +last_offset = hnae_page_size(ring) - hnae_buf_size(ring);
>> +}
>> +
>> +#else
>> +truesize = ALIGN(size, L1_CACHE_BYTES);
>> +last_offset = hnae_page_size(ring) - hnae_buf_size(ring);
>> +#endif
> This is not indented properly, and it looks terrible.
>
> .
>
Hi David,
Thanks for pointing it out. i will pay attention next time.

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


[PATCH v2 next 0/2] dts: hisi: fixes no syscon error when init mdio

2015-12-07 Thread yankejian
this patchset fixes the bug that eth can't initial successful on hip05-D02
because the dts files doesn't match the source code.

yankejian (2):
  dts: hisi: fixes no syscon error when init mdio
  net: hns: fixes no syscon error when init mdio

---
change log:
v2:
 1) update the related documented in the binding as well
 2) use the normal naming conventions using '-' instead of '_', and
update the related *.c files.

v1:
 initial version

 .../devicetree/bindings/arm/hisilicon/hisilicon.txt  | 16 
 arch/arm64/boot/dts/hisilicon/hip05.dtsi |  5 +
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi |  4 ++--
 drivers/net/ethernet/hisilicon/hns_mdio.c|  2 +-
 4 files changed, 24 insertions(+), 3 deletions(-)

-- 
1.9.1

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


[PATCH v2 next 1/2] dts: hisi: fixes no syscon error when init mdio

2015-12-07 Thread yankejian
Signed-nux start up, we get the log below:
"Hi-HNS_MDIO 803c.mdio: no syscon hisilicon,peri-c-subctrl
 mdio_bus mdio@803c: mdio sys ctl reg has not maped   "

the source code about the subctrl is dealled with syscon, but dts doesn't.
it cause such fault. so this patch adds the syscon info on dts files to
fixes it. and it adds documentation for the devicetree bindings used by
DT files of Hisilicon Hip05-D02 development board.

Signed-off-by: yankejian 
---
change log:
v2:
 1) updates the related documented in the binding as well
 2) use the normal naming conventions using '-' instead of '_'

v1:
 initial version
---
 .../devicetree/bindings/arm/hisilicon/hisilicon.txt  | 16 
 arch/arm64/boot/dts/hisilicon/hip05.dtsi |  5 +
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi |  4 ++--
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt 
b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
index 6ac7c00..9f05767 100644
--- a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
+++ b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
@@ -187,6 +187,22 @@ Example:
reg = <0xb000 0x1>;
};
 
+Hisilicon HiP05 PERISUB system controller
+
+Required properties:
+- compatible : "hisilicon,peri-c-subctrl", "syscon";
+- reg : Register address and size
+
+The HiP05 PERISUB system controller is shared by peripheral controllers in
+HiP05 Soc to implement some basic configurations. the peripheral
+controllers include mdio, ddr, iic, uart, timer and so on.
+
+Example:
+   /* for HiP05 PCIe-SAS system */
+   peri-c-subctrl: sub-ctrl-c@8000 {
+   compatible = "hisilicon,peri-c-subctrl", "syscon";
+   reg = <0x0 0x8000 0x0 0x1>;
+   };
 ---
 Hisilicon CPU controller
 
diff --git a/arch/arm64/boot/dts/hisilicon/hip05.dtsi 
b/arch/arm64/boot/dts/hisilicon/hip05.dtsi
index 4ff16d0..5fec740 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05.dtsi
@@ -246,6 +246,11 @@
clock-frequency = <2>;
};
 
+   peri_c_subctrl: sub-ctrl-c@8000 {
+   compatible = "hisilicon,peri-c-subctrl", "syscon";
+   reg = < 0x0 0x8000 0x0 0x1>;
+   };
+
uart0: uart@8030 {
compatible = "snps,dw-apb-uart";
reg = <0x0 0x8030 0x0 0x1>;
diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi 
b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
index 606dd5a..da7b6e6 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
@@ -10,8 +10,8 @@ soc0: soc@0 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "hisilicon,hns-mdio";
-   reg = <0x0 0x803c 0x0 0x1
-  0x0 0x8000 0x0 0x1>;
+   reg = <0x0 0x803c 0x0 0x1>;
+   subctrl-vbase = <&peri_c_subctrl>;
 
soc0_phy0: ethernet-phy@0 {
reg = <0x0>;
-- 
1.9.1

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


[PATCH v2 next 2/2] net: hns: fixes no syscon error when init mdio

2015-12-07 Thread yankejian
as dtsi files use the normal naming conventions using '-' instead of '_'
inside of property names, the driver needs to update the phandle name
strings of the of_parse_phandle func.

Signed-off-by: yankejian 
---
 drivers/net/ethernet/hisilicon/hns_mdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns_mdio.c 
b/drivers/net/ethernet/hisilicon/hns_mdio.c
index 37491c8..1e07e91 100644
--- a/drivers/net/ethernet/hisilicon/hns_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hns_mdio.c
@@ -458,7 +458,7 @@ static int hns_mdio_probe(struct platform_device *pdev)
}
 
mdio_dev->subctrl_vbase =
-   syscon_node_to_regmap(of_parse_phandle(np, "subctrl_vbase", 0));
+   syscon_node_to_regmap(of_parse_phandle(np, "subctrl-vbase", 0));
if (IS_ERR(mdio_dev->subctrl_vbase)) {
dev_warn(&pdev->dev, "no syscon hisilicon,peri-c-subctrl\n");
mdio_dev->subctrl_vbase = NULL;
-- 
1.9.1

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


Re: [PATCH net-next 2/2] net: hns: enet specisies a reference to dsaf (config and documents)

2015-12-06 Thread Yankejian (Hackim Yim)


On 2015/12/6 6:19, Arnd Bergmann wrote:
> On Saturday 05 December 2015 14:10:56 yankejian wrote:
>> 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@c700 {
>> +dsaf0: dsa@c700 {
>> compatible = "hisilicon,hns-dsaf-v1";
>> -   dsa_name = "dsaf0";
>> mode = "6port-16rss";
>> interrupt-parent = <&mbigen_dsa>;
>> reg = <0x0 0xC000 0x0 0x42
>> 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:
>>  
>>
> This looks like an incompatible change, as you add and remove
> required properties. Is there a way to support both the old and
> the new style?
>
>   Arnd
>
> .

Hi Arnd,
Thanks for your suggestions.  it must be set the same strings in dsaf node and 
every enet node before.
it seems inappropriate. as Rob Herring  's suggestions, that 
would solve associating
enet with a particular dsaf. so we discus the solution with Yisen Zhuang 
.
we decide to use the new way instead of the old one.

Best regards,
yankejian

>


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


Re: [PATCH RESEND net-next 2/3] dts: hisi: fixes no syscon error when init mdio

2015-12-06 Thread Yankejian (Hackim Yim)


On 2015/12/6 6:15, Arnd Bergmann wrote:
> On Saturday 05 December 2015 15:56:57 yankejian wrote:
>> #size-cells = <0>;
>> compatible = "hisilicon,hns-mdio";
>> -   reg = <0x0 0x803c 0x0 0x1
>> -  0x0 0x8000 0x0 0x1>;
>> +   reg = <0x0 0x803c 0x0 0x1>;
>> +   subctrl_vbase = <&peri_c_subctrl>;
>>  
>> soc0_phy0: ethernet-phy@0 {
>> reg = <0x0>;
> I don't see the subctrl_vbase property documented in the binding. Please
> modify the binding as well.
>
> Also, please use the normal naming conventions using '-' instead of '_'
> inside of property names.
>
>   Arnd
>
> .

Hi, Arnd
Thanks for your suggestions. i will fixes it later.


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


Re: [PATCH RESEND net-next 3/3] arm64: hip05-d02: Document devicetree bindings for Hisilicon D02 Board

2015-12-06 Thread Yankejian (Hackim Yim)


On 2015/12/6 6:13, Arnd Bergmann wrote:
> On Saturday 05 December 2015 15:56:58 yankejian wrote:
>> +Required properties:
>> +- compatible : "hisilicon,peri-c-subctrl", "syscon";
>> +- reg : Register address and size
>> +
>> +The HiP05 PERISUB system controller is shared by peripheral controllers in
>> +HiP05 Soc to implement some basic configurations. the peripheral
>> + controllers include mdio, ddr, iic, uart, timer and so on.
>> +
>> +Example:
>> +   /* for HiP05 PCIe-SAS system */
>> +   pcie_sas: system_controller@0xb000 {
>> +   compatible = "hisilicon,pcie-sas-subctrl", "syscon";
>> +   reg = <0xb000 0x1>;
>> +   };
>>
> The compatible string in the example does not match the required properties.
>
>   Arnd
>
> .
Hi, Arnd
Thanks for your suggestions. i will fixes it later.



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


[PATCH RESEND net-next 3/3] arm64: hip05-d02: Document devicetree bindings for Hisilicon D02 Board

2015-12-04 Thread yankejian
This patch adds documentation for the devicetree bindings used by the
DT files of Hisilicon Hip05-D02 development board.

Signed-off-by: yankejian 
---
 .../devicetree/bindings/arm/hisilicon/hisilicon.txt  | 16 
 1 file changed, 16 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt 
b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
index 6ac7c00..5318d78 100644
--- a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
+++ b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
@@ -187,6 +187,22 @@ Example:
reg = <0xb000 0x1>;
};
 
+Hisilicon HiP05 PERISUB system controller
+
+Required properties:
+- compatible : "hisilicon,peri-c-subctrl", "syscon";
+- reg : Register address and size
+
+The HiP05 PERISUB system controller is shared by peripheral controllers in
+HiP05 Soc to implement some basic configurations. the peripheral
+ controllers include mdio, ddr, iic, uart, timer and so on.
+
+Example:
+   /* for HiP05 PCIe-SAS system */
+   pcie_sas: system_controller@0xb000 {
+   compatible = "hisilicon,pcie-sas-subctrl", "syscon";
+   reg = <0xb000 0x1>;
+   };
 ---
 Hisilicon CPU controller
 
-- 
1.9.1

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


[PATCH net-next 1/2] net: hns: enet specisies a reference to dsaf

2015-12-04 Thread yankejian
enet is associating with dasf. before this patch, the association is
the same strings between ae-name and dsa-name. in a general way, enet
specifies a reference to dsaf should be a good idea. so this patch
deletes the ae-name in enet, and adds parsing the ae-handle
from DT to set the associating with dsaf.

Signed-off-by: yankejian 
---
 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 +-
 7 files changed, 28 insertions(+), 26 deletions(-)

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 d1f3316..0012664 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -523,8 +523,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 77c6edb..ed9a72c 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -848,6 +848,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:
@@ -859,6 +860,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 636b205..f3de749 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_g

Re: [PATCH RESEND net-next 0/3] dts: hisi: fixes can't find eth for hip05-D02

2015-12-04 Thread Yankejian (Hackim Yim)
sorry, pls ignore this patchset.

On 2015/12/5 15:54, yankejian wrote:
> this patchset fixes the bug that eth can't initial successful on hip05-D02
> because the dts files doesn't match the source code.
>
> yankejian (3):
>   dts: hisi: enables the ethX for D02 board
>   dts: hisi: fixes no syscon error when init mdio
>   arm64: hip05-d02: Document devicetree bindings for Hisilicon D02 Board
>
>  .../devicetree/bindings/arm/hisilicon/hisilicon.txt  | 16 
> 
>  arch/arm64/boot/dts/hisilicon/hip05-d02.dts  | 16 
> 
>  arch/arm64/boot/dts/hisilicon/hip05.dtsi |  4 
>  arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi |  4 ++--
>  4 files changed, 38 insertions(+), 2 deletions(-)
>


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


[PATCH net-next 0/2] net: hns: enet specisies a reference to dsaf

2015-12-04 Thread yankejian
in this patchset, enet specifies a reference to dsaf. and delete the 
ae-name in enet, and adds parsing the ae-handle from DT to set the 
associating with dsaf.
the patchset updates the dtsi and bindings documents as well.

yankejian (2):
  net: hns: enet specisies a reference to dsaf
  net: hns: enet specisies a reference to dsaf (config and documents)

 .../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(-)

-- 
1.9.1

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


[PATCH net-next 2/2] net: hns: enet specisies a reference to dsaf (config and documents)

2015-12-04 Thread yankejian
when enet specisies a reference to dsaf, the correlative config and
documents needs to update. this patch updates the correlative dtsi file
and bindings documents .

Signed-off-by: yankejian 
---
 .../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 +--
 3 files changed, 14 insertions(+), 17 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@c700 {
+dsaf0: dsa@c700 {
compatible = "hisilicon,hns-dsaf-v1";
-   dsa_name = "dsaf0";
mode = "6port-16rss";
interrupt-parent = <&mbigen_dsa>;
reg = <0x0 0xC000 0x0 0x42
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@0 {
};
};
 
-   dsa: dsa@c700 {
+   dsaf0: dsa@c700 {
compatible = "hisilicon,hns-dsaf-v1";
-   dsa_name = "dsaf0";
mode = "6port-16rss";
interrupt-parent = <&mbigen_dsa>;
 
@@ -127,7 +126,7 @@ soc0: soc@0 {
 
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@0 {
};
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@0 {
};
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 @@ so

[PATCH RESEND net-next 1/3] dts: hisi: enables the ethX for D02 board

2015-12-04 Thread yankejian
this patch enables the ethX for D02 board on hip05-d02.dts. otherwise it
cannot find hns ethX by ifconfig -a.

Signed-off-by: yankejian 
---
 arch/arm64/boot/dts/hisilicon/hip05-d02.dts | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hip05-d02.dts 
b/arch/arm64/boot/dts/hisilicon/hip05-d02.dts
index ae34e25..6aa5cb2 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05-d02.dts
+++ b/arch/arm64/boot/dts/hisilicon/hip05-d02.dts
@@ -34,3 +34,19 @@
 &uart0 {
status = "ok";
 };
+
+ð2 {
+   status = "okay";
+};
+
+ð3 {
+   status = "okay";
+};
+
+ð6 {
+   status = "okay";
+};
+
+ð7 {
+   status = "okay";
+};
-- 
1.9.1

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


[PATCH RESEND net-next 2/3] dts: hisi: fixes no syscon error when init mdio

2015-12-04 Thread yankejian
when linux start up, we get the log below:
"Hi-HNS_MDIO 803c.mdio: no syscon hisilicon,peri-c-subctrl
 mdio_bus mdio@803c: mdio sys ctl reg has not maped   "

the source code about the subctrl is dealled with syscon, but dts doesn't.
it cause such fault. so this patch adds the syscon info on dts files to
fixes it.

Signed-off-by: yankejian 
---
 arch/arm64/boot/dts/hisilicon/hip05.dtsi | 4 
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/hisilicon/hip05.dtsi 
b/arch/arm64/boot/dts/hisilicon/hip05.dtsi
index 4ff16d0..daaca63 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05.dtsi
@@ -246,6 +246,10 @@
clock-frequency = <2>;
};
 
+   peri_c_subctrl: sub_ctrl_c@8000 {
+   compatible = "hisilicon,peri-c-subctrl", "syscon";
+   reg = < 0x0 0x8000 0x0 0x1>;
+   };
uart0: uart@8030 {
compatible = "snps,dw-apb-uart";
reg = <0x0 0x8030 0x0 0x1>;
diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi 
b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
index 606dd5a..4d4815e 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
@@ -10,8 +10,8 @@ soc0: soc@0 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "hisilicon,hns-mdio";
-   reg = <0x0 0x803c 0x0 0x1
-  0x0 0x8000 0x0 0x1>;
+   reg = <0x0 0x803c 0x0 0x1>;
+   subctrl_vbase = <&peri_c_subctrl>;
 
soc0_phy0: ethernet-phy@0 {
reg = <0x0>;
-- 
1.9.1

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


[PATCH RESEND net-next 0/3] dts: hisi: fixes can't find eth for hip05-D02

2015-12-04 Thread yankejian
this patchset fixes the bug that eth can't initial successful on hip05-D02
because the dts files doesn't match the source code.

yankejian (3):
  dts: hisi: enables the ethX for D02 board
  dts: hisi: fixes no syscon error when init mdio
  arm64: hip05-d02: Document devicetree bindings for Hisilicon D02 Board

 .../devicetree/bindings/arm/hisilicon/hisilicon.txt  | 16 
 arch/arm64/boot/dts/hisilicon/hip05-d02.dts  | 16 
 arch/arm64/boot/dts/hisilicon/hip05.dtsi |  4 
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi |  4 ++--
 4 files changed, 38 insertions(+), 2 deletions(-)

-- 
1.9.1

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


[PATCH RESEND net-next 2/3] dts: hisi: fixes no syscon error when init mdio

2015-12-04 Thread yankejian
when linux start up, we get the log below:
"Hi-HNS_MDIO 803c.mdio: no syscon hisilicon,peri-c-subctrl
 mdio_bus mdio@803c: mdio sys ctl reg has not maped   "

the source code about the subctrl is dealled with syscon, but dts doesn't.
it cause such fault. so this patch adds the syscon info on dts files to
fixes it.

Signed-off-by: yankejian 
---
 arch/arm64/boot/dts/hisilicon/hip05.dtsi | 4 
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/hisilicon/hip05.dtsi 
b/arch/arm64/boot/dts/hisilicon/hip05.dtsi
index 4ff16d0..daaca63 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05.dtsi
@@ -246,6 +246,10 @@
clock-frequency = <2>;
};
 
+   peri_c_subctrl: sub_ctrl_c@8000 {
+   compatible = "hisilicon,peri-c-subctrl", "syscon";
+   reg = < 0x0 0x8000 0x0 0x1>;
+   };
uart0: uart@8030 {
compatible = "snps,dw-apb-uart";
reg = <0x0 0x8030 0x0 0x1>;
diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi 
b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
index 606dd5a..4d4815e 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
@@ -10,8 +10,8 @@ soc0: soc@0 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "hisilicon,hns-mdio";
-   reg = <0x0 0x803c 0x0 0x1
-  0x0 0x8000 0x0 0x1>;
+   reg = <0x0 0x803c 0x0 0x1>;
+   subctrl_vbase = <&peri_c_subctrl>;
 
soc0_phy0: ethernet-phy@0 {
reg = <0x0>;
-- 
1.9.1

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


[PATCH RESEND net-next 3/3] arm64: hip05-d02: Document devicetree bindings for Hisilicon D02 Board

2015-12-04 Thread yankejian
This patch adds documentation for the devicetree bindings used by the
DT files of Hisilicon Hip05-D02 development board.

Signed-off-by: yankejian 
---
 .../devicetree/bindings/arm/hisilicon/hisilicon.txt  | 16 
 1 file changed, 16 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt 
b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
index 6ac7c00..5318d78 100644
--- a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
+++ b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
@@ -187,6 +187,22 @@ Example:
reg = <0xb000 0x1>;
};
 
+Hisilicon HiP05 PERISUB system controller
+
+Required properties:
+- compatible : "hisilicon,peri-c-subctrl", "syscon";
+- reg : Register address and size
+
+The HiP05 PERISUB system controller is shared by peripheral controllers in
+HiP05 Soc to implement some basic configurations. the peripheral
+ controllers include mdio, ddr, iic, uart, timer and so on.
+
+Example:
+   /* for HiP05 PCIe-SAS system */
+   pcie_sas: system_controller@0xb000 {
+   compatible = "hisilicon,pcie-sas-subctrl", "syscon";
+   reg = <0xb000 0x1>;
+   };
 ---
 Hisilicon CPU controller
 
-- 
1.9.1

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


[PATCH RESEND net-next 0/3] dts: hisi: fixes can't find eth for hip05-D02

2015-12-04 Thread yankejian
this patchset fixes the bug that eth can't initial successful on hip05-D02
because the dts files doesn't match the source code.

yankejian (3):
  dts: hisi: enables the ethX for D02 board
  dts: hisi: fixes no syscon error when init mdio
  arm64: hip05-d02: Document devicetree bindings for Hisilicon D02 Board

 .../devicetree/bindings/arm/hisilicon/hisilicon.txt  | 16 
 arch/arm64/boot/dts/hisilicon/hip05-d02.dts  | 16 
 arch/arm64/boot/dts/hisilicon/hip05.dtsi |  4 
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi |  4 ++--
 4 files changed, 38 insertions(+), 2 deletions(-)

-- 
1.9.1

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


[PATCH RESEND net-next 1/3] dts: hisi: enables the ethX for D02 board

2015-12-04 Thread yankejian
this patch enables the ethX for D02 board on hip05-d02.dts. otherwise it
cannot find hns ethX by ifconfig -a.

Signed-off-by: yankejian 
---
 arch/arm64/boot/dts/hisilicon/hip05-d02.dts | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hip05-d02.dts 
b/arch/arm64/boot/dts/hisilicon/hip05-d02.dts
index ae34e25..6aa5cb2 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05-d02.dts
+++ b/arch/arm64/boot/dts/hisilicon/hip05-d02.dts
@@ -34,3 +34,19 @@
 &uart0 {
status = "ok";
 };
+
+ð2 {
+   status = "okay";
+};
+
+ð3 {
+   status = "okay";
+};
+
+ð6 {
+   status = "okay";
+};
+
+ð7 {
+   status = "okay";
+};
-- 
1.9.1

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


[PATCH net-next] net: hns: optimize XGE capability by reducing cpu usage

2015-12-04 Thread yankejian
here is the patch raising the performance of XGE by:
1)changes the way page management method for enet momery, and
2)reduces the count of rmb, and
3)adds Memory prefetching

Signed-off-by: yankejian 
---
 drivers/net/ethernet/hisilicon/hns/hnae.h |  5 +-
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c |  1 -
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 79 +++
 3 files changed, 55 insertions(+), 30 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h 
b/drivers/net/ethernet/hisilicon/hns/hnae.h
index d1f3316..6ca94dc 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -341,7 +341,8 @@ struct hnae_queue {
void __iomem *io_base;
phys_addr_t phy_base;
struct hnae_ae_dev *dev;/* the device who use this queue */
-   struct hnae_ring rx_ring, tx_ring;
+   struct hnae_ring rx_ring cacheline_internodealigned_in_smp;
+   struct hnae_ring tx_ring cacheline_internodealigned_in_smp;
struct hnae_handle *handle;
 };
 
@@ -597,11 +598,9 @@ static inline void hnae_replace_buffer(struct hnae_ring 
*ring, int i,
   struct hnae_desc_cb *res_cb)
 {
struct hnae_buf_ops *bops = ring->q->handle->bops;
-   struct hnae_desc_cb tmp_cb = ring->desc_cb[i];
 
bops->unmap_buffer(ring, &ring->desc_cb[i]);
ring->desc_cb[i] = *res_cb;
-   *res_cb = tmp_cb;
ring->desc[i].addr = (__le64)ring->desc_cb[i].dma;
ring->desc[i].rx.ipoff_bnum_pid_flag = 0;
 }
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c 
b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index 77c6edb..522b264 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -341,7 +341,6 @@ void hns_ae_toggle_ring_irq(struct hnae_ring *ring, u32 
mask)
else
flag = RCB_INT_FLAG_RX;
 
-   hns_rcb_int_clr_hw(ring->q, flag);
hns_rcb_int_ctrl_hw(ring->q, flag, mask);
 }
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c 
b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index cad2663..e2be510 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -33,6 +33,7 @@
 
 #define RCB_IRQ_NOT_INITED 0
 #define RCB_IRQ_INITED 1
+#define HNS_BUFFER_SIZE_2048 2048
 
 #define BD_MAX_SEND_SIZE 8191
 #define SKB_TMP_LEN(SKB) \
@@ -491,13 +492,51 @@ static unsigned int hns_nic_get_headlen(unsigned char 
*data, u32 flag,
return max_size;
 }
 
-static void
-hns_nic_reuse_page(struct hnae_desc_cb *desc_cb, int tsize, int last_offset)
+static void hns_nic_reuse_page(struct sk_buff *skb, int i,
+  struct hnae_ring *ring, int pull_len,
+  struct hnae_desc_cb *desc_cb)
 {
+   struct hnae_desc *desc;
+   int truesize, size;
+   int last_offset = 0;
+
+   desc = &ring->desc[ring->next_to_clean];
+   size = le16_to_cpu(desc->rx.size);
+
+#if (PAGE_SIZE < 8192)
+   if (hnae_buf_size(ring) == HNS_BUFFER_SIZE_2048) {
+   truesize = hnae_buf_size(ring);
+   } else {
+   truesize = ALIGN(size, L1_CACHE_BYTES);
+   last_offset = hnae_page_size(ring) - hnae_buf_size(ring);
+   }
+
+#else
+   truesize = ALIGN(size, L1_CACHE_BYTES);
+   last_offset = hnae_page_size(ring) - hnae_buf_size(ring);
+#endif
+
+   skb_add_rx_frag(skb, i, desc_cb->priv, desc_cb->page_offset + pull_len,
+   size - pull_len, truesize - pull_len);
+
 /* avoid re-using remote pages,flag default unreuse */
if (likely(page_to_nid(desc_cb->priv) == numa_node_id())) {
+#if (PAGE_SIZE < 8192)
+   if (hnae_buf_size(ring) == HNS_BUFFER_SIZE_2048) {
+   /* if we are only owner of page we can reuse it */
+   if (likely(page_count(desc_cb->priv) == 1)) {
+   /* flip page offset to other buffer */
+   desc_cb->page_offset ^= truesize;
+
+   desc_cb->reuse_flag = 1;
+   /* bump ref count on page before it is given*/
+   get_page(desc_cb->priv);
+   }
+   return;
+   }
+#endif
/* move offset up to the next cache line */
-   desc_cb->page_offset += tsize;
+   desc_cb->page_offset += truesize;
 
if (desc_cb->page_offset <= last_offset) {
desc_cb->reuse_flag = 1;
@@ -529,11 +568,10 @@ static int hns_nic_poll_rx_skb(struct hns_nic_ring_data 
*ring_data,
struct hnae_desc *desc;
struct hnae_desc_cb *desc_cb;
  

[PATCH net-next 0/2] net: hns: enet specisies a reference to dsaf

2015-12-04 Thread yankejian
in this patchset, enet specifies a reference to dsaf. and delete the 
ae-name in enet, and adds parsing the ae-handle from DT to set the 
associating with dsaf.
the patchset updates the dtsi and bindings documents as well.

yankejian (2):
  net: hns: enet specisies a reference to dsaf
  net: hns: enet specisies a reference to dsaf (config and documents)

 .../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(-)

-- 
1.9.1

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


[PATCH net-next 1/2] net: hns: enet specisies a reference to dsaf

2015-12-04 Thread yankejian
enet is associating with dasf. before this patch, the association is
the same strings between ae-name and dsa-name. in a general way, enet
specifies a reference to dsaf should be a good idea. so this patch
deletes the ae-name in enet, and adds parsing the ae-handle
from DT to set the associating with dsaf.

Signed-off-by: yankejian 
---
 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 +-
 7 files changed, 28 insertions(+), 26 deletions(-)

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 d1f3316..0012664 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -523,8 +523,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 77c6edb..ed9a72c 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -848,6 +848,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:
@@ -859,6 +860,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 636b205..f3de749 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_g

[PATCH net-next 2/2] net: hns: enet specisies a reference to dsaf (config and documents)

2015-12-04 Thread yankejian
when enet specisies a reference to dsaf, the correlative config and
documents needs to update. this patch updates the correlative dtsi file
and bindings documents .

Signed-off-by: yankejian 
---
 .../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 +--
 3 files changed, 14 insertions(+), 17 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@c700 {
+dsaf0: dsa@c700 {
compatible = "hisilicon,hns-dsaf-v1";
-   dsa_name = "dsaf0";
mode = "6port-16rss";
interrupt-parent = <&mbigen_dsa>;
reg = <0x0 0xC000 0x0 0x42
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@0 {
};
};
 
-   dsa: dsa@c700 {
+   dsaf0: dsa@c700 {
compatible = "hisilicon,hns-dsaf-v1";
-   dsa_name = "dsaf0";
mode = "6port-16rss";
interrupt-parent = <&mbigen_dsa>;
 
@@ -127,7 +126,7 @@ soc0: soc@0 {
 
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@0 {
};
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@0 {
};
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 @@ so

[PATCH net-next 1/3] dts: hisi: enables the ethX for D02 board

2015-11-27 Thread yankejian
this patch enables the ethX for D02 board on hip05-d02.dts. otherwise it
cannot find hns ethX by ifconfig -a.

Signed-off-by: yankejian 
---
 arch/arm64/boot/dts/hisilicon/hip05-d02.dts | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hip05-d02.dts 
b/arch/arm64/boot/dts/hisilicon/hip05-d02.dts
index ae34e25..6aa5cb2 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05-d02.dts
+++ b/arch/arm64/boot/dts/hisilicon/hip05-d02.dts
@@ -34,3 +34,19 @@
 &uart0 {
status = "ok";
 };
+
+ð2 {
+   status = "okay";
+};
+
+ð3 {
+   status = "okay";
+};
+
+ð6 {
+   status = "okay";
+};
+
+ð7 {
+   status = "okay";
+};
-- 
1.9.1

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


[PATCH net-next 2/3] dts: hisi: fixes no syscon error when init mdio

2015-11-27 Thread yankejian
when linux start up, we get the log below:
"Hi-HNS_MDIO 803c.mdio: no syscon hisilicon,peri-c-subctrl
 mdio_bus mdio@803c: mdio sys ctl reg has not maped   "

the source code about the subctrl is dealled with syscon, but dts doesn't.
it cause such fault. so this patch adds the syscon info on dts files to
fixes it.

Signed-off-by: yankejian 
---
 arch/arm64/boot/dts/hisilicon/hip05.dtsi | 4 
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/hisilicon/hip05.dtsi 
b/arch/arm64/boot/dts/hisilicon/hip05.dtsi
index 4ff16d0..daaca63 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05.dtsi
@@ -246,6 +246,10 @@
clock-frequency = <2>;
};
 
+   peri_c_subctrl: sub_ctrl_c@8000 {
+   compatible = "hisilicon,peri-c-subctrl", "syscon";
+   reg = < 0x0 0x8000 0x0 0x1>;
+   };
uart0: uart@8030 {
compatible = "snps,dw-apb-uart";
reg = <0x0 0x8030 0x0 0x1>;
diff --git a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi 
b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
index 606dd5a..4d4815e 100644
--- a/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi
@@ -10,8 +10,8 @@ soc0: soc@0 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "hisilicon,hns-mdio";
-   reg = <0x0 0x803c 0x0 0x1
-  0x0 0x8000 0x0 0x1>;
+   reg = <0x0 0x803c 0x0 0x1>;
+   subctrl_vbase = <&peri_c_subctrl>;
 
soc0_phy0: ethernet-phy@0 {
reg = <0x0>;
-- 
1.9.1

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


[PATCH net-next 0/3] dts: hisi: fixes can't find eth for hip05-D02

2015-11-27 Thread yankejian
this patchset fixes the bug that eth can't initial successful. because the
the dts files doesn't match the source code.

yankejian (3):
  dts: hisi: enables the ethX for D02 board
  dts: hisi: fixes no syscon error when init mdio
  arm64: hip05-d02: Document devicetree bindings for Hisilicon D02 Board

 .../devicetree/bindings/arm/hisilicon/hisilicon.txt  | 16 
 arch/arm64/boot/dts/hisilicon/hip05-d02.dts  | 16 
 arch/arm64/boot/dts/hisilicon/hip05.dtsi |  4 
 arch/arm64/boot/dts/hisilicon/hip05_hns.dtsi |  4 ++--
 4 files changed, 38 insertions(+), 2 deletions(-)

-- 
1.9.1

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


[PATCH] net: hns: fixes the bug tested XGE by ethtool -p

2015-10-27 Thread yankejian
From: Li Peng 

delete action of ETHTOOL_ID_ON/ETHTOOL_ID_OFF in XGE ethtool -p,
so Hardware control the LED state instead of software.

Signed-off-by: Li Peng 
Signed-off-by: Yisen Zhuang 
Signed-off-by: yankejian 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
index d611388..523e9b8 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
@@ -64,17 +64,10 @@ int cpld_set_led_id(struct hns_mac_cb *mac_cb,
switch (status) {
case HNAE_LED_ACTIVE:
mac_cb->cpld_led_value = dsaf_read_b(mac_cb->cpld_vaddr);
-   return 2;
-   case HNAE_LED_ON:
dsaf_set_bit(mac_cb->cpld_led_value, DSAF_LED_ANCHOR_B,
 CPLD_LED_ON_VALUE);
dsaf_write_b(mac_cb->cpld_vaddr, mac_cb->cpld_led_value);
-   break;
-   case HNAE_LED_OFF:
-   dsaf_set_bit(mac_cb->cpld_led_value, DSAF_LED_ANCHOR_B,
-CPLD_LED_DEFAULT_VALUE);
-   dsaf_write_b(mac_cb->cpld_vaddr, mac_cb->cpld_led_value);
-   break;
+   return 2;
case HNAE_LED_INACTIVE:
dsaf_set_bit(mac_cb->cpld_led_value, DSAF_LED_ANCHOR_B,
 CPLD_LED_DEFAULT_VALUE);
-- 
1.9.1

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


[PATCH net-next] net: hisilicon: deals with the sub ctrl by syscon

2015-10-21 Thread yankejian
  the global Soc configuration is treated by syscon, and sub ctrl bus is
Soc bus. it has to be treated by syscon.

Signed-off-by: yankejian 
Signed-off-by: lisheng 
Signed-off-by: lipeng 
---
 drivers/net/ethernet/hisilicon/hns_mdio.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns_mdio.c 
b/drivers/net/ethernet/hisilicon/hns_mdio.c
index e4ec52a..37491c8 100644
--- a/drivers/net/ethernet/hisilicon/hns_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hns_mdio.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -20,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define MDIO_DRV_NAME "Hi-HNS_MDIO"
@@ -36,7 +38,7 @@
 
 struct hns_mdio_device {
void *vbase;/* mdio reg base address */
-   void *sys_vbase;
+   struct regmap *subctrl_vbase;
 };
 
 /* mdio reg */
@@ -155,10 +157,10 @@ static int mdio_sc_cfg_reg_write(struct hns_mdio_device 
*mdio_dev,
u32 time_cnt;
u32 reg_value;
 
-   mdio_write_reg((void *)mdio_dev->sys_vbase, cfg_reg, set_val);
+   regmap_write(mdio_dev->subctrl_vbase, cfg_reg, set_val);
 
for (time_cnt = MDIO_TIMEOUT; time_cnt; time_cnt--) {
-   reg_value = mdio_read_reg((void *)mdio_dev->sys_vbase, st_reg);
+   regmap_read(mdio_dev->subctrl_vbase, st_reg, ®_value);
reg_value &= st_msk;
if ((!!check_st) == (!!reg_value))
break;
@@ -352,7 +354,7 @@ static int hns_mdio_reset(struct mii_bus *bus)
struct hns_mdio_device *mdio_dev = (struct hns_mdio_device *)bus->priv;
int ret;
 
-   if (!mdio_dev->sys_vbase) {
+   if (!mdio_dev->subctrl_vbase) {
dev_err(&bus->dev, "mdio sys ctl reg has not maped\n");
return -ENODEV;
}
@@ -455,13 +457,12 @@ static int hns_mdio_probe(struct platform_device *pdev)
return ret;
}
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-   mdio_dev->sys_vbase = devm_ioremap_resource(&pdev->dev, res);
-   if (IS_ERR(mdio_dev->sys_vbase)) {
-   ret = PTR_ERR(mdio_dev->sys_vbase);
-   return ret;
+   mdio_dev->subctrl_vbase =
+   syscon_node_to_regmap(of_parse_phandle(np, "subctrl_vbase", 0));
+   if (IS_ERR(mdio_dev->subctrl_vbase)) {
+   dev_warn(&pdev->dev, "no syscon hisilicon,peri-c-subctrl\n");
+   mdio_dev->subctrl_vbase = NULL;
}
-
new_bus->irq = devm_kcalloc(&pdev->dev, PHY_MAX_ADDR,
sizeof(int), GFP_KERNEL);
if (!new_bus->irq)
-- 
1.9.1

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


[PATCH net-next 2/2] net: hns: fixes a bug about timeout by pause frame

2015-10-16 Thread yankejian
From: lisheng 

this patch fixes the bug triggered timeout sequence. when the connective
ports cannot accept the packets with higher speed, they will send out the
pause frame to the Soc's mac. At that time, the driver resets the relevant
of the Soc, then it causes the packets cannot be sent out immediately.
this patch fixes the issue.

Signed-off-by: yankejian 
Signed-off-by: Yisen Zhuang 
Signed-off-by: lisheng 
Signed-off-by: lipeng 
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c 
b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 6f9091c..302d3ae 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -1315,16 +1315,15 @@ static void hns_nic_reset_subtask(struct hns_nic_priv 
*priv)
return;
 
hns_nic_dump(priv);
-   netdev_err(priv->netdev, "Reset %s port\n",
-  (type == HNAE_PORT_DEBUG ? "debug" : "business"));
+   netdev_info(priv->netdev, "Reset %s port\n",
+   (type == HNAE_PORT_DEBUG ? "debug" : "business"));
 
rtnl_lock();
-   if (type == HNAE_PORT_DEBUG) {
+   /* put off any impending NetWatchDogTimeout */
+   priv->netdev->trans_start = jiffies;
+
+   if (type == HNAE_PORT_DEBUG)
hns_nic_net_reinit(priv->netdev);
-   } else {
-   hns_nic_net_down(priv->netdev);
-   hns_nic_net_reset(priv->netdev);
-   }
rtnl_unlock();
 }
 
-- 
1.9.1

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


[PATCH net-next 1/2] net: hns: fixes the issue by using ethtool -s

2015-10-16 Thread yankejian
From: Chenny Xu 

  before this patch, hns driver only permits user to set the net device
by using ethtool -s when the device is link up. it is obviously not so
good. it needs to be set no matter it is link up or down. so this patch
fixes this issue.

Signed-off-by: yankejian 
Signed-off-by: Yisen Zhuang 
Signed-off-by: lisheng 
Signed-off-by: lipeng 
Signed-off-by: Chenny Xu 
---
 drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 39 
 1 file changed, 12 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c 
b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
index 2550208..e31c10b 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
@@ -194,9 +194,7 @@ static int hns_nic_set_settings(struct net_device *net_dev,
 {
struct hns_nic_priv *priv = netdev_priv(net_dev);
struct hnae_handle *h;
-   int link_stat;
u32 speed;
-   u8 duplex, autoneg;
 
if (!netif_running(net_dev))
return -ESRCH;
@@ -206,48 +204,35 @@ static int hns_nic_set_settings(struct net_device 
*net_dev,
return -ENODEV;
 
h = priv->ae_handle;
-   link_stat = hns_nic_get_link(net_dev);
-   duplex = cmd->duplex;
speed = ethtool_cmd_speed(cmd);
-   autoneg = cmd->autoneg;
-
-   if (!link_stat) {
-   if (duplex != (u8)DUPLEX_UNKNOWN || speed != (u32)SPEED_UNKNOWN)
-   return -EINVAL;
-
-   if (h->phy_if == PHY_INTERFACE_MODE_SGMII && h->phy_node) {
-   priv->phy->autoneg = autoneg;
-   return phy_start_aneg(priv->phy);
-   }
-   }
 
if (h->phy_if == PHY_INTERFACE_MODE_XGMII) {
-   if (autoneg != AUTONEG_DISABLE)
-   return -EINVAL;
-
-   if (speed != SPEED_1 || duplex != DUPLEX_FULL)
+   if (cmd->autoneg == AUTONEG_ENABLE || speed != SPEED_1 ||
+   cmd->duplex != DUPLEX_FULL)
return -EINVAL;
} else if (h->phy_if == PHY_INTERFACE_MODE_SGMII) {
-   if (!h->phy_node && autoneg != AUTONEG_DISABLE)
+   if (!priv->phy && cmd->autoneg == AUTONEG_ENABLE)
return -EINVAL;
 
-   if (speed == SPEED_1000 && duplex == DUPLEX_HALF)
+   if (speed == SPEED_1000 && cmd->duplex == DUPLEX_HALF)
return -EINVAL;
+   if (priv->phy)
+   return phy_ethtool_sset(priv->phy, cmd);
 
-   if (speed != SPEED_10 && speed != SPEED_100 &&
-   speed != SPEED_1000)
+   if ((speed != SPEED_10 && speed != SPEED_100 &&
+speed != SPEED_1000) || (cmd->duplex != DUPLEX_HALF &&
+cmd->duplex != DUPLEX_FULL))
return -EINVAL;
} else {
netdev_err(net_dev, "Not supported!");
return -ENOTSUPP;
}
 
-   if (priv->phy) {
-   return phy_ethtool_sset(priv->phy, cmd);
-   } else if (h->dev->ops->adjust_link && link_stat) {
-   h->dev->ops->adjust_link(h, speed, duplex);
+   if (h->dev->ops->adjust_link) {
+   h->dev->ops->adjust_link(h, (int)speed, cmd->duplex);
return 0;
}
+
netdev_err(net_dev, "Not supported!");
return -ENOTSUPP;
 }
-- 
1.9.1

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


[PATCH net-next 0/2] net: hns: fixes two bugs in hns driver

2015-10-16 Thread yankejian
  This patchset fixes two bugs in hns driver.
  - fixes timeout when received pause frame from the connective ports
  - should be set by using ethtool -s when the devices are link down

Chenny Xu (1):
  net: hns: fixes the issue by using ethtool -s

lisheng (1):
  net: hns: fixes a bug about timeout by pause frame

 drivers/net/ethernet/hisilicon/hns/hns_enet.c| 13 
 drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 39 
 2 files changed, 18 insertions(+), 34 deletions(-)

-- 
1.9.1

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


[PATCH net-next] net: hisilicon: fixes a bug when using ethtool -S

2015-10-14 Thread yankejian
From: lipeng 

this patch fixes a bug in hns driver. when we want to get statistic info
by using ethtool -S, it shows us there are 3 wrong counters info. because
the strings related to the registers are wrong. it needs to modify the
strings which give us wrong info.

Signed-off-by: lipeng 
Signed-off-by: yankejian 
Signed-off-by: Yisen Zhuang 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c
index dab5ecf..802d554 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c
@@ -51,9 +51,9 @@ static const struct mac_stats_string g_xgmac_stats_string[] = 
{
{"xgmac_rx_bad_pkt_from_dsaf", MAC_STATS_FIELD_OFF(rx_bad_from_sw)},
{"xgmac_tx_bad_pkt_64tomax", MAC_STATS_FIELD_OFF(tx_bad_pkts)},
 
-   {"xgmac_rx_not_well_pkt", MAC_STATS_FIELD_OFF(rx_fragment_err)},
-   {"xgmac_rx_good_well_pkt", MAC_STATS_FIELD_OFF(rx_undersize)},
-   {"xgmac_rx_total_pkt", MAC_STATS_FIELD_OFF(rx_under_min)},
+   {"xgmac_rx_bad_pkts_minto64", MAC_STATS_FIELD_OFF(rx_fragment_err)},
+   {"xgmac_rx_good_pkts_minto64", MAC_STATS_FIELD_OFF(rx_undersize)},
+   {"xgmac_rx_total_pkts_minto64", MAC_STATS_FIELD_OFF(rx_under_min)},
{"xgmac_rx_pkt_64", MAC_STATS_FIELD_OFF(rx_64bytes)},
{"xgmac_rx_pkt_65to127", MAC_STATS_FIELD_OFF(rx_65to127)},
{"xgmac_rx_pkt_128to255", MAC_STATS_FIELD_OFF(rx_128to255)},
-- 
1.9.1

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


[PATCH net-next] net: hisilicon net: fix a bug about led

2015-10-13 Thread yankejian
From: lipeng 

this patch fixes a bug in hns driver. the link led is on at the beginning,
but at this time the ethernet port is on down status. it needs to reset
the led status on init sequence.

Signed-off-by: lipeng 
Signed-off-by: yankejian 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 95bf42a..f8f7347 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -744,9 +744,11 @@ int hns_mac_get_cfg(struct dsaf_device *dsaf_dev, int 
mac_idx)
mac_cb->serdes_vaddr = dsaf_dev->sds_base;
 
if (dsaf_dev->cpld_base &&
-   mac_idx < DSAF_SERVICE_PORT_NUM_PER_DSAF)
+   mac_idx < DSAF_SERVICE_PORT_NUM_PER_DSAF) {
mac_cb->cpld_vaddr = dsaf_dev->cpld_base +
mac_cb->mac_id * CPLD_ADDR_PORT_OFFSET;
+   cpld_led_reset(mac_cb);
+   }
mac_cb->sfp_prsnt = 0;
mac_cb->txpkt_for_led = 0;
mac_cb->rxpkt_for_led = 0;
-- 
1.9.1

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


[PATCH net-next] net:hisilicon: supports promisc mode

2015-10-12 Thread yankejian
  this patch adds support to set promisc mode. it configs the queue on
init seq  when it is on promisc mode.and being enabled or disabled promisc
mode by upper level user.

Signed-off-by: yankejian 
Signed-off-by: Yisen Zhuang 
---
 drivers/net/ethernet/hisilicon/hns/hnae.h  |  1 +
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c  |  6 +
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 27 ++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h |  1 +
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c  |  4 ++--
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h  |  2 ++
 drivers/net/ethernet/hisilicon/hns/hns_enet.c  | 17 +-
 7 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h 
b/drivers/net/ethernet/hisilicon/hns/hnae.h
index 5edd8cd..dd4aa1b 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -429,6 +429,7 @@ struct hnae_ae_ops {
void (*set_coalesce_usecs)(struct hnae_handle *handle, u32 timeout);
int (*set_coalesce_frames)(struct hnae_handle *handle,
   u32 coalesce_frames);
+   void (*set_promisc_mode)(struct hnae_handle *handle, u32 en);
int (*get_mac_addr)(struct hnae_handle *handle, void **p);
int (*set_mac_addr)(struct hnae_handle *handle, void *p);
int (*set_mc_addr)(struct hnae_handle *handle, void *addr);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c 
b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index a2c72f8..1a16c03 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -392,6 +392,11 @@ static int hns_ae_set_autoneg(struct hnae_handle *handle, 
u8 enable)
return hns_mac_set_autoneg(hns_get_mac_cb(handle), enable);
 }
 
+static void hns_ae_set_promisc_mode(struct hnae_handle *handle, u32 en)
+{
+   hns_dsaf_set_promisc_mode(hns_ae_get_dsaf_dev(handle->dev), en);
+}
+
 static int hns_ae_get_autoneg(struct hnae_handle *handle)
 {
u32 auto_neg;
@@ -748,6 +753,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
.get_rx_max_coalesced_frames = hns_ae_get_rx_max_coalesced_frames,
.set_coalesce_usecs = hns_ae_set_coalesce_usecs,
.set_coalesce_frames = hns_ae_set_coalesce_frames,
+   .set_promisc_mode = hns_ae_set_promisc_mode,
.set_mac_addr = hns_ae_set_mac_address,
.set_mc_addr = hns_ae_set_multicast_one,
.set_mtu = hns_ae_set_mtu,
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 26ae6c6..ffc2604 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -217,6 +217,25 @@ hns_dsaf_ppe_qid_cfg(struct dsaf_device *dsaf_dev, u32 
qid_cfg)
}
 }
 
+static void hns_dsaf_mix_def_qid_cfg(struct dsaf_device *dsaf_dev)
+{
+   u16 max_q_per_vf, max_vfn;
+   u32 q_id, q_num_per_port;
+   u32 i;
+
+   hns_rcb_get_queue_mode(dsaf_dev->dsaf_mode,
+  HNS_DSAF_COMM_SERVICE_NW_IDX,
+  &max_vfn, &max_q_per_vf);
+   q_num_per_port = max_vfn * max_q_per_vf;
+
+   for (i = 0, q_id = 0; i < DSAF_SERVICE_NW_NUM; i++) {
+   dsaf_set_dev_field(dsaf_dev,
+  DSAF_MIX_DEF_QID_0_REG + 0x0004 * i,
+  0xff, 0, q_id);
+   q_id += q_num_per_port;
+   }
+}
+
 /**
  * hns_dsaf_sw_port_type_cfg - cfg sw type
  * @dsaf_id: dsa fabric id
@@ -592,6 +611,11 @@ static void hns_dsaf_tbl_tcam_data_ucast_pul(
dsaf_write_dev(dsaf_dev, DSAF_TBL_PUL_0_REG, o_tbl_pul);
 }
 
+void hns_dsaf_set_promisc_mode(struct dsaf_device *dsaf_dev, u32 en)
+{
+   dsaf_set_dev_bit(dsaf_dev, DSAF_CFG_0_REG, DSAF_CFG_MIX_MODE_S, !!en);
+}
+
 /**
  * hns_dsaf_tbl_stat_en - tbl
  * @dsaf_id: dsa fabric id
@@ -920,6 +944,9 @@ static void hns_dsaf_comm_init(struct dsaf_device *dsaf_dev)
/* set 22 queue per tx ppe engine, only used in switch mode */
hns_dsaf_ppe_qid_cfg(dsaf_dev, DSAF_DEFAUTL_QUEUE_NUM_PER_PPE);
 
+   /* set promisc def queue id */
+   hns_dsaf_mix_def_qid_cfg(dsaf_dev);
+
/* in non switch mode, set all port to access mode */
hns_dsaf_sw_port_type_cfg(dsaf_dev, DSAF_SW_PORT_TYPE_NON_VLAN);
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
index 315b07e..b2b9348 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
@@ -423,5 +423,6 @@ void hns_dsaf_get_strings(int stringset, u8 *data, int 
port);
 
 void hns_dsaf_get_regs(struct dsaf_device *ddev, u32 port, void *data);
 int hns_dsaf_get_regs_count(void);
+void hns_dsaf_set_promisc_mode(s