[PATCH iproute2] tc: bpf: update list of archs with eBPF support in manpage

2018-08-08 Thread Tobias Klauser
Update the list of architectures supporting eBPF JIT as of Linux 4.18.
Also mention the Linux version where support for a particular
architecture was introduced. Finally, reformat the list of architectures
as a bullet list in order to make it more readable.

Signed-off-by: Tobias Klauser 
---
 man/man8/tc-bpf.8 | 37 +
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/man/man8/tc-bpf.8 b/man/man8/tc-bpf.8
index d311f295615b..b2f9344f5e28 100644
--- a/man/man8/tc-bpf.8
+++ b/man/man8/tc-bpf.8
@@ -79,10 +79,39 @@ In Linux, it's generally considered that eBPF is the 
successor of cBPF.
 The kernel internally transforms cBPF expressions into eBPF expressions and
 executes the latter. Execution of them can be performed in an interpreter
 or at setup time, they can be just-in-time compiled (JIT'ed) to run as
-native machine code. Currently, x86_64, ARM64, s390, ppc64 and sparc64
-architectures have eBPF JIT support, whereas PPC, SPARC, ARM and MIPS have
-cBPF, but did not (yet) switch to eBPF JIT support.
-
+native machine code.
+.PP
+Currently, the eBPF JIT compiler is available for the following architectures:
+.IP * 4
+x86_64 (since Linux 3.18)
+.PD 0
+.IP *
+arm64 (since Linux 3.18)
+.IP *
+s390 (since Linux 4.1)
+.IP *
+ppc64 (since Linux 4.8)
+.IP *
+sparc64 (since Linux 4.12)
+.IP *
+mips64 (since Linux 4.13)
+.IP *
+arm32 (since Linux 4.14)
+.IP *
+x86_32 (since Linux 4.18)
+.PD
+.PP
+Whereas the following architectures have cBPF, but did not (yet) switch to eBPF
+JIT support:
+.IP * 4
+ppc32
+.PD 0
+.IP *
+sparc32
+.IP *
+mips32
+.PD
+.PP
 eBPF's instruction set has similar underlying principles as the cBPF
 instruction set, it however is modelled closer to the underlying
 architecture to better mimic native instruction sets with the aim to
-- 
2.18.0.130.g98da2f6b3e4a




Re: [PATCH net-next] net: ethoc: Remove useless test before clk_disable_unprepare

2018-05-16 Thread Tobias Klauser
On 2018-05-16 at 13:18:22 +0200, YueHaibing <yuehaib...@huawei.com> wrote:
> clk_disable_unprepare() already checks that the clock pointer is valid.
> No need to test it before calling it.
> 
> Signed-off-by: YueHaibing <yuehaib...@huawei.com>

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>


[PATCH] net: af_unix: fix typo in UNIX_SKB_FRAGS_SZ comment

2018-02-13 Thread Tobias Klauser
Change "minimun" to "minimum".

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/unix/af_unix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index d545e1d0dea2..2d465bdeccbc 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1825,7 +1825,7 @@ static int unix_dgram_sendmsg(struct socket *sock, struct 
msghdr *msg,
 }
 
 /* We use paged skbs for stream sockets, and limit occupancy to 32768
- * bytes, and a minimun of a full page.
+ * bytes, and a minimum of a full page.
  */
 #define UNIX_SKB_FRAGS_SZ (PAGE_SIZE << get_order(32768))
 
-- 
2.13.0



Re: [PATCH 03/31] nds32: Support early_printk

2017-11-08 Thread Tobias Klauser
On 2017-11-08 at 06:54:51 +0100, Greentime Hu  wrote:
> From: Greentime Hu 
> 
> Signed-off-by: Rick Chen 
> Signed-off-by: Greentime Hu 
> ---
>  arch/nds32/kernel/early_printk.c |  124 
> ++
>  1 file changed, 124 insertions(+)
>  create mode 100644 arch/nds32/kernel/early_printk.c
> 
> diff --git a/arch/nds32/kernel/early_printk.c 
> b/arch/nds32/kernel/early_printk.c
> new file mode 100644
> index 000..269c3cd
> --- /dev/null
> +++ b/arch/nds32/kernel/early_printk.c

Could be implemented using earlycon (the 8250 drivers already supports
it) instead of duplicating functionality in arch/nds32?  See e.g. the
nios2 port for how this could be done, specifically commit e118c3fec9c0
("nios2: remove custom early console implementation").


Re: [PATCH] net: hns: set correct return value

2017-10-30 Thread Tobias Klauser
On 2017-10-30 at 09:50:01 +0100, Pan Bian <bianpan2...@163.com> wrote:
> The function of_parse_phandle() returns a NULL pointer if it cannot
> resolve a phandle property to a device_node pointer. In function
> hns_nic_dev_probe(), its return value is passed to PTR_ERR to extract
> the error code. However, in this case, the extracted error code will
> always be zero, which is unexpected.
> 
> Signed-off-by: Pan Bian <bianpan2...@163.com>

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>


Re: net: hns: set correct return value

2017-10-30 Thread Tobias Klauser
On 2017-10-29 at 15:35:32 +0100, Pan Bian <bianpan2...@163.com> wrote:
> The function of_parse_phandle() returns a NULL pointer if it cannot
> resolve a phandle property to a device_node pointer. In function
> hns_nic_dev_probe(), its return value is passed to PTR_ERR to extract
> the error code. However, in this case, the extracted error code will
> always be zero, which is unexpected.
> 
> Signed-off-by: Pan Bian <bianpan2...@163.com>

The subject is missing a [PATCH] prefix which causes the patch e.g. to
not show up on patchwork [1]. Care to resend with the proper subject?

[1] https://patchwork.ozlabs.org/project/netdev/list/

Care to resend with the proper subject?

For the patch itself:

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>


Re: [PATCH] net: dl2k: Convert timers to use timer_setup()

2017-10-05 Thread Tobias Klauser
On 2017-10-05 at 02:51:50 +0200, Kees Cook <keesc...@chromium.org> wrote:
> In preparation for unconditionally passing the struct timer_list pointer to
> all timer callbacks, switch to using the new timer_setup() and from_timer()
> to pass the timer pointer explicitly.
> 
> Cc: "David S. Miller" <da...@davemloft.net>
> Cc: Jarod Wilson <ja...@redhat.com>
> Cc: Tobias Klauser <tklau...@distanz.ch>
> Cc: Philippe Reynes <trem...@gmail.com>
> Cc: netdev@vger.kernel.org
> Cc: Thomas Gleixner <t...@linutronix.de>
> Signed-off-by: Kees Cook <keesc...@chromium.org>

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>


Re: [PATCH] net: tulip: de2104x: Convert timers to use

2017-10-05 Thread Tobias Klauser
On 2017-10-05 at 02:50:48 +0200, Kees Cook <keesc...@chromium.org> wrote:
> In preparation for unconditionally passing the struct timer_list pointer to
> all timer callbacks, switch to using the new timer_setup() and from_timer()
> to pass the timer pointer explicitly.
> 
> Cc: "David S. Miller" <da...@davemloft.net>
> Cc: "yuval.sh...@oracle.com" <yuval.sh...@oracle.com>
> Cc: Tobias Klauser <tklau...@distanz.ch>
> Cc: Jarod Wilson <ja...@redhat.com>
> Cc: Philippe Reynes <trem...@gmail.com>
> Cc: netdev@vger.kernel.org
> Cc: linux-par...@vger.kernel.org
> Cc: Thomas Gleixner <t...@linutronix.de>
> Signed-off-by: Kees Cook <keesc...@chromium.org>

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>


[PATCH net-next] ldmvsw: Remove redundant unlikely()

2017-09-26 Thread Tobias Klauser
IS_ERR() already implies unlikely(), so it can be omitted.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/sun/ldmvsw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sun/ldmvsw.c 
b/drivers/net/ethernet/sun/ldmvsw.c
index 5b56c24b6ed2..5feeaa9f0a9e 100644
--- a/drivers/net/ethernet/sun/ldmvsw.c
+++ b/drivers/net/ethernet/sun/ldmvsw.c
@@ -307,7 +307,7 @@ static int vsw_port_probe(struct vio_dev *vdev, const 
struct vio_device_id *id)
 
/* Get (or create) the vnet associated with this port */
vp = vsw_get_vnet(hp, vdev->mp, );
-   if (unlikely(IS_ERR(vp))) {
+   if (IS_ERR(vp)) {
err = PTR_ERR(vp);
pr_err("Failed to get vnet for vsw-port\n");
mdesc_release(hp);
-- 
2.13.0




[PATCH net-next] bnxt_en: Remove redundant unlikely()

2017-09-26 Thread Tobias Klauser
IS_ERR() already implies unlikely(), so it can be omitted.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index c25f5b555adf..5ba49938ba55 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -1491,7 +1491,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_napi 
*bnapi, u32 *raw_cons,
   (struct rx_tpa_end_cmp *)rxcmp,
   (struct rx_tpa_end_cmp_ext *)rxcmp1, event);
 
-   if (unlikely(IS_ERR(skb)))
+   if (IS_ERR(skb))
return -EBUSY;
 
rc = -ENOMEM;
-- 
2.13.0




[PATCH net-next] net/mlx5: Remove redundant unlikely()

2017-09-26 Thread Tobias Klauser
IS_ERR() already implies unlikely(), so it can be omitted.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
index 4614ddfa91eb..6a7c8b04447e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
@@ -256,7 +256,7 @@ struct sk_buff *mlx5e_ipsec_handle_tx_skb(struct net_device 
*netdev,
goto drop;
}
mdata = mlx5e_ipsec_add_metadata(skb);
-   if (unlikely(IS_ERR(mdata))) {
+   if (IS_ERR(mdata)) {
atomic64_inc(>ipsec->sw_stats.ipsec_tx_drop_metadata);
goto drop;
}
-- 
2.13.0




[PATCH net-next] kcm: Remove redundant unlikely()

2017-09-26 Thread Tobias Klauser
IS_ERR() already implies unlikely(), so it can be omitted.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/kcm/kcmsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index af4e76ac88ff..0b750a22c4b9 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -1650,7 +1650,7 @@ static int kcm_clone(struct socket *osock, struct 
kcm_clone *info,
}
 
newfile = sock_alloc_file(newsock, 0, osock->sk->sk_prot_creator->name);
-   if (unlikely(IS_ERR(newfile))) {
+   if (IS_ERR(newfile)) {
err = PTR_ERR(newfile);
goto out_sock_alloc_fail;
}
-- 
2.13.0




[PATCH net-next] datagram: Remove redundant unlikely()

2017-09-26 Thread Tobias Klauser
IS_ERR() already implies unlikely(), so it can be omitted.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/core/datagram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/datagram.c b/net/core/datagram.c
index f7fb7e3f2acf..0b7b4c22719e 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -188,7 +188,7 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,
}
if (!skb->len) {
skb = skb_set_peeked(skb);
-   if (unlikely(IS_ERR(skb))) {
+   if (IS_ERR(skb)) {
*err = PTR_ERR(skb);
return NULL;
}
-- 
2.13.0




[PATCH net-next] ipv6: Remove redundant unlikely()

2017-09-26 Thread Tobias Klauser
IS_ERR() already implies unlikely(), so it can be omitted.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/ipv6/addrconf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 96861c702c06..13c3b697f8c0 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3297,7 +3297,7 @@ static int fixup_permanent_addr(struct inet6_dev *idev,
struct rt6_info *rt, *prev;
 
rt = addrconf_dst_alloc(idev, >addr, false);
-   if (unlikely(IS_ERR(rt)))
+   if (IS_ERR(rt))
return PTR_ERR(rt);
 
/* ifp->rt can be accessed outside of rtnl */
-- 
2.13.0




[PATCH net-next] net: ena: Remove redundant unlikely()

2017-09-26 Thread Tobias Klauser
IS_ERR() already implies unlikely(), so it can be omitted.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/amazon/ena/ena_com.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c 
b/drivers/net/ethernet/amazon/ena/ena_com.c
index 52beba8c7a39..ded29af648c9 100644
--- a/drivers/net/ethernet/amazon/ena/ena_com.c
+++ b/drivers/net/ethernet/amazon/ena/ena_com.c
@@ -315,7 +315,7 @@ static struct ena_comp_ctx *ena_com_submit_admin_cmd(struct 
ena_com_admin_queue
  cmd_size_in_bytes,
  comp,
  comp_size_in_bytes);
-   if (unlikely(IS_ERR(comp_ctx)))
+   if (IS_ERR(comp_ctx))
admin_queue->running_state = false;
spin_unlock_irqrestore(_queue->q_lock, flags);
 
@@ -1130,7 +1130,7 @@ int ena_com_execute_admin_command(struct 
ena_com_admin_queue *admin_queue,
 
comp_ctx = ena_com_submit_admin_cmd(admin_queue, cmd, cmd_size,
comp, comp_size);
-   if (unlikely(IS_ERR(comp_ctx))) {
+   if (IS_ERR(comp_ctx)) {
if (comp_ctx == ERR_PTR(-ENODEV))
pr_debug("Failed to submit command [%ld]\n",
 PTR_ERR(comp_ctx));
-- 
2.13.0




[PATCH] bpf: devmap: pass on return value of bpf_map_precharge_memlock

2017-09-18 Thread Tobias Klauser
If bpf_map_precharge_memlock in dev_map_alloc, -ENOMEM is returned
regardless of the actual error produced by bpf_map_precharge_memlock.
Fix it by passing on the error returned by bpf_map_precharge_memlock.

Also return -EINVAL instead of -ENOMEM if the page count overflow check
fails.

This makes dev_map_alloc match the behavior of other bpf maps' alloc
functions wrt. return values.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 kernel/bpf/devmap.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 959c9a07f318..e093d9a2c4dd 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -75,8 +75,8 @@ static u64 dev_map_bitmap_size(const union bpf_attr *attr)
 static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
 {
struct bpf_dtab *dtab;
+   int err = -EINVAL;
u64 cost;
-   int err;
 
/* check sanity of attributes */
if (attr->max_entries == 0 || attr->key_size != 4 ||
@@ -108,6 +108,8 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
if (err)
goto free_dtab;
 
+   err = -ENOMEM;
+
/* A per cpu bitfield with a bit per possible net device */
dtab->flush_needed = __alloc_percpu(dev_map_bitmap_size(attr),
__alignof__(unsigned long));
@@ -128,7 +130,7 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
 free_dtab:
free_percpu(dtab->flush_needed);
kfree(dtab);
-   return ERR_PTR(-ENOMEM);
+   return ERR_PTR(err);
 }
 
 static void dev_map_free(struct bpf_map *map)
-- 
2.13.0




[PATCH] tls: make tls_sw_free_resources static

2017-09-14 Thread Tobias Klauser
Make the needlessly global function tls_sw_free_resources static to fix
a gcc/sparse warning.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/tls/tls_sw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index fa596fa71ba7..7d80040a37b6 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -639,7 +639,7 @@ int tls_sw_sendpage(struct sock *sk, struct page *page,
return ret;
 }
 
-void tls_sw_free_resources(struct sock *sk)
+static void tls_sw_free_resources(struct sock *sk)
 {
struct tls_context *tls_ctx = tls_get_ctx(sk);
struct tls_sw_context *ctx = tls_sw_ctx(tls_ctx);
-- 
2.13.0




Re: [PATCH] net: ethoc: enable NAPI before poll may be scheduled

2017-06-06 Thread Tobias Klauser
On 2017-06-06 at 03:31:16 +0200, Max Filippov <jcmvb...@gmail.com> wrote:
> ethoc_reset enables device interrupts, ethoc_interrupt may schedule a
> NAPI poll before NAPI is enabled in the ethoc_open, which results in
> device being unable to send or receive anything until it's closed and
> reopened. In case the device is flooded with ingress packets it may be
> unable to recover at all.
> Move napi_enable above ethoc_reset in the ethoc_open to fix that.
> 
> Cc: sta...@vger.kernel.org
> Signed-off-by: Max Filippov <jcmvb...@gmail.com>

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>


Re: [PATCH net] rtnetlink: Fix the IFLA_PHYS_PORT_NAME TLV to include terminating NULL

2017-05-09 Thread Tobias Klauser
On 2017-05-09 at 14:12:02 +0200, Yotam Gigi  wrote:
> The IFLA_PHYS_PORT_NAME rtnetlink TLV length does not include the
> terminating NULL character, which is different from other string typed
> TLVs. Due to the fact that libnl checks for the terminating NULL in every
> string typed attribute, it crashes on every RTM_GETLINK response on
> drivers that implement ndo_get_phys_port_name.
> 
> Make the fill_phys_port_name function include the terminating NULL in the
> TLV size by using the nla_put_string helper function.
> 
> Fixes: db24a9044ee1 ("net: add support for phys_port_name")
> Signed-off-by: Yotam Gigi 
> Cc: David Ahern 
> Reviewed-by: Ido Schimmel 
> Acked-by: Jiri Pirko 
> ---
> Please consider this for stable too. Thanks!

This is already fixed in commit 77ef033b687c ("rtnetlink: NUL-terminate
IFLA_PHYS_PORT_NAME string").


[PATCH net] bridge: netlink: account for IFLA_BRPORT_{B,M}CAST_FLOOD size and policy

2017-05-05 Thread Tobias Klauser
The attribute sizes for IFLA_BRPORT_MCAST_FLOOD and
IFLA_BRPORT_BCAST_FLOOD weren't accounted for in br_port_info_size()
when they were added. Do so now and also add the corresponding policy
entries:

Cc: Nikolay Aleksandrov <niko...@cumulusnetworks.com>
Cc: Mike Manning <mmann...@brocade.com>
Fixes: b6cb5ac8331b ("net: bridge: add per-port multicast flood flag")
Fixes: 99f906e9ad7b ("bridge: add per-port broadcast flood flag")
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/bridge/br_netlink.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index a572db710d4e..c5ce7745b230 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -133,6 +133,8 @@ static inline size_t br_port_info_size(void)
+ nla_total_size(1) /* IFLA_BRPORT_MCAST_TO_UCAST */
+ nla_total_size(1) /* IFLA_BRPORT_LEARNING */
+ nla_total_size(1) /* IFLA_BRPORT_UNICAST_FLOOD */
+   + nla_total_size(1) /* IFLA_BRPORT_MCAST_FLOOD */
+   + nla_total_size(1) /* IFLA_BRPORT_BCAST_FLOOD */
+ nla_total_size(1) /* IFLA_BRPORT_PROXYARP */
+ nla_total_size(1) /* IFLA_BRPORT_PROXYARP_WIFI */
+ nla_total_size(1) /* IFLA_BRPORT_VLAN_TUNNEL */
@@ -633,6 +635,8 @@ static const struct nla_policy 
br_port_policy[IFLA_BRPORT_MAX + 1] = {
[IFLA_BRPORT_PROXYARP_WIFI] = { .type = NLA_U8 },
[IFLA_BRPORT_MULTICAST_ROUTER] = { .type = NLA_U8 },
[IFLA_BRPORT_MCAST_TO_UCAST] = { .type = NLA_U8 },
+   [IFLA_BRPORT_MCAST_FLOOD] = { .type = NLA_U8 },
+   [IFLA_BRPORT_BCAST_FLOOD] = { .type = NLA_U8 },
 };
 
 /* Change the state of the port and notify spanning tree */
-- 
2.12.2




[PATCH net-next] bpf: remove reference to sock_filter_ext from kerneldoc comment

2017-04-18 Thread Tobias Klauser
struct sock_filter_ext didn't make it into the tree and is now called
struct bpf_insn. Reword the kerneldoc comment for bpf_convert_filter()
accordingly.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/core/filter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index ce2a19da8aa4..42a7f08b609f 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -354,7 +354,8 @@ static bool convert_bpf_extensions(struct sock_filter *fp,
  * @new_prog: buffer where converted program will be stored
  * @new_len: pointer to store length of converted program
  *
- * Remap 'sock_filter' style BPF instruction set to 'sock_filter_ext' style.
+ * Remap 'sock_filter' style classic BPF (cBPF) instruction set to 'bpf_insn'
+ * style extended BPF (eBPF).
  * Conversion workflow:
  *
  * 1) First pass for calculating the new program length:
-- 
2.12.2




Re: [PATCH net-next 05/14] net: macb: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
On 2017-04-07 at 10:29:34 +0200, Nicolas Ferre <nicolas.fe...@microchip.com> 
wrote:
> Le 07/04/2017 à 10:17, Tobias Klauser a écrit :
> > Instead of using a private copy of struct net_device_stats in struct
> > macb, use stats from struct net_device.
> 
> I agree with the initiative but I read this in the documentation of this
> struct member...
> 
> @stats: Statistics struct, which was left as a legacy, use
> rtnl_link_stats64 instead

Seems I haven't read the comments for this struct member in a long time.
Thanks for the hint :)

> Is it still permitted to use it? Would it be to directly move to the
> most up-to-date code?

With a quick git/google search I couldn't really find any information on
why net_device_stats was deemed legacy and whether it is still allowed
to be used. It seems the comment saying so was introduced in
536721b1cb3f ("net: kernel-doc compliant documentation for net_device")
but neither the log message specifies nor the mailing list thread
provide any further information.

In any case I'd say it's still better to use the one provided by
struct net_device rather than introducing a copy.

And certainly, switching to use rtnl_link_stats64 would even be better.
I can try to come up with a patch but I'm not really sure what the
preferred method to store these stats is. Should the driver define its
own struct with the counters it is interested in and then copy it to
rtnl_link_stats64 in .ndo_get_stats (which is what most drivers not
having HW counter register seem to be doing)? Or should a copy of
rtnl_link_stats64 be included in the netdev_priv data?

Thanks

> Regards,
> 
> 
> > Cc: Nicolas Ferre <nicolas.fe...@atmel.com>
> > Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
> > ---
> >  drivers/net/ethernet/cadence/macb.c | 40 
> > ++---
> >  drivers/net/ethernet/cadence/macb.h |  1 -
> >  2 files changed, 20 insertions(+), 21 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/cadence/macb.c 
> > b/drivers/net/ethernet/cadence/macb.c
> > index 30606b11b128..5cbd1e7a926a 100644
> > --- a/drivers/net/ethernet/cadence/macb.c
> > +++ b/drivers/net/ethernet/cadence/macb.c
> > @@ -684,8 +684,8 @@ static void macb_tx_error_task(struct work_struct *work)
> > netdev_vdbg(bp->dev, "txerr skb %u (data %p) TX 
> > complete\n",
> > macb_tx_ring_wrap(bp, tail),
> > skb->data);
> > -   bp->stats.tx_packets++;
> > -   bp->stats.tx_bytes += skb->len;
> > +   bp->dev->stats.tx_packets++;
> > +   bp->dev->stats.tx_bytes += skb->len;
> > }
> > } else {
> > /* "Buffers exhausted mid-frame" errors may only happen
> > @@ -778,8 +778,8 @@ static void macb_tx_interrupt(struct macb_queue *queue)
> > netdev_vdbg(bp->dev, "skb %u (data %p) TX 
> > complete\n",
> > macb_tx_ring_wrap(bp, tail),
> > skb->data);
> > -   bp->stats.tx_packets++;
> > -   bp->stats.tx_bytes += skb->len;
> > +   bp->dev->stats.tx_packets++;
> > +   bp->dev->stats.tx_bytes += skb->len;
> > }
> >  
> > /* Now we can safely release resources */
> > @@ -911,14 +911,14 @@ static int gem_rx(struct macb *bp, int budget)
> > if (!(ctrl & MACB_BIT(RX_SOF) && ctrl & MACB_BIT(RX_EOF))) {
> > netdev_err(bp->dev,
> >"not whole frame pointed by descriptor\n");
> > -   bp->stats.rx_dropped++;
> > +   bp->dev->stats.rx_dropped++;
> > break;
> > }
> > skb = bp->rx_skbuff[entry];
> > if (unlikely(!skb)) {
> > netdev_err(bp->dev,
> >"inconsistent Rx descriptor chain\n");
> > -   bp->stats.rx_dropped++;
> > +   bp->dev->stats.rx_dropped++;
> > break;
> > }
> > /* now everything is ready for receiving packet */
> > @@ -938,8 +938,8 @@ static int gem_rx(struct macb *bp, int budget)

[PATCH net-next 11/14] net: tulip: de2104x: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
de_private, use stats from struct net_device.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/dec/tulip/de2104x.c | 42 +++-
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c 
b/drivers/net/ethernet/dec/tulip/de2104x.c
index 127ce9707378..91b8f6f5a765 100644
--- a/drivers/net/ethernet/dec/tulip/de2104x.c
+++ b/drivers/net/ethernet/dec/tulip/de2104x.c
@@ -312,8 +312,6 @@ struct de_private {
 
u32 msg_enable;
 
-   struct net_device_stats net_stats;
-
struct pci_dev  *pdev;
 
u16 setup_frame[DE_SETUP_FRAME_WORDS];
@@ -388,14 +386,14 @@ static void de_rx_err_acct (struct de_private *de, 
unsigned rx_tail,
netif_warn(de, rx_err, de->dev,
   "Oversized Ethernet frame spanned multiple 
buffers, status %08x!\n",
   status);
-   de->net_stats.rx_length_errors++;
+   de->dev->stats.rx_length_errors++;
}
} else if (status & RxError) {
/* There was a fatal error. */
-   de->net_stats.rx_errors++; /* end of a packet.*/
-   if (status & 0x0890) de->net_stats.rx_length_errors++;
-   if (status & RxErrCRC) de->net_stats.rx_crc_errors++;
-   if (status & RxErrFIFO) de->net_stats.rx_fifo_errors++;
+   de->dev->stats.rx_errors++; /* end of a packet.*/
+   if (status & 0x0890) de->dev->stats.rx_length_errors++;
+   if (status & RxErrCRC) de->dev->stats.rx_crc_errors++;
+   if (status & RxErrFIFO) de->dev->stats.rx_fifo_errors++;
}
 }
 
@@ -423,7 +421,7 @@ static void de_rx (struct de_private *de)
mapping = de->rx_skb[rx_tail].mapping;
 
if (unlikely(drop)) {
-   de->net_stats.rx_dropped++;
+   de->dev->stats.rx_dropped++;
goto rx_next;
}
 
@@ -441,7 +439,7 @@ static void de_rx (struct de_private *de)
buflen = copying_skb ? (len + RX_OFFSET) : de->rx_buf_sz;
copy_skb = netdev_alloc_skb(de->dev, buflen);
if (unlikely(!copy_skb)) {
-   de->net_stats.rx_dropped++;
+   de->dev->stats.rx_dropped++;
drop = 1;
rx_work = 100;
goto rx_next;
@@ -470,8 +468,8 @@ static void de_rx (struct de_private *de)
 
skb->protocol = eth_type_trans (skb, de->dev);
 
-   de->net_stats.rx_packets++;
-   de->net_stats.rx_bytes += skb->len;
+   de->dev->stats.rx_packets++;
+   de->dev->stats.rx_bytes += skb->len;
rc = netif_rx (skb);
if (rc == NET_RX_DROP)
drop = 1;
@@ -572,18 +570,18 @@ static void de_tx (struct de_private *de)
netif_dbg(de, tx_err, de->dev,
  "tx err, status 0x%x\n",
  status);
-   de->net_stats.tx_errors++;
+   de->dev->stats.tx_errors++;
if (status & TxOWC)
-   de->net_stats.tx_window_errors++;
+   de->dev->stats.tx_window_errors++;
if (status & TxMaxCol)
-   de->net_stats.tx_aborted_errors++;
+   de->dev->stats.tx_aborted_errors++;
if (status & TxLinkFail)
-   de->net_stats.tx_carrier_errors++;
+   de->dev->stats.tx_carrier_errors++;
if (status & TxFIFOUnder)
-   de->net_stats.tx_fifo_errors++;
+   de->dev->stats.tx_fifo_errors++;
} else {
-   de->net_stats.tx_packets++;
-   de->net_stats.tx_bytes += skb->len;
+   de->dev->stats.tx_packets++;
+   de->dev->stats.tx_bytes += skb->len;
netif_dbg(de, tx_done, de->dev,
  "tx done, slot %d\n", tx_tail);
}
@@ -814,9 +812,9 @@ s

[PATCH net-next 02/14] net: cxgb3: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in
struct port_info, use stats from struct net_device.

Cc: Santosh Raspatur <sant...@chelsio.com>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/chelsio/cxgb3/adapter.h| 1 -
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb3/adapter.h 
b/drivers/net/ethernet/chelsio/cxgb3/adapter.h
index 8b395b537330..087ff0ffb597 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/adapter.h
+++ b/drivers/net/ethernet/chelsio/cxgb3/adapter.h
@@ -72,7 +72,6 @@ struct port_info {
struct cphy phy;
struct cmac mac;
struct link_config link_config;
-   struct net_device_stats netstats;
int activity;
__be32 iscsi_ipv4addr;
struct iscsi_config iscsic;
diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c 
b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index d76491676b51..2ff6bd139c96 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -1489,7 +1489,7 @@ static struct net_device_stats *cxgb_get_stats(struct 
net_device *dev)
 {
struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter;
-   struct net_device_stats *ns = >netstats;
+   struct net_device_stats *ns = >stats;
const struct mac_stats *pstats;
 
spin_lock(>stats_lock);
-- 
2.12.2




[PATCH net-next 07/14] net: nmlan_cs: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
_mace_private, use stats from struct net_device.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/amd/nmclan_cs.c | 49 ++--
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ethernet/amd/nmclan_cs.c 
b/drivers/net/ethernet/amd/nmclan_cs.c
index b556c926557a..9c152d85840d 100644
--- a/drivers/net/ethernet/amd/nmclan_cs.c
+++ b/drivers/net/ethernet/amd/nmclan_cs.c
@@ -359,7 +359,6 @@ typedef struct _mace_statistics {
 
 typedef struct _mace_private {
struct pcmcia_device*p_dev;
-struct net_device_stats linux_stats; /* Linux statistics counters */
 mace_statistics mace_stats; /* MACE chip statistics counters */
 
 /* restore_multicast_list() state variables */
@@ -879,7 +878,7 @@ static netdev_tx_t mace_start_xmit(struct sk_buff *skb,
service a transmit interrupt while we are in here.
 */
 
-lp->linux_stats.tx_bytes += skb->len;
+dev->stats.tx_bytes += skb->len;
 lp->tx_free_frames--;
 
 /* WARNING: Write the _exact_ number of bytes written in the header! */
@@ -967,7 +966,7 @@ static irqreturn_t mace_interrupt(int irq, void *dev_id)
 
   fifofc = inb(ioaddr + AM2150_MACE_BASE + MACE_FIFOFC);
   if ((fifofc & MACE_FIFOFC_XMTFC)==0) {
-   lp->linux_stats.tx_errors++;
+   dev->stats.tx_errors++;
outb(0xFF, ioaddr + AM2150_XMT_SKIP);
   }
 
@@ -1016,7 +1015,7 @@ static irqreturn_t mace_interrupt(int irq, void *dev_id)
 
   } /* if (xmtfs & MACE_XMTFS_XMTSV) */
 
-  lp->linux_stats.tx_packets++;
+  dev->stats.tx_packets++;
   lp->tx_free_frames++;
   netif_wake_queue(dev);
 } /* if (status & MACE_IR_XMTINT) */
@@ -1077,7 +1076,7 @@ static int mace_rx(struct net_device *dev, unsigned char 
RxCnt)
  " 0x%X.\n", dev->name, rx_framecnt, rx_status);
 
 if (rx_status & MACE_RCVFS_RCVSTS) { /* Error, update stats. */
-  lp->linux_stats.rx_errors++;
+  dev->stats.rx_errors++;
   if (rx_status & MACE_RCVFS_OFLO) {
 lp->mace_stats.oflo++;
   }
@@ -1114,14 +1113,14 @@ static int mace_rx(struct net_device *dev, unsigned 
char RxCnt)

netif_rx(skb); /* Send the packet to the upper (protocol) layers. */
 
-   lp->linux_stats.rx_packets++;
-   lp->linux_stats.rx_bytes += pkt_len;
+   dev->stats.rx_packets++;
+   dev->stats.rx_bytes += pkt_len;
outb(0xFF, ioaddr + AM2150_RCV_NEXT); /* skip to next frame */
continue;
   } else {
pr_debug("%s: couldn't allocate a sk_buff of size"
  " %d.\n", dev->name, pkt_len);
-   lp->linux_stats.rx_dropped++;
+   dev->stats.rx_dropped++;
   }
 }
 outb(0xFF, ioaddr + AM2150_RCV_NEXT); /* skip to next frame */
@@ -1231,13 +1230,13 @@ static void update_stats(unsigned int ioaddr, struct 
net_device *dev)
   lp->mace_stats.rntpc += mace_read(lp, ioaddr, MACE_RNTPC);
   lp->mace_stats.mpc += mace_read(lp, ioaddr, MACE_MPC);
   /* At this point, mace_stats is fully updated for this call.
- We may now update the linux_stats. */
+ We may now update the netdev stats. */
 
-  /* The MACE has no equivalent for linux_stats field which are commented
+  /* The MACE has no equivalent for netdev stats field which are commented
  out. */
 
-  /* lp->linux_stats.multicast; */
-  lp->linux_stats.collisions = 
+  /* dev->stats.multicast; */
+  dev->stats.collisions =
 lp->mace_stats.rcvcco * 256 + lp->mace_stats.rcvcc;
 /* Collision: The MACE may retry sending a packet 15 times
before giving up.  The retry count is in XMTRC.
@@ -1245,22 +1244,22 @@ static void update_stats(unsigned int ioaddr, struct 
net_device *dev)
If so, why doesn't the RCVCC record these collisions? */
 
   /* detailed rx_errors: */
-  lp->linux_stats.rx_length_errors = 
+  dev->stats.rx_length_errors =
 lp->mace_stats.rntpco * 256 + lp->mace_stats.rntpc;
-  /* lp->linux_stats.rx_over_errors */
-  lp->linux_stats.rx_crc_errors = lp->mace_stats.fcs;
-  lp->linux_stats.rx_frame_errors = lp->mace_stats.fram;
-  lp->linux_stats.rx_fifo_errors = lp->mace_stats.oflo;
-  lp->linux_stats.rx_missed_errors = 
+  /* dev->stats.rx_over_errors */
+  dev->stats.rx_crc_errors = lp->mace_stats.fcs;
+  dev->stats.rx_frame_errors = lp->mace_stats.fram;
+  dev->stats.rx_fifo_errors = lp->mace_stats.oflo;
+  dev->stats.rx_missed_errors =
 lp->mace_stats.mpco * 256 + lp->mace_stats.mpc;
 
   /* detailed tx_errors */
-  lp->linux_stats.tx_aborted_errors = lp->mace_stats.rtry;
-  lp->linux_stats.tx_carrier_errors = lp->mace_stats.lcar;
+  dev->stats.tx_aborted_errors = lp->mace_stats.rtry;
+  de

[PATCH net-next 06/14] net: moxa: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
moxart_mac_priv_t, use stats from struct net_device. Also remove the now
unnecessary .ndo_get_stats function.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/moxa/moxart_ether.c | 28 ++--
 drivers/net/ethernet/moxa/moxart_ether.h |  1 -
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 6ad44be08b33..c0d7d5eec7e7 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -228,8 +228,8 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
if (desc0 & (RX_DESC0_ERR | RX_DESC0_CRC_ERR | RX_DESC0_FTL |
 RX_DESC0_RUNT | RX_DESC0_ODD_NB)) {
net_dbg_ratelimited("packet error\n");
-   priv->stats.rx_dropped++;
-   priv->stats.rx_errors++;
+   ndev->stats.rx_dropped++;
+   ndev->stats.rx_errors++;
goto rx_next;
}
 
@@ -245,8 +245,8 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
 
if (unlikely(!skb)) {
net_dbg_ratelimited("netdev_alloc_skb_ip_align 
failed\n");
-   priv->stats.rx_dropped++;
-   priv->stats.rx_errors++;
+   ndev->stats.rx_dropped++;
+   ndev->stats.rx_errors++;
goto rx_next;
}
 
@@ -256,10 +256,10 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
napi_gro_receive(>napi, skb);
rx++;
 
-   priv->stats.rx_packets++;
-   priv->stats.rx_bytes += len;
+   ndev->stats.rx_packets++;
+   ndev->stats.rx_bytes += len;
if (desc0 & RX_DESC0_MULTICAST)
-   priv->stats.multicast++;
+   ndev->stats.multicast++;
 
 rx_next:
wmb(); /* prevent setting ownership back too early */
@@ -296,8 +296,8 @@ static void moxart_tx_finished(struct net_device *ndev)
dma_unmap_single(>dev, priv->tx_mapping[tx_tail],
 priv->tx_len[tx_tail], DMA_TO_DEVICE);
 
-   priv->stats.tx_packets++;
-   priv->stats.tx_bytes += priv->tx_skb[tx_tail]->len;
+   ndev->stats.tx_packets++;
+   ndev->stats.tx_bytes += priv->tx_skb[tx_tail]->len;
 
dev_kfree_skb_irq(priv->tx_skb[tx_tail]);
priv->tx_skb[tx_tail] = NULL;
@@ -349,7 +349,7 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
 
if (moxart_desc_read(desc + TX_REG_OFFSET_DESC0) & TX_DESC0_DMA_OWN) {
net_dbg_ratelimited("no TX space for packet\n");
-   priv->stats.tx_dropped++;
+   ndev->stats.tx_dropped++;
goto out_unlock;
}
rmb(); /* ensure data is only read that had TX_DESC0_DMA_OWN cleared */
@@ -400,13 +400,6 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
return ret;
 }
 
-static struct net_device_stats *moxart_mac_get_stats(struct net_device *ndev)
-{
-   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
-
-   return >stats;
-}
-
 static void moxart_mac_setmulticast(struct net_device *ndev)
 {
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
@@ -456,7 +449,6 @@ static const struct net_device_ops moxart_netdev_ops = {
.ndo_open   = moxart_mac_open,
.ndo_stop   = moxart_mac_stop,
.ndo_start_xmit = moxart_mac_start_xmit,
-   .ndo_get_stats  = moxart_mac_get_stats,
.ndo_set_rx_mode= moxart_mac_set_rx_mode,
.ndo_set_mac_address= moxart_set_mac_address,
.ndo_validate_addr  = eth_validate_addr,
diff --git a/drivers/net/ethernet/moxa/moxart_ether.h 
b/drivers/net/ethernet/moxa/moxart_ether.h
index afc32ec998c0..686b8957d5cf 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.h
+++ b/drivers/net/ethernet/moxa/moxart_ether.h
@@ -293,7 +293,6 @@
 
 struct moxart_mac_priv_t {
void __iomem *base;
-   struct net_device_stats stats;
unsigned int reg_maccr;
unsigned int reg_imr;
struct napi_struct napi;
-- 
2.12.2




[PATCH net-next 12/14] net: typhoon: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
typhoon, use stats from struct net_device.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/3com/typhoon.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/3com/typhoon.c 
b/drivers/net/ethernet/3com/typhoon.c
index 084a6d58543a..be823c186517 100644
--- a/drivers/net/ethernet/3com/typhoon.c
+++ b/drivers/net/ethernet/3com/typhoon.c
@@ -283,7 +283,6 @@ struct typhoon {
spinlock_t  command_lockcacheline_aligned;
struct basic_ring   cmdRing;
struct basic_ring   respRing;
-   struct net_device_stats stats;
struct net_device_stats stats_saved;
struct typhoon_shared * shared;
dma_addr_t  shared_dma;
@@ -898,7 +897,7 @@ typhoon_set_rx_mode(struct net_device *dev)
 static int
 typhoon_do_get_stats(struct typhoon *tp)
 {
-   struct net_device_stats *stats = >stats;
+   struct net_device_stats *stats = >dev->stats;
struct net_device_stats *saved = >stats_saved;
struct cmd_desc xp_cmd;
struct resp_desc xp_resp[7];
@@ -951,7 +950,7 @@ static struct net_device_stats *
 typhoon_get_stats(struct net_device *dev)
 {
struct typhoon *tp = netdev_priv(dev);
-   struct net_device_stats *stats = >stats;
+   struct net_device_stats *stats = >dev->stats;
struct net_device_stats *saved = >stats_saved;
 
smp_rmb();
@@ -1991,7 +1990,7 @@ typhoon_stop_runtime(struct typhoon *tp, int wait_type)
tp->card_state = Sleeping;
smp_wmb();
typhoon_do_get_stats(tp);
-   memcpy(>stats_saved, >stats, sizeof(struct net_device_stats));
+   memcpy(>stats_saved, >dev->stats, sizeof(struct 
net_device_stats));
 
INIT_COMMAND_NO_RESPONSE(_cmd, TYPHOON_CMD_HALT);
typhoon_issue_command(tp, 1, _cmd, 0, NULL);
-- 
2.12.2




[PATCH net-next 00/14] Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Along the lines of previous patches, switch (almost) all remaining net
drivers to use net_device_stats from net_device instead of including a
copy of it in their netdev_priv struct.

Tobias Klauser (14):
  net: cxgb: Use net_device_stats from struct net_device
  net: cxgb3: Use net_device_stats from struct net_device
  net: dl2k: Use net_device_stats from struct net_device
  net: emac: Use net_device_stats from struct net_device
  net: macb: Use net_device_stats from struct net_device
  net: moxa: Use net_device_stats from struct net_device
  net: nmlan_cs: Use net_device_stats from struct net_device
  net: nuvoton: Use net_device_stats from struct net_device
  net: sunbmac: Use net_device_stats from struct net_device
  net: sunhme: Use net_device_stats from struct net_device
  net: tulip: de2104x: Use net_device_stats from struct net_device
  net: typhoon: Use net_device_stats from struct net_device
  usbnet: kaweth: Use net_device_stats from struct net_device
  usbnet: pegasus: Use net_device_stats from struct net_device

 drivers/net/ethernet/3com/typhoon.c |  7 ++--
 drivers/net/ethernet/amd/nmclan_cs.c| 49 -
 drivers/net/ethernet/cadence/macb.c | 40 ++--
 drivers/net/ethernet/cadence/macb.h |  1 -
 drivers/net/ethernet/chelsio/cxgb/common.h  |  1 -
 drivers/net/ethernet/chelsio/cxgb/cxgb2.c   |  2 +-
 drivers/net/ethernet/chelsio/cxgb3/adapter.h|  1 -
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c |  2 +-
 drivers/net/ethernet/dec/tulip/de2104x.c| 42 ++---
 drivers/net/ethernet/dlink/dl2k.c   | 45 ++-
 drivers/net/ethernet/dlink/dl2k.h   |  1 -
 drivers/net/ethernet/ibm/emac/core.c|  2 +-
 drivers/net/ethernet/ibm/emac/core.h|  1 -
 drivers/net/ethernet/moxa/moxart_ether.c| 28 +-
 drivers/net/ethernet/moxa/moxart_ether.h|  1 -
 drivers/net/ethernet/nuvoton/w90p910_ether.c| 33 ++---
 drivers/net/ethernet/sun/sunbmac.c  | 18 -
 drivers/net/ethernet/sun/sunbmac.h  |  1 -
 drivers/net/ethernet/sun/sunhme.c   | 22 +--
 drivers/net/ethernet/sun/sunhme.h   |  2 -
 drivers/net/usb/kaweth.c| 32 +---
 drivers/net/usb/pegasus.c   | 36 --
 drivers/net/usb/pegasus.h   |  1 -
 23 files changed, 156 insertions(+), 212 deletions(-)

-- 
2.12.2




[PATCH net-next 05/14] net: macb: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
macb, use stats from struct net_device.

Cc: Nicolas Ferre <nicolas.fe...@atmel.com>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/cadence/macb.c | 40 ++---
 drivers/net/ethernet/cadence/macb.h |  1 -
 2 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index 30606b11b128..5cbd1e7a926a 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -684,8 +684,8 @@ static void macb_tx_error_task(struct work_struct *work)
netdev_vdbg(bp->dev, "txerr skb %u (data %p) TX 
complete\n",
macb_tx_ring_wrap(bp, tail),
skb->data);
-   bp->stats.tx_packets++;
-   bp->stats.tx_bytes += skb->len;
+   bp->dev->stats.tx_packets++;
+   bp->dev->stats.tx_bytes += skb->len;
}
} else {
/* "Buffers exhausted mid-frame" errors may only happen
@@ -778,8 +778,8 @@ static void macb_tx_interrupt(struct macb_queue *queue)
netdev_vdbg(bp->dev, "skb %u (data %p) TX 
complete\n",
macb_tx_ring_wrap(bp, tail),
skb->data);
-   bp->stats.tx_packets++;
-   bp->stats.tx_bytes += skb->len;
+   bp->dev->stats.tx_packets++;
+   bp->dev->stats.tx_bytes += skb->len;
}
 
/* Now we can safely release resources */
@@ -911,14 +911,14 @@ static int gem_rx(struct macb *bp, int budget)
if (!(ctrl & MACB_BIT(RX_SOF) && ctrl & MACB_BIT(RX_EOF))) {
netdev_err(bp->dev,
   "not whole frame pointed by descriptor\n");
-   bp->stats.rx_dropped++;
+   bp->dev->stats.rx_dropped++;
break;
}
skb = bp->rx_skbuff[entry];
if (unlikely(!skb)) {
netdev_err(bp->dev,
   "inconsistent Rx descriptor chain\n");
-   bp->stats.rx_dropped++;
+   bp->dev->stats.rx_dropped++;
break;
}
/* now everything is ready for receiving packet */
@@ -938,8 +938,8 @@ static int gem_rx(struct macb *bp, int budget)
GEM_BFEXT(RX_CSUM, ctrl) & GEM_RX_CSUM_CHECKED_MASK)
skb->ip_summed = CHECKSUM_UNNECESSARY;
 
-   bp->stats.rx_packets++;
-   bp->stats.rx_bytes += skb->len;
+   bp->dev->stats.rx_packets++;
+   bp->dev->stats.rx_bytes += skb->len;
 
 #if defined(DEBUG) && defined(VERBOSE_DEBUG)
netdev_vdbg(bp->dev, "received skb of length %u, csum: %08x\n",
@@ -984,7 +984,7 @@ static int macb_rx_frame(struct macb *bp, unsigned int 
first_frag,
 */
skb = netdev_alloc_skb(bp->dev, len + NET_IP_ALIGN);
if (!skb) {
-   bp->stats.rx_dropped++;
+   bp->dev->stats.rx_dropped++;
for (frag = first_frag; ; frag++) {
desc = macb_rx_desc(bp, frag);
desc->addr &= ~MACB_BIT(RX_USED);
@@ -1030,8 +1030,8 @@ static int macb_rx_frame(struct macb *bp, unsigned int 
first_frag,
__skb_pull(skb, NET_IP_ALIGN);
skb->protocol = eth_type_trans(skb, bp->dev);
 
-   bp->stats.rx_packets++;
-   bp->stats.rx_bytes += skb->len;
+   bp->dev->stats.rx_packets++;
+   bp->dev->stats.rx_bytes += skb->len;
netdev_vdbg(bp->dev, "received skb of length %u, csum: %08x\n",
skb->len, skb->csum);
netif_receive_skb(skb);
@@ -2210,7 +2210,7 @@ static void gem_update_stats(struct macb *bp)
 static struct net_device_stats *gem_get_stats(struct macb *bp)
 {
struct gem_stats *hwstat = >hw_stats.gem;
-   struct net_device_stats *nstat = >stats;
+   struct net_device_stats *nstat = >dev->stats;
 
gem_update_stats(bp);
 
@@ -2281,7 +2281,7 @@ static void gem_get_ethtool_strings(struct net_device 
*dev, u32 sset, u8 *p)
 static struct net_device_stats *macb_get_stats(struct net_device *dev)
 {

[PATCH net-next 08/14] net: nuvoton: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in
struct w90p910_ether, use stats from struct net_device. Also remove
the now unnecessary .ndo_get_stats function.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/nuvoton/w90p910_ether.c | 33 ++--
 1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/nuvoton/w90p910_ether.c 
b/drivers/net/ethernet/nuvoton/w90p910_ether.c
index 9709c8ca0774..159564d8dcdb 100644
--- a/drivers/net/ethernet/nuvoton/w90p910_ether.c
+++ b/drivers/net/ethernet/nuvoton/w90p910_ether.c
@@ -152,7 +152,6 @@ struct  w90p910_ether {
struct tran_pdesc *tdesc;
dma_addr_t rdesc_phys;
dma_addr_t tdesc_phys;
-   struct net_device_stats stats;
struct platform_device *pdev;
struct resource *res;
struct sk_buff *skb;
@@ -584,15 +583,6 @@ static int w90p910_ether_close(struct net_device *dev)
return 0;
 }
 
-static struct net_device_stats *w90p910_ether_stats(struct net_device *dev)
-{
-   struct w90p910_ether *ether;
-
-   ether = netdev_priv(dev);
-
-   return >stats;
-}
-
 static int w90p910_send_frame(struct net_device *dev,
unsigned char *data, int length)
 {
@@ -671,10 +661,10 @@ static irqreturn_t w90p910_tx_interrupt(int irq, void 
*dev_id)
ether->finish_tx = 0;
 
if (txbd->sl & TXDS_TXCP) {
-   ether->stats.tx_packets++;
-   ether->stats.tx_bytes += txbd->sl & 0x;
+   dev->stats.tx_packets++;
+   dev->stats.tx_bytes += txbd->sl & 0x;
} else {
-   ether->stats.tx_errors++;
+   dev->stats.tx_errors++;
}
 
txbd->sl = 0x0;
@@ -730,7 +720,7 @@ static void netdev_rx(struct net_device *dev)
data = ether->rdesc->recv_buf[ether->cur_rx];
skb = netdev_alloc_skb(dev, length + 2);
if (!skb) {
-   ether->stats.rx_dropped++;
+   dev->stats.rx_dropped++;
return;
}
 
@@ -738,24 +728,24 @@ static void netdev_rx(struct net_device *dev)
skb_put(skb, length);
skb_copy_to_linear_data(skb, data, length);
skb->protocol = eth_type_trans(skb, dev);
-   ether->stats.rx_packets++;
-   ether->stats.rx_bytes += length;
+   dev->stats.rx_packets++;
+   dev->stats.rx_bytes += length;
netif_rx(skb);
} else {
-   ether->stats.rx_errors++;
+   dev->stats.rx_errors++;
 
if (status & RXDS_RP) {
dev_err(>dev, "rx runt err\n");
-   ether->stats.rx_length_errors++;
+   dev->stats.rx_length_errors++;
} else if (status & RXDS_CRCE) {
dev_err(>dev, "rx crc err\n");
-   ether->stats.rx_crc_errors++;
+   dev->stats.rx_crc_errors++;
} else if (status & RXDS_ALIE) {
dev_err(>dev, "rx alignment err\n");
-   ether->stats.rx_frame_errors++;
+   dev->stats.rx_frame_errors++;
} else if (status & RXDS_PTLE) {
dev_err(>dev, "rx longer err\n");
-   ether->stats.rx_over_errors++;
+   dev->stats.rx_over_errors++;
}
}
 
@@ -912,7 +902,6 @@ static const struct net_device_ops w90p910_ether_netdev_ops 
= {
.ndo_open   = w90p910_ether_open,
.ndo_stop   = w90p910_ether_close,
.ndo_start_xmit = w90p910_ether_start_xmit,
-   .ndo_get_stats  = w90p910_ether_stats,
.ndo_set_rx_mode= w90p910_ether_set_multicast_list,
.ndo_set_mac_address= w90p910_set_mac_address,
.ndo_do_ioctl   = w90p910_ether_ioctl,
-- 
2.12.2




[PATCH net-next 13/14] usbnet: kaweth: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
kaweth_device, use stats from struct net_device. Also remove the now
unnecessary .ndo_get_stats function.

Cc: linux-...@vger.kernel.org
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/usb/kaweth.c | 32 ++--
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 876f02f4945e..3d8ea18df696 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -245,8 +245,6 @@ struct kaweth_device
__u16 packet_filter_bitmap;
 
struct kaweth_ethernet_configuration configuration;
-
-   struct net_device_stats stats;
 };
 
 /
@@ -598,7 +596,7 @@ static void kaweth_usb_receive(struct urb *urb)
struct sk_buff *skb;
 
if (unlikely(status == -EPIPE)) {
-   kaweth->stats.rx_errors++;
+   net->stats.rx_errors++;
kaweth->end = 1;
wake_up(>term_wait);
dev_dbg(dev, "Status was -EPIPE.\n");
@@ -613,12 +611,12 @@ static void kaweth_usb_receive(struct urb *urb)
}
if (unlikely(status == -EPROTO || status == -ETIME ||
 status == -EILSEQ)) {
-   kaweth->stats.rx_errors++;
+   net->stats.rx_errors++;
dev_dbg(dev, "Status was -EPROTO, -ETIME, or -EILSEQ.\n");
return;
}
if (unlikely(status == -EOVERFLOW)) {
-   kaweth->stats.rx_errors++;
+   net->stats.rx_errors++;
dev_dbg(dev, "Status was -EOVERFLOW.\n");
}
spin_lock(>device_lock);
@@ -663,8 +661,8 @@ static void kaweth_usb_receive(struct urb *urb)
 
netif_rx(skb);
 
-   kaweth->stats.rx_packets++;
-   kaweth->stats.rx_bytes += pkt_len;
+   net->stats.rx_packets++;
+   net->stats.rx_bytes += pkt_len;
}
 
kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC);
@@ -810,7 +808,7 @@ static netdev_tx_t kaweth_start_xmit(struct sk_buff *skb,
dev_kfree_skb_irq(skb);
skb = copied_skb;
if (!copied_skb) {
-   kaweth->stats.tx_errors++;
+   net->stats.tx_errors++;
netif_start_queue(net);
spin_unlock_irq(>device_lock);
return NETDEV_TX_OK;
@@ -834,15 +832,15 @@ static netdev_tx_t kaweth_start_xmit(struct sk_buff *skb,
{
dev_warn(>dev, "kaweth failed tx_urb %d\n", res);
 skip:
-   kaweth->stats.tx_errors++;
+   net->stats.tx_errors++;
 
netif_start_queue(net);
dev_kfree_skb_irq(skb);
}
else
{
-   kaweth->stats.tx_packets++;
-   kaweth->stats.tx_bytes += skb->len;
+   net->stats.tx_packets++;
+   net->stats.tx_bytes += skb->len;
}
 
spin_unlock_irq(>device_lock);
@@ -912,15 +910,6 @@ static void kaweth_async_set_rx_mode(struct kaweth_device 
*kaweth)
 }
 
 /
- * kaweth_netdev_stats
- /
-static struct net_device_stats *kaweth_netdev_stats(struct net_device *dev)
-{
-   struct kaweth_device *kaweth = netdev_priv(dev);
-   return >stats;
-}
-
-/
  * kaweth_tx_timeout
  /
 static void kaweth_tx_timeout(struct net_device *net)
@@ -928,7 +917,7 @@ static void kaweth_tx_timeout(struct net_device *net)
struct kaweth_device *kaweth = netdev_priv(net);
 
dev_warn(>dev, "%s: Tx timed out. Resetting.\n", net->name);
-   kaweth->stats.tx_errors++;
+   net->stats.tx_errors++;
netif_trans_update(net);
 
usb_unlink_urb(kaweth->tx_urb);
@@ -981,7 +970,6 @@ static const struct net_device_ops kaweth_netdev_ops = {
.ndo_start_xmit =   kaweth_start_xmit,
.ndo_tx_timeout =   kaweth_tx_timeout,
.ndo_set_rx_mode =  kaweth_set_rx_mode,
-   .ndo_get_stats =kaweth_netdev_stats,
.ndo_set_mac_address =  eth_mac_addr,
.ndo_validate_addr =eth_validate_addr,
 };
-- 
2.12.2




[PATCH net-next 04/14] net: emac: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in
struct emac_instance, use stats from struct net_device.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/ibm/emac/core.c | 2 +-
 drivers/net/ethernet/ibm/emac/core.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ibm/emac/core.c 
b/drivers/net/ethernet/ibm/emac/core.c
index 0f9cd92fdc5e..508923f39ccf 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -1929,7 +1929,7 @@ static struct net_device_stats *emac_stats(struct 
net_device *ndev)
struct emac_instance *dev = netdev_priv(ndev);
struct emac_stats *st = >stats;
struct emac_error_stats *est = >estats;
-   struct net_device_stats *nst = >nstats;
+   struct net_device_stats *nst = >stats;
unsigned long flags;
 
DBG2(dev, "stats" NL);
diff --git a/drivers/net/ethernet/ibm/emac/core.h 
b/drivers/net/ethernet/ibm/emac/core.h
index 0710a6685489..f10e156641d5 100644
--- a/drivers/net/ethernet/ibm/emac/core.h
+++ b/drivers/net/ethernet/ibm/emac/core.h
@@ -265,7 +265,6 @@ struct emac_instance {
/* Stats
 */
struct emac_error_stats estats;
-   struct net_device_stats nstats;
struct emac_stats   stats;
 
/* Misc
-- 
2.12.2




[PATCH net-next 10/14] net: sunhme: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
happy_meal, use stats from struct net_device.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/sun/sunhme.c | 22 +++---
 drivers/net/ethernet/sun/sunhme.h |  2 --
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c 
b/drivers/net/ethernet/sun/sunhme.c
index 53ff66ef53ac..a6cc9a2d41c1 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -933,7 +933,7 @@ static void happy_meal_stop(struct happy_meal *hp, void 
__iomem *gregs)
 /* hp->happy_lock must be held */
 static void happy_meal_get_counters(struct happy_meal *hp, void __iomem *bregs)
 {
-   struct net_device_stats *stats = >net_stats;
+   struct net_device_stats *stats = >dev->stats;
 
stats->rx_crc_errors += hme_read32(hp, bregs + BMAC_RCRCECTR);
hme_write32(hp, bregs + BMAC_RCRCECTR, 0);
@@ -1947,7 +1947,7 @@ static void happy_meal_tx(struct happy_meal *hp)
break;
}
hp->tx_skbs[elem] = NULL;
-   hp->net_stats.tx_bytes += skb->len;
+   dev->stats.tx_bytes += skb->len;
 
for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) {
dma_addr = hme_read_desc32(hp, >tx_addr);
@@ -1964,7 +1964,7 @@ static void happy_meal_tx(struct happy_meal *hp)
}
 
dev_kfree_skb_irq(skb);
-   hp->net_stats.tx_packets++;
+   dev->stats.tx_packets++;
}
hp->tx_old = elem;
TXD((">"));
@@ -2009,17 +2009,17 @@ static void happy_meal_rx(struct happy_meal *hp, struct 
net_device *dev)
/* Check for errors. */
if ((len < ETH_ZLEN) || (flags & RXFLAG_OVERFLOW)) {
RXD(("ERR(%08x)]", flags));
-   hp->net_stats.rx_errors++;
+   dev->stats.rx_errors++;
if (len < ETH_ZLEN)
-   hp->net_stats.rx_length_errors++;
+   dev->stats.rx_length_errors++;
if (len & (RXFLAG_OVERFLOW >> 16)) {
-   hp->net_stats.rx_over_errors++;
-   hp->net_stats.rx_fifo_errors++;
+   dev->stats.rx_over_errors++;
+   dev->stats.rx_fifo_errors++;
}
 
/* Return it to the Happy meal. */
drop_it:
-   hp->net_stats.rx_dropped++;
+   dev->stats.rx_dropped++;
hme_write_rxd(hp, this,
  
(RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)),
  dma_addr);
@@ -2084,8 +2084,8 @@ static void happy_meal_rx(struct happy_meal *hp, struct 
net_device *dev)
skb->protocol = eth_type_trans(skb, dev);
netif_rx(skb);
 
-   hp->net_stats.rx_packets++;
-   hp->net_stats.rx_bytes += len;
+   dev->stats.rx_packets++;
+   dev->stats.rx_bytes += len;
next:
elem = NEXT_RX(elem);
this = [elem];
@@ -2396,7 +2396,7 @@ static struct net_device_stats 
*happy_meal_get_stats(struct net_device *dev)
happy_meal_get_counters(hp, hp->bigmacregs);
spin_unlock_irq(>happy_lock);
 
-   return >net_stats;
+   return >stats;
 }
 
 static void happy_meal_set_multicast(struct net_device *dev)
diff --git a/drivers/net/ethernet/sun/sunhme.h 
b/drivers/net/ethernet/sun/sunhme.h
index 4a8d5b18dfd5..3af540adb3c5 100644
--- a/drivers/net/ethernet/sun/sunhme.h
+++ b/drivers/net/ethernet/sun/sunhme.h
@@ -418,8 +418,6 @@ struct happy_meal {
 
int rx_new, tx_new, rx_old, tx_old;
 
-   struct net_device_stats   net_stats;  /* Statistical counters   
   */
-
 #if defined(CONFIG_SBUS) && defined(CONFIG_PCI)
u32 (*read32)(void __iomem *);
void (*write32)(void __iomem *, u32);
-- 
2.12.2




[PATCH net-next 03/14] net: dl2k: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
netdev_private, use stats from struct net_device. Also remove the now
unnecessary .ndo_get_stats function and the #ifdef'ed increment of the
collisions16 counter which doesn't exist in struct net_device_stats.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/dlink/dl2k.c | 45 +--
 drivers/net/ethernet/dlink/dl2k.h |  1 -
 2 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/dlink/dl2k.c 
b/drivers/net/ethernet/dlink/dl2k.c
index 1e350135f11d..778f974e2928 100644
--- a/drivers/net/ethernet/dlink/dl2k.c
+++ b/drivers/net/ethernet/dlink/dl2k.c
@@ -878,10 +878,10 @@ tx_error (struct net_device *dev, int tx_status)
frame_id = (tx_status & 0x);
printk (KERN_ERR "%s: Transmit error, TxStatus %4.4x, FrameId %d.\n",
dev->name, tx_status, frame_id);
-   np->stats.tx_errors++;
+   dev->stats.tx_errors++;
/* Ttransmit Underrun */
if (tx_status & 0x10) {
-   np->stats.tx_fifo_errors++;
+   dev->stats.tx_fifo_errors++;
dw16(TxStartThresh, dr16(TxStartThresh) + 0x10);
/* Transmit Underrun need to set TxReset, DMARest, FIFOReset */
dw16(ASICCtrl + 2,
@@ -903,7 +903,7 @@ tx_error (struct net_device *dev, int tx_status)
}
/* Late Collision */
if (tx_status & 0x04) {
-   np->stats.tx_fifo_errors++;
+   dev->stats.tx_fifo_errors++;
/* TxReset and clear FIFO */
dw16(ASICCtrl + 2, TxReset | FIFOReset);
/* Wait reset done */
@@ -916,13 +916,8 @@ tx_error (struct net_device *dev, int tx_status)
/* Let TxStartThresh stay default value */
}
/* Maximum Collisions */
-#ifdef ETHER_STATS
if (tx_status & 0x08)
-   np->stats.collisions16++;
-#else
-   if (tx_status & 0x08)
-   np->stats.collisions++;
-#endif
+   dev->stats.collisions++;
/* Restart the Tx */
dw32(MACCtrl, dr16(MACCtrl) | TxEnable);
 }
@@ -952,15 +947,15 @@ receive_packet (struct net_device *dev)
break;
/* Update rx error statistics, drop packet. */
if (frame_status & RFS_Errors) {
-   np->stats.rx_errors++;
+   dev->stats.rx_errors++;
if (frame_status & (RxRuntFrame | RxLengthError))
-   np->stats.rx_length_errors++;
+   dev->stats.rx_length_errors++;
if (frame_status & RxFCSError)
-   np->stats.rx_crc_errors++;
+   dev->stats.rx_crc_errors++;
if (frame_status & RxAlignmentError && np->speed != 
1000)
-   np->stats.rx_frame_errors++;
+   dev->stats.rx_frame_errors++;
if (frame_status & RxFIFOOverrun)
-   np->stats.rx_fifo_errors++;
+   dev->stats.rx_fifo_errors++;
} else {
struct sk_buff *skb;
 
@@ -1096,23 +1091,23 @@ get_stats (struct net_device *dev)
/* All statistics registers need to be acknowledged,
   else statistic overflow could cause problems */
 
-   np->stats.rx_packets += dr32(FramesRcvOk);
-   np->stats.tx_packets += dr32(FramesXmtOk);
-   np->stats.rx_bytes += dr32(OctetRcvOk);
-   np->stats.tx_bytes += dr32(OctetXmtOk);
+   dev->stats.rx_packets += dr32(FramesRcvOk);
+   dev->stats.tx_packets += dr32(FramesXmtOk);
+   dev->stats.rx_bytes += dr32(OctetRcvOk);
+   dev->stats.tx_bytes += dr32(OctetXmtOk);
 
-   np->stats.multicast = dr32(McstFramesRcvdOk);
-   np->stats.collisions += dr32(SingleColFrames)
+   dev->stats.multicast = dr32(McstFramesRcvdOk);
+   dev->stats.collisions += dr32(SingleColFrames)
 +  dr32(MultiColFrames);
 
/* detailed tx errors */
stat_reg = dr16(FramesAbortXSColls);
-   np->stats.tx_aborted_errors += stat_reg;
-   np->stats.tx_errors += stat_reg;
+   dev->stats.tx_aborted_errors += stat_reg;
+   dev->stats.tx_errors += stat_reg;
 
stat_reg = dr16(CarrierSenseErrors);
-   np->stats.tx_carrier_errors += stat_reg;
-   np->stats.tx_errors += stat_reg;
+   dev->stats.tx_carrier_errors += stat_reg;
+   dev->stats.tx_errors += stat_reg;
 
/* Clear all other statistic register. */
dr32(McstOctetXmtOk);
@@ -1142,7 +1137,7 @@ get_stats (struct net_device *dev

[PATCH net-next 14/14] usbnet: pegasus: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
pegasus, use stats from struct net_device. Also remove the now
unnecessary .ndo_get_stats function.

Cc: Petko Manolov <pet...@nucleusys.com>
Cc: linux-...@vger.kernel.org
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/usb/pegasus.c | 36 +++-
 drivers/net/usb/pegasus.h |  1 -
 2 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
index 321e059e13ae..6514c86f043e 100644
--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -501,13 +501,13 @@ static void read_bulk_callback(struct urb *urb)
if (rx_status & 0x1e) {
netif_dbg(pegasus, rx_err, net,
  "RX packet error %x\n", rx_status);
-   pegasus->stats.rx_errors++;
+   net->stats.rx_errors++;
if (rx_status & 0x06)   /* long or runt */
-   pegasus->stats.rx_length_errors++;
+   net->stats.rx_length_errors++;
if (rx_status & 0x08)
-   pegasus->stats.rx_crc_errors++;
+   net->stats.rx_crc_errors++;
if (rx_status & 0x10)   /* extra bits   */
-   pegasus->stats.rx_frame_errors++;
+   net->stats.rx_frame_errors++;
goto goon;
}
if (pegasus->chip == 0x8513) {
@@ -535,8 +535,8 @@ static void read_bulk_callback(struct urb *urb)
skb_put(pegasus->rx_skb, pkt_len);
pegasus->rx_skb->protocol = eth_type_trans(pegasus->rx_skb, net);
netif_rx(pegasus->rx_skb);
-   pegasus->stats.rx_packets++;
-   pegasus->stats.rx_bytes += pkt_len;
+   net->stats.rx_packets++;
+   net->stats.rx_bytes += pkt_len;
 
if (pegasus->flags & PEGASUS_UNPLUG)
return;
@@ -670,13 +670,13 @@ static void intr_callback(struct urb *urb)
/* byte 0 == tx_status1, reg 2B */
if (d[0] & (TX_UNDERRUN|EXCESSIVE_COL
|LATE_COL|JABBER_TIMEOUT)) {
-   pegasus->stats.tx_errors++;
+   net->stats.tx_errors++;
if (d[0] & TX_UNDERRUN)
-   pegasus->stats.tx_fifo_errors++;
+   net->stats.tx_fifo_errors++;
if (d[0] & (EXCESSIVE_COL | JABBER_TIMEOUT))
-   pegasus->stats.tx_aborted_errors++;
+   net->stats.tx_aborted_errors++;
if (d[0] & LATE_COL)
-   pegasus->stats.tx_window_errors++;
+   net->stats.tx_window_errors++;
}
 
/* d[5].LINK_STATUS lies on some adapters.
@@ -685,7 +685,7 @@ static void intr_callback(struct urb *urb)
 */
 
/* bytes 3-4 == rx_lostpkt, reg 2E/2F */
-   pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4];
+   net->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4];
}
 
res = usb_submit_urb(urb, GFP_ATOMIC);
@@ -701,7 +701,7 @@ static void pegasus_tx_timeout(struct net_device *net)
pegasus_t *pegasus = netdev_priv(net);
netif_warn(pegasus, timer, net, "tx timeout\n");
usb_unlink_urb(pegasus->tx_urb);
-   pegasus->stats.tx_errors++;
+   net->stats.tx_errors++;
 }
 
 static netdev_tx_t pegasus_start_xmit(struct sk_buff *skb,
@@ -731,23 +731,18 @@ static netdev_tx_t pegasus_start_xmit(struct sk_buff *skb,
netif_device_detach(pegasus->net);
break;
default:
-   pegasus->stats.tx_errors++;
+   net->stats.tx_errors++;
netif_start_queue(net);
}
} else {
-   pegasus->stats.tx_packets++;
-   pegasus->stats.tx_bytes += skb->len;
+   net->stats.tx_packets++;
+   net->stats.tx_bytes += skb->len;
}
dev_kfree_skb(skb);
 
return NETDEV_TX_OK;
 }
 
-static struct net_device_stats *pegasus_netdev_stats(struct net_device *dev)
-{
-   return &((pegasus_t *) netdev_priv(dev))->stats;
-}
-
 static inline void disable_net_traffic(pegasus_t *pegasus)
 {
__le16 tmp = cpu_to_le16(0);
@@ -1294,7 +1289,6 @@ static const struct net_device_ops pegasus_netdev_ops = {
.ndo_do_ioctl = pegasus_ioctl,
.ndo_start_xmit =   pegasus_start_xmit,
.ndo_set_rx_mode =  pegasus_set_multicast,
-   .ndo_get_stats =   

[PATCH net-next 09/14] net: sunbmac: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
bigmac, use stats from struct net_device.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/sun/sunbmac.c | 18 +-
 drivers/net/ethernet/sun/sunbmac.h |  1 -
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunbmac.c 
b/drivers/net/ethernet/sun/sunbmac.c
index c4caf486cbef..3189722110c2 100644
--- a/drivers/net/ethernet/sun/sunbmac.c
+++ b/drivers/net/ethernet/sun/sunbmac.c
@@ -169,7 +169,7 @@ static void bigmac_stop(struct bigmac *bp)
 
 static void bigmac_get_counters(struct bigmac *bp, void __iomem *bregs)
 {
-   struct net_device_stats *stats = >enet_stats;
+   struct net_device_stats *stats = >dev->stats;
 
stats->rx_crc_errors += sbus_readl(bregs + BMAC_RCRCECTR);
sbus_writel(0, bregs + BMAC_RCRCECTR);
@@ -774,8 +774,8 @@ static void bigmac_tx(struct bigmac *bp)
if (this->tx_flags & TXD_OWN)
break;
skb = bp->tx_skbs[elem];
-   bp->enet_stats.tx_packets++;
-   bp->enet_stats.tx_bytes += skb->len;
+   dev->stats.tx_packets++;
+   dev->stats.tx_bytes += skb->len;
dma_unmap_single(>bigmac_op->dev,
 this->tx_addr, skb->len,
 DMA_TO_DEVICE);
@@ -811,12 +811,12 @@ static void bigmac_rx(struct bigmac *bp)
 
/* Check for errors. */
if (len < ETH_ZLEN) {
-   bp->enet_stats.rx_errors++;
-   bp->enet_stats.rx_length_errors++;
+   bp->dev->stats.rx_errors++;
+   bp->dev->stats.rx_length_errors++;
 
drop_it:
/* Return it to the BigMAC. */
-   bp->enet_stats.rx_dropped++;
+   bp->dev->stats.rx_dropped++;
this->rx_flags =
(RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & 
RXD_LENGTH));
goto next;
@@ -875,8 +875,8 @@ static void bigmac_rx(struct bigmac *bp)
/* No checksums done by the BigMAC ;-( */
skb->protocol = eth_type_trans(skb, bp->dev);
netif_rx(skb);
-   bp->enet_stats.rx_packets++;
-   bp->enet_stats.rx_bytes += len;
+   bp->dev->stats.rx_packets++;
+   bp->dev->stats.rx_bytes += len;
next:
elem = NEXT_RX(elem);
this = [elem];
@@ -987,7 +987,7 @@ static struct net_device_stats *bigmac_get_stats(struct 
net_device *dev)
struct bigmac *bp = netdev_priv(dev);
 
bigmac_get_counters(bp, bp->bregs);
-   return >enet_stats;
+   return >stats;
 }
 
 static void bigmac_set_multicast(struct net_device *dev)
diff --git a/drivers/net/ethernet/sun/sunbmac.h 
b/drivers/net/ethernet/sun/sunbmac.h
index 532fc56830cf..ee56930475a8 100644
--- a/drivers/net/ethernet/sun/sunbmac.h
+++ b/drivers/net/ethernet/sun/sunbmac.h
@@ -311,7 +311,6 @@ struct bigmac {
enum bigmac_timer_state timer_state;
unsigned inttimer_ticks;
 
-   struct net_device_stats enet_stats;
struct platform_device  *qec_op;
struct platform_device  *bigmac_op;
struct net_device   *dev;
-- 
2.12.2




[PATCH net-next 01/14] net: cxgb: Use net_device_stats from struct net_device

2017-04-07 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
port_info, use stats from struct net_device.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/chelsio/cxgb/common.h | 1 -
 drivers/net/ethernet/chelsio/cxgb/cxgb2.c  | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb/common.h 
b/drivers/net/ethernet/chelsio/cxgb/common.h
index 6916c62f2487..94b9482f14a5 100644
--- a/drivers/net/ethernet/chelsio/cxgb/common.h
+++ b/drivers/net/ethernet/chelsio/cxgb/common.h
@@ -223,7 +223,6 @@ struct port_info {
struct cmac *mac;
struct cphy *phy;
struct link_config link_config;
-   struct net_device_stats netstats;
 };
 
 struct sge;
diff --git a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c 
b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
index d8aff7a4b3c7..8623be13bf86 100644
--- a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
+++ b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
@@ -296,7 +296,7 @@ static struct net_device_stats *t1_get_stats(struct 
net_device *dev)
 {
struct adapter *adapter = dev->ml_priv;
struct port_info *p = >port[dev->if_port];
-   struct net_device_stats *ns = >netstats;
+   struct net_device_stats *ns = >stats;
const struct cmac_statistics *pstats;
 
/* Do a full update of the MAC stats */
-- 
2.12.2




[PATCH] net: i40evf: Use net_device_stats from struct net_device

2017-04-06 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in
struct i40evf_adapter, use stats from struct net_device. Also remove the
now unnecessary .ndo_get_stats function.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/intel/i40evf/i40evf.h |  1 -
 drivers/net/ethernet/intel/i40evf/i40evf_main.c| 16 
 .../net/ethernet/intel/i40evf/i40evf_virtchnl.c| 22 +++---
 3 files changed, 11 insertions(+), 28 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40evf/i40evf.h 
b/drivers/net/ethernet/intel/i40evf/i40evf.h
index d61ecf655091..66d4880b5c14 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf.h
+++ b/drivers/net/ethernet/intel/i40evf/i40evf.h
@@ -253,7 +253,6 @@ struct i40evf_adapter {
/* OS defined structs */
struct net_device *netdev;
struct pci_dev *pdev;
-   struct net_device_stats net_stats;
 
struct i40e_hw hw; /* defined in i40e_type.h */
 
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c 
b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index fb2811c23024..1e36561b428a 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -2231,21 +2231,6 @@ static int i40evf_close(struct net_device *netdev)
 }
 
 /**
- * i40evf_get_stats - Get System Network Statistics
- * @netdev: network interface device structure
- *
- * Returns the address of the device statistics structure.
- * The statistics are actually updated from the timer callback.
- **/
-static struct net_device_stats *i40evf_get_stats(struct net_device *netdev)
-{
-   struct i40evf_adapter *adapter = netdev_priv(netdev);
-
-   /* only return the current stats */
-   return >net_stats;
-}
-
-/**
  * i40evf_change_mtu - Change the Maximum Transfer Unit
  * @netdev: network interface device structure
  * @new_mtu: new value for maximum frame size
@@ -2351,7 +2336,6 @@ static const struct net_device_ops i40evf_netdev_ops = {
.ndo_open   = i40evf_open,
.ndo_stop   = i40evf_close,
.ndo_start_xmit = i40evf_xmit_frame,
-   .ndo_get_stats  = i40evf_get_stats,
.ndo_set_rx_mode= i40evf_set_rx_mode,
.ndo_validate_addr  = eth_validate_addr,
.ndo_set_mac_address= i40evf_set_mac,
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c 
b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
index 032be8d3928a..91121de0d928 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
@@ -958,17 +958,17 @@ void i40evf_virtchnl_completion(struct i40evf_adapter 
*adapter,
case I40E_VIRTCHNL_OP_GET_STATS: {
struct i40e_eth_stats *stats =
(struct i40e_eth_stats *)msg;
-   adapter->net_stats.rx_packets = stats->rx_unicast +
-stats->rx_multicast +
-stats->rx_broadcast;
-   adapter->net_stats.tx_packets = stats->tx_unicast +
-stats->tx_multicast +
-stats->tx_broadcast;
-   adapter->net_stats.rx_bytes = stats->rx_bytes;
-   adapter->net_stats.tx_bytes = stats->tx_bytes;
-   adapter->net_stats.tx_errors = stats->tx_errors;
-   adapter->net_stats.rx_dropped = stats->rx_discards;
-   adapter->net_stats.tx_dropped = stats->tx_discards;
+   netdev->stats.rx_packets = stats->rx_unicast +
+  stats->rx_multicast +
+  stats->rx_broadcast;
+   netdev->stats.tx_packets = stats->tx_unicast +
+  stats->tx_multicast +
+  stats->tx_broadcast;
+   netdev->stats.rx_bytes = stats->rx_bytes;
+   netdev->stats.tx_bytes = stats->tx_bytes;
+   netdev->stats.tx_errors = stats->tx_errors;
+   netdev->stats.rx_dropped = stats->rx_discards;
+   netdev->stats.tx_dropped = stats->tx_discards;
adapter->current_stats = *stats;
}
break;
-- 
2.12.2.399.g034667a45805




[PATCH] net: igbvf: Use net_device_stats from struct net_device

2017-04-06 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in
struct igbvf_adapter, use stats from struct net_device. Also remove the
now unnecessary .ndo_get_stats function.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/intel/igbvf/igbvf.h  |  1 -
 drivers/net/ethernet/intel/igbvf/netdev.c | 26 +-
 2 files changed, 5 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/intel/igbvf/igbvf.h 
b/drivers/net/ethernet/intel/igbvf/igbvf.h
index 6f4290d6dc9f..11c7238e612c 100644
--- a/drivers/net/ethernet/intel/igbvf/igbvf.h
+++ b/drivers/net/ethernet/intel/igbvf/igbvf.h
@@ -241,7 +241,6 @@ struct igbvf_adapter {
/* OS defined structs */
struct net_device *netdev;
struct pci_dev *pdev;
-   struct net_device_stats net_stats;
spinlock_t stats_lock; /* prevent concurrent stats updates */
 
/* structs defined in e1000_hw.h */
diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c 
b/drivers/net/ethernet/intel/igbvf/netdev.c
index 839ba110f7fb..0707d08f7d47 100644
--- a/drivers/net/ethernet/intel/igbvf/netdev.c
+++ b/drivers/net/ethernet/intel/igbvf/netdev.c
@@ -400,8 +400,8 @@ static bool igbvf_clean_rx_irq(struct igbvf_adapter 
*adapter,
 
adapter->total_rx_packets += total_packets;
adapter->total_rx_bytes += total_bytes;
-   adapter->net_stats.rx_bytes += total_bytes;
-   adapter->net_stats.rx_packets += total_packets;
+   netdev->stats.rx_bytes += total_bytes;
+   netdev->stats.rx_packets += total_packets;
return cleaned;
 }
 
@@ -864,8 +864,8 @@ static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring)
}
}
 
-   adapter->net_stats.tx_bytes += total_bytes;
-   adapter->net_stats.tx_packets += total_packets;
+   netdev->stats.tx_bytes += total_bytes;
+   netdev->stats.tx_packets += total_packets;
return count < tx_ring->count;
 }
 
@@ -1798,7 +1798,7 @@ void igbvf_update_stats(struct igbvf_adapter *adapter)
UPDATE_VF_COUNTER(VFGPRLBC, gprlbc);
 
/* Fill out the OS statistics structure */
-   adapter->net_stats.multicast = adapter->stats.mprc;
+   adapter->netdev->stats.multicast = adapter->stats.mprc;
 }
 
 static void igbvf_print_link_info(struct igbvf_adapter *adapter)
@@ -2334,21 +2334,6 @@ static void igbvf_reset_task(struct work_struct *work)
 }
 
 /**
- * igbvf_get_stats - Get System Network Statistics
- * @netdev: network interface device structure
- *
- * Returns the address of the device statistics structure.
- * The statistics are actually updated from the timer callback.
- **/
-static struct net_device_stats *igbvf_get_stats(struct net_device *netdev)
-{
-   struct igbvf_adapter *adapter = netdev_priv(netdev);
-
-   /* only return the current stats */
-   return >net_stats;
-}
-
-/**
  * igbvf_change_mtu - Change the Maximum Transfer Unit
  * @netdev: network interface device structure
  * @new_mtu: new value for maximum frame size
@@ -2635,7 +2620,6 @@ static const struct net_device_ops igbvf_netdev_ops = {
.ndo_open   = igbvf_open,
.ndo_stop   = igbvf_close,
.ndo_start_xmit = igbvf_xmit_frame,
-   .ndo_get_stats  = igbvf_get_stats,
.ndo_set_rx_mode= igbvf_set_multi,
.ndo_set_mac_address= igbvf_set_mac,
.ndo_change_mtu = igbvf_change_mtu,
-- 
2.12.2.399.g034667a45805




[PATCH] batman-adv: Use net_device_stats from struct net_device

2017-04-05 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
batadv_priv, use stats from struct net_device.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/batman-adv/distributed-arp-table.c | 9 +
 net/batman-adv/soft-interface.c| 2 +-
 net/batman-adv/types.h | 2 --
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/net/batman-adv/distributed-arp-table.c 
b/net/batman-adv/distributed-arp-table.c
index 1bfd1dbc2feb..936b08ee5b45 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -1002,6 +1002,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct 
batadv_priv *bat_priv,
bool ret = false;
struct batadv_dat_entry *dat_entry = NULL;
struct sk_buff *skb_new;
+   struct net_device *soft_iface = bat_priv->soft_iface;
int hdr_size = 0;
unsigned short vid;
 
@@ -1046,10 +1047,10 @@ bool batadv_dat_snoop_outgoing_arp_request(struct 
batadv_priv *bat_priv,
if (!skb_new)
goto out;
 
-   skb_new->protocol = eth_type_trans(skb_new,
-  bat_priv->soft_iface);
-   bat_priv->stats.rx_packets++;
-   bat_priv->stats.rx_bytes += skb->len + ETH_HLEN + hdr_size;
+   skb_new->protocol = eth_type_trans(skb_new, soft_iface);
+
+   soft_iface->stats.rx_packets++;
+   soft_iface->stats.rx_bytes += skb->len + ETH_HLEN + hdr_size;
 
netif_rx(skb_new);
batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied 
locally\n");
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index d042c99af028..71895c58e6d8 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -140,7 +140,7 @@ static u64 batadv_sum_counter(struct batadv_priv *bat_priv, 
 size_t idx)
 static struct net_device_stats *batadv_interface_stats(struct net_device *dev)
 {
struct batadv_priv *bat_priv = netdev_priv(dev);
-   struct net_device_stats *stats = _priv->stats;
+   struct net_device_stats *stats = >stats;
 
stats->tx_packets = batadv_sum_counter(bat_priv, BATADV_CNT_TX);
stats->tx_bytes = batadv_sum_counter(bat_priv, BATADV_CNT_TX_BYTES);
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 246f21b4973b..5c55e48d8941 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1000,7 +1000,6 @@ struct batadv_priv_bat_v {
  * struct batadv_priv - per mesh interface data
  * @mesh_state: current status of the mesh (inactive/active/deactivating)
  * @soft_iface: net device which holds this struct as private data
- * @stats: structure holding the data for the ndo_get_stats() call
  * @bat_counters: mesh internal traffic statistic counters (see 
batadv_counters)
  * @aggregated_ogms: bool indicating whether OGM aggregation is enabled
  * @bonding: bool indicating whether traffic bonding is enabled
@@ -1055,7 +1054,6 @@ struct batadv_priv_bat_v {
 struct batadv_priv {
atomic_t mesh_state;
struct net_device *soft_iface;
-   struct net_device_stats stats;
u64 __percpu *bat_counters; /* Per cpu counters */
atomic_t aggregated_ogms;
atomic_t bonding;
-- 
2.12.2.399.g034667a45805



[PATCH net-next] net: ibmvnic: Remove unused net_stats member from struct ibmvnic_adapter

2017-03-27 Thread Tobias Klauser
The ibmvnic driver keeps its statistics in net_device->stats, so the
net_stats member in struct ibmvnic_adapter is unused. Remove it.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/ibm/ibmvnic.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.h 
b/drivers/net/ethernet/ibm/ibmvnic.h
index 10ad259208cb..42ad648c174d 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.h
+++ b/drivers/net/ethernet/ibm/ibmvnic.h
@@ -953,7 +953,6 @@ struct ibmvnic_adapter {
dma_addr_t bounce_buffer_dma;
 
/* Statistics */
-   struct net_device_stats net_stats;
struct ibmvnic_statistics stats;
dma_addr_t stats_token;
struct completion stats_done;
-- 
2.11.0




[PATCH net-next] net: ibmveth: Remove unused stats member from struct ibmveth_adapter

2017-03-27 Thread Tobias Klauser
The ibmveth driver keeps its statistics in net_device->stats, so the
stats member in struct ibmveth_adapter is unused. Remove it.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/ibm/ibmveth.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/ibm/ibmveth.h 
b/drivers/net/ethernet/ibm/ibmveth.h
index 7acda04d034e..ed8780cca982 100644
--- a/drivers/net/ethernet/ibm/ibmveth.h
+++ b/drivers/net/ethernet/ibm/ibmveth.h
@@ -146,7 +146,6 @@ struct ibmveth_adapter {
 struct vio_dev *vdev;
 struct net_device *netdev;
 struct napi_struct napi;
-struct net_device_stats stats;
 unsigned int mcastFilterSize;
 void * buffer_list_addr;
 void * filter_list_addr;
-- 
2.11.0




[PATCH net-next] net: bfin_mac: Remove unused stats member from struct bfin_mac_local

2017-03-27 Thread Tobias Klauser
The bfin_mac driver keeps its statistics in net_device->stats, so the
stats member in struct bfin_mac_local is unused. Remove it, as well as
the accompanying comment.

Cc: adi-buildroot-de...@lists.sourceforge.net
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/adi/bfin_mac.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/net/ethernet/adi/bfin_mac.h 
b/drivers/net/ethernet/adi/bfin_mac.h
index 8c3b56198e4b..4ad5b9be3f84 100644
--- a/drivers/net/ethernet/adi/bfin_mac.h
+++ b/drivers/net/ethernet/adi/bfin_mac.h
@@ -68,13 +68,6 @@ struct net_dma_desc_tx {
 };
 
 struct bfin_mac_local {
-   /*
-* these are things that the kernel wants me to keep, so users
-* can find out semi-useless statistics of how well the card is
-* performing
-*/
-   struct net_device_stats stats;
-
spinlock_t lock;
 
int wol;/* Wake On Lan */
-- 
2.11.0




[PATCH net-next] net: greth: Utilize of_get_mac_address()

2017-03-21 Thread Tobias Klauser
Do not open code getting the MAC address exclusively from the
"local-mac-address" property, but instead use of_get_mac_address() which
looks up the MAC address using the 3 typical property names.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/aeroflex/greth.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/aeroflex/greth.c 
b/drivers/net/ethernet/aeroflex/greth.c
index 9f7422ada704..d8e133ced7b8 100644
--- a/drivers/net/ethernet/aeroflex/greth.c
+++ b/drivers/net/ethernet/aeroflex/greth.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1454,11 +1455,10 @@ static int greth_of_probe(struct platform_device *ofdev)
break;
}
if (i == 6) {
-   const unsigned char *addr;
-   int len;
-   addr = of_get_property(ofdev->dev.of_node, "local-mac-address",
-   );
-   if (addr != NULL && len == 6) {
+   const u8 *addr;
+
+   addr = of_get_mac_address(ofdev->dev.of_node);
+   if (addr) {
for (i = 0; i < 6; i++)
macaddr[i] = (unsigned int) addr[i];
} else {
-- 
2.11.0




[PATCH] batman-adv: Omit unnecessary memset of netdev private data

2017-03-17 Thread Tobias Klauser
The memory for netdev_priv is allocated using kzalloc in alloc_netdev
(or alloc_netdev_mq respectively) so there is no need to set it to 0
again.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/batman-adv/soft-interface.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 5d099b2e6cfc..8226495c6664 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -972,8 +972,6 @@ static void batadv_softif_free(struct net_device *dev)
  */
 static void batadv_softif_init_early(struct net_device *dev)
 {
-   struct batadv_priv *priv = netdev_priv(dev);
-
ether_setup(dev);
 
dev->netdev_ops = _netdev_ops;
@@ -990,8 +988,6 @@ static void batadv_softif_init_early(struct net_device *dev)
eth_hw_addr_random(dev);
 
dev->ethtool_ops = _ethtool_ops;
-
-   memset(priv, 0, sizeof(*priv));
 }
 
 struct net_device *batadv_softif_create(struct net *net, const char *name)
-- 
2.11.0




[PATCH net-next] net: ethoc: Use ether_addr_copy()

2017-03-17 Thread Tobias Klauser
Use ether_addr_copy() instead of memcpy() to set netdev->dev_addr (which
is 2-byte aligned).

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/ethoc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 23d82748f52b..e863ba74d005 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -1148,14 +1148,14 @@ static int ethoc_probe(struct platform_device *pdev)
 
/* Allow the platform setup code to pass in a MAC address. */
if (pdata) {
-   memcpy(netdev->dev_addr, pdata->hwaddr, IFHWADDRLEN);
+   ether_addr_copy(netdev->dev_addr, pdata->hwaddr);
priv->phy_id = pdata->phy_id;
} else {
const void *mac;
 
mac = of_get_mac_address(pdev->dev.of_node);
if (mac)
-   memcpy(netdev->dev_addr, mac, IFHWADDRLEN);
+   ether_addr_copy(netdev->dev_addr, mac);
priv->phy_id = -1;
}
 
-- 
2.11.0




[PATCH] net: mediatek: Use eth_hw_addr_random()

2017-03-07 Thread Tobias Klauser
Use eth_hw_addr_random() to set a random dev_addr and update
addr_assign_type instead of open-coding it.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c 
b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 9e757684816d..bf6317eca2f6 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1908,10 +1908,9 @@ static int __init mtk_init(struct net_device *dev)
 
/* If the mac address is invalid, use random mac address  */
if (!is_valid_ether_addr(dev->dev_addr)) {
-   random_ether_addr(dev->dev_addr);
+   eth_hw_addr_random(dev);
dev_err(eth->dev, "generated random MAC address %pM\n",
dev->dev_addr);
-   dev->addr_assign_type = NET_ADDR_RANDOM;
}
 
return mtk_phy_connect(dev);
-- 
2.11.0




[PATCH] net: axienet: use eth_hw_addr_random()

2017-02-28 Thread Tobias Klauser
Use eth_hw_addr_random() to set a random MAC address in order to make
sure ndev->addr_assign_type will be properly set to NET_ADDR_RANDOM.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c 
b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index b96e96919e31..33c595f4691d 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -301,7 +301,7 @@ static void axienet_set_mac_address(struct net_device *ndev,
if (address)
memcpy(ndev->dev_addr, address, ETH_ALEN);
if (!is_valid_ether_addr(ndev->dev_addr))
-   eth_random_addr(ndev->dev_addr);
+   eth_hw_addr_random(ndev);
 
/* Set up unicast MAC address filter set its mac address */
axienet_iow(lp, XAE_UAW0_OFFSET,
-- 
2.11.0




[PATCH] bnxt_en: use eth_hw_addr_random()

2017-02-21 Thread Tobias Klauser
Use eth_hw_addr_random() to set a random MAC address in order to make
sure bp->dev->addr_assign_type will be properly set to NET_ADDR_RANDOM.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 6dacdf1e4d26..235733e91c79 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4552,7 +4552,7 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp)
/* overwrite netdev dev_adr with admin VF MAC */
memcpy(bp->dev->dev_addr, vf->mac_addr, ETH_ALEN);
} else {
-   random_ether_addr(bp->dev->dev_addr);
+   eth_hw_addr_random(bp->dev);
rc = bnxt_approve_mac(bp, bp->dev->dev_addr);
}
return rc;
-- 
2.11.0




[PATCH] net/hsr: use eth_hw_addr_random()

2017-02-21 Thread Tobias Klauser
Use eth_hw_addr_random() to set a random MAC address in order to make sure
dev->addr_assign_type will be properly set to NET_ADDR_RANDOM.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/hsr/hsr_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
index fc65b145f6e7..c73160fb11e7 100644
--- a/net/hsr/hsr_device.c
+++ b/net/hsr/hsr_device.c
@@ -395,7 +395,7 @@ static struct device_type hsr_type = {
 
 void hsr_dev_setup(struct net_device *dev)
 {
-   random_ether_addr(dev->dev_addr);
+   eth_hw_addr_random(dev);
 
ether_setup(dev);
dev->min_mtu = 0;
-- 
2.11.0




[PATCH] rtnl: simplify error return path in rtnl_create_link()

2017-02-20 Thread Tobias Klauser
There is only one possible error path which reaches the err label, so
return ERR_PTR(-ENOMEM) directly if alloc_netdev_mqs() fails. This also
allows to omit the err variable.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/core/rtnetlink.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index e3286d32eca5..c4e84c558240 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2358,7 +2358,6 @@ struct net_device *rtnl_create_link(struct net *net,
const char *ifname, unsigned char name_assign_type,
const struct rtnl_link_ops *ops, struct nlattr *tb[])
 {
-   int err;
struct net_device *dev;
unsigned int num_tx_queues = 1;
unsigned int num_rx_queues = 1;
@@ -2373,11 +2372,10 @@ struct net_device *rtnl_create_link(struct net *net,
else if (ops->get_num_rx_queues)
num_rx_queues = ops->get_num_rx_queues();
 
-   err = -ENOMEM;
dev = alloc_netdev_mqs(ops->priv_size, ifname, name_assign_type,
   ops->setup, num_tx_queues, num_rx_queues);
if (!dev)
-   goto err;
+   return ERR_PTR(-ENOMEM);
 
dev_net_set(dev, net);
dev->rtnl_link_ops = ops;
@@ -2403,9 +2401,6 @@ struct net_device *rtnl_create_link(struct net *net,
dev_set_group(dev, nla_get_u32(tb[IFLA_GROUP]));
 
return dev;
-
-err:
-   return ERR_PTR(err);
 }
 EXPORT_SYMBOL(rtnl_create_link);
 
-- 
2.11.0




[PATCH] net: bgmac: store MAC address directly in netdev->dev_addr

2017-02-16 Thread Tobias Klauser
After commit 34a5102c3235 ("net: bgmac: allocate struct bgmac just once
& don't copy it") the mac_addr member of struct bgmac is no longer
necessary to pass the MAC address to bgmac_enet_probe(). Instead it can
directly be stored in netdev->dev_addr.

Also use eth_hw_addr_random() instead of eth_random_addr() in case a
random MAC is nedded. This will make sure netdev->addr_assign_type will
be properly set.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/broadcom/bgmac-bcma.c | 2 +-
 drivers/net/ethernet/broadcom/bgmac-platform.c | 2 +-
 drivers/net/ethernet/broadcom/bgmac.c  | 9 -
 drivers/net/ethernet/broadcom/bgmac.h  | 1 -
 4 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma.c 
b/drivers/net/ethernet/broadcom/bgmac-bcma.c
index 5ef60d4f12b4..d59cfcc4c4d5 100644
--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
+++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
@@ -144,7 +144,7 @@ static int bgmac_probe(struct bcma_device *core)
goto err;
}
 
-   ether_addr_copy(bgmac->mac_addr, mac);
+   ether_addr_copy(bgmac->net_dev->dev_addr, mac);
 
/* On BCM4706 we need common core to access PHY */
if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
diff --git a/drivers/net/ethernet/broadcom/bgmac-platform.c 
b/drivers/net/ethernet/broadcom/bgmac-platform.c
index 805e6ed6c390..7b1af950f312 100644
--- a/drivers/net/ethernet/broadcom/bgmac-platform.c
+++ b/drivers/net/ethernet/broadcom/bgmac-platform.c
@@ -169,7 +169,7 @@ static int bgmac_probe(struct platform_device *pdev)
 
mac_addr = of_get_mac_address(np);
if (mac_addr)
-   ether_addr_copy(bgmac->mac_addr, mac_addr);
+   ether_addr_copy(bgmac->net_dev->dev_addr, mac_addr);
else
dev_warn(>dev, "MAC address not present in device 
tree\n");
 
diff --git a/drivers/net/ethernet/broadcom/bgmac.c 
b/drivers/net/ethernet/broadcom/bgmac.c
index 20fe2520da42..415046750bb4 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1477,14 +1477,13 @@ int bgmac_enet_probe(struct bgmac *bgmac)
net_dev->irq = bgmac->irq;
SET_NETDEV_DEV(net_dev, bgmac->dev);
 
-   if (!is_valid_ether_addr(bgmac->mac_addr)) {
+   if (!is_valid_ether_addr(net_dev->dev_addr)) {
dev_err(bgmac->dev, "Invalid MAC addr: %pM\n",
-   bgmac->mac_addr);
-   eth_random_addr(bgmac->mac_addr);
+   net_dev->dev_addr);
+   eth_hw_addr_random(net_dev);
dev_warn(bgmac->dev, "Using random MAC: %pM\n",
-bgmac->mac_addr);
+net_dev->dev_addr);
}
-   ether_addr_copy(net_dev->dev_addr, bgmac->mac_addr);
 
/* This (reset &) enable is not preset in specs or reference driver but
 * Broadcom does it in arch PCI code when enabling fake PCI device.
diff --git a/drivers/net/ethernet/broadcom/bgmac.h 
b/drivers/net/ethernet/broadcom/bgmac.h
index ab2db76e4fb8..248727dc62f2 100644
--- a/drivers/net/ethernet/broadcom/bgmac.h
+++ b/drivers/net/ethernet/broadcom/bgmac.h
@@ -474,7 +474,6 @@ struct bgmac {
 
struct device *dev;
struct device *dma_dev;
-   unsigned char mac_addr[ETH_ALEN];
u32 feature_flags;
 
struct net_device *net_dev;
-- 
2.11.0




[PATCH] net: ethoc: Use eth_hw_addr_random()

2017-02-16 Thread Tobias Klauser
Use eth_hw_addr_random() to set a random dev_addr and update
addr_assign_type instead of open-coding it.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/ethoc.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index f18aba05f1c2..23d82748f52b 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -1031,7 +1031,6 @@ static int ethoc_probe(struct platform_device *pdev)
struct ethoc *priv = NULL;
int num_bd;
int ret = 0;
-   bool random_mac = false;
struct ethoc_platform_data *pdata = dev_get_platdata(>dev);
u32 eth_clkfreq = pdata ? pdata->eth_clkfreq : 0;
 
@@ -1169,16 +1168,11 @@ static int ethoc_probe(struct platform_device *pdev)
/* Check the MAC again for validity, if it still isn't choose and
 * program a random one.
 */
-   if (!is_valid_ether_addr(netdev->dev_addr)) {
-   eth_random_addr(netdev->dev_addr);
-   random_mac = true;
-   }
+   if (!is_valid_ether_addr(netdev->dev_addr))
+   eth_hw_addr_random(netdev);
 
ethoc_do_set_mac_address(netdev);
 
-   if (random_mac)
-   netdev->addr_assign_type = NET_ADDR_RANDOM;
-
/* Allow the platform setup code to adjust MII management bus clock. */
if (!eth_clkfreq) {
struct clk *clk = devm_clk_get(>dev, NULL);
-- 
2.11.0




[PATCH net-next] ixgb: Omit private ndo_get_stats function

2017-02-15 Thread Tobias Klauser
ixgb_get_stats() just returns dev->stats so we can leave it
out altogether and let dev_get_stats() do the job.

Suggested-by: Joe Perches <j...@perches.com>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/intel/ixgb/ixgb_main.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c 
b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
index fbd220d137b3..5a713199653c 100644
--- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c
+++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
@@ -86,7 +86,6 @@ static void ixgb_set_multi(struct net_device *netdev);
 static void ixgb_watchdog(unsigned long data);
 static netdev_tx_t ixgb_xmit_frame(struct sk_buff *skb,
   struct net_device *netdev);
-static struct net_device_stats *ixgb_get_stats(struct net_device *netdev);
 static int ixgb_change_mtu(struct net_device *netdev, int new_mtu);
 static int ixgb_set_mac(struct net_device *netdev, void *p);
 static irqreturn_t ixgb_intr(int irq, void *data);
@@ -367,7 +366,6 @@ static const struct net_device_ops ixgb_netdev_ops = {
.ndo_open   = ixgb_open,
.ndo_stop   = ixgb_close,
.ndo_start_xmit = ixgb_xmit_frame,
-   .ndo_get_stats  = ixgb_get_stats,
.ndo_set_rx_mode= ixgb_set_multi,
.ndo_validate_addr  = eth_validate_addr,
.ndo_set_mac_address= ixgb_set_mac,
@@ -1597,20 +1595,6 @@ ixgb_tx_timeout_task(struct work_struct *work)
 }
 
 /**
- * ixgb_get_stats - Get System Network Statistics
- * @netdev: network interface device structure
- *
- * Returns the address of the device statistics structure.
- * The statistics are actually updated from the timer callback.
- **/
-
-static struct net_device_stats *
-ixgb_get_stats(struct net_device *netdev)
-{
-   return >stats;
-}
-
-/**
  * ixgb_change_mtu - Change the Maximum Transfer Unit
  * @netdev: network interface device structure
  * @new_mtu: new value for maximum frame size
-- 
2.11.0




[PATCH net-next] e1000: Omit private ndo_get_stats function

2017-02-15 Thread Tobias Klauser
e1000_get_stats() just returns dev->stats so we can leave it
out altogether and let dev_get_stats() do the job.

Suggested-by: Joe Perches <j...@perches.com>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/intel/e1000/e1000_main.c | 15 ---
 1 file changed, 15 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c 
b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 93fc6c67306b..bd8b05fe8258 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -131,7 +131,6 @@ static void e1000_watchdog(struct work_struct *work);
 static void e1000_82547_tx_fifo_stall_task(struct work_struct *work);
 static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
struct net_device *netdev);
-static struct net_device_stats *e1000_get_stats(struct net_device *netdev);
 static int e1000_change_mtu(struct net_device *netdev, int new_mtu);
 static int e1000_set_mac(struct net_device *netdev, void *p);
 static irqreturn_t e1000_intr(int irq, void *data);
@@ -846,7 +845,6 @@ static const struct net_device_ops e1000_netdev_ops = {
.ndo_open   = e1000_open,
.ndo_stop   = e1000_close,
.ndo_start_xmit = e1000_xmit_frame,
-   .ndo_get_stats  = e1000_get_stats,
.ndo_set_rx_mode= e1000_set_rx_mode,
.ndo_set_mac_address= e1000_set_mac,
.ndo_tx_timeout = e1000_tx_timeout,
@@ -3530,19 +3528,6 @@ static void e1000_reset_task(struct work_struct *work)
 }
 
 /**
- * e1000_get_stats - Get System Network Statistics
- * @netdev: network interface device structure
- *
- * Returns the address of the device statistics structure.
- * The statistics are actually updated from the watchdog.
- **/
-static struct net_device_stats *e1000_get_stats(struct net_device *netdev)
-{
-   /* only return the current stats */
-   return >stats;
-}
-
-/**
  * e1000_change_mtu - Change the Maximum Transfer Unit
  * @netdev: network interface device structure
  * @new_mtu: new value for maximum frame size
-- 
2.11.0




Re: [PATCH] net: hip04: Omit private ndo_get_stats function

2017-02-15 Thread Tobias Klauser
On 2017-02-15 at 11:28:08 +0100, Joe Perches <j...@perches.com> wrote:
> On Tue, 2017-02-14 at 15:10 +0100, Tobias Klauser wrote:
> > hip04_get_stats() just returns dev->stats so we can leave it
> > out altogether and let dev_get_stats() do the job.
> 
> This could be done for at least a few more drivers:
> 
> drivers/net/ethernet/chelsio/cxgb/sge.c

I don't see an .ndo_get_stats being defined/set in this file. AFAICT,
this driver sets .ndo_get_stats to t1_get_stats(), which does some
additional extraction of statistics from device registers and thus
shouldn't be removed.

> drivers/net/ethernet/intel/e1000/e1000_main.c
> drivers/net/ethernet/intel/ixgb/ixgb_main.c

Will cover these in follow-up patches, thanks.

> drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c

A patch for pch_gbe already landed in net-next.


[PATCH] pch_gbe: Omit private ndo_get_stats function

2017-02-14 Thread Tobias Klauser
pch_gbe_get_stats() just returns dev->stats so we can leave it out
altogether and let dev_get_stats() do the job.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c 
b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index f9e4e8eca665..5ae9681a2da7 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -2149,17 +2149,6 @@ static int pch_gbe_xmit_frame(struct sk_buff *skb, 
struct net_device *netdev)
 }
 
 /**
- * pch_gbe_get_stats - Get System Network Statistics
- * @netdev:  Network interface device structure
- * Returns:  The current stats
- */
-static struct net_device_stats *pch_gbe_get_stats(struct net_device *netdev)
-{
-   /* only return the current stats */
-   return >stats;
-}
-
-/**
  * pch_gbe_set_multi - Multicast and Promiscuous mode set
  * @netdev:   Network interface device structure
  */
@@ -2420,7 +2409,6 @@ static const struct net_device_ops pch_gbe_netdev_ops = {
.ndo_open = pch_gbe_open,
.ndo_stop = pch_gbe_stop,
.ndo_start_xmit = pch_gbe_xmit_frame,
-   .ndo_get_stats = pch_gbe_get_stats,
.ndo_set_mac_address = pch_gbe_set_mac,
.ndo_tx_timeout = pch_gbe_tx_timeout,
.ndo_change_mtu = pch_gbe_change_mtu,
-- 
2.11.0




[PATCH] net: hip04: Omit private ndo_get_stats function

2017-02-14 Thread Tobias Klauser
hip04_get_stats() just returns dev->stats so we can leave it
out altogether and let dev_get_stats() do the job.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/hisilicon/hip04_eth.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c 
b/drivers/net/ethernet/hisilicon/hip04_eth.c
index 6e50ec82b3d8..0cec06bec63e 100644
--- a/drivers/net/ethernet/hisilicon/hip04_eth.c
+++ b/drivers/net/ethernet/hisilicon/hip04_eth.c
@@ -701,11 +701,6 @@ static void hip04_tx_timeout_task(struct work_struct *work)
hip04_mac_open(priv->ndev);
 }
 
-static struct net_device_stats *hip04_get_stats(struct net_device *ndev)
-{
-   return >stats;
-}
-
 static int hip04_get_coalesce(struct net_device *netdev,
  struct ethtool_coalesce *ec)
 {
@@ -764,7 +759,6 @@ static const struct ethtool_ops hip04_ethtool_ops = {
 static const struct net_device_ops hip04_netdev_ops = {
.ndo_open   = hip04_mac_open,
.ndo_stop   = hip04_mac_stop,
-   .ndo_get_stats  = hip04_get_stats,
.ndo_start_xmit = hip04_mac_start_xmit,
.ndo_set_mac_address= hip04_set_mac_address,
.ndo_tx_timeout = hip04_timeout,
-- 
2.11.0




[PATCH] brcmfmac: Use net_device_stats from struct net_device

2017-02-13 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
brcm_if, use stats from struct net_device.  Also remove the now
unnecessary .ndo_get_stats function.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 .../wireless/broadcom/brcm80211/brcmfmac/core.c| 26 +++---
 .../wireless/broadcom/brcm80211/brcmfmac/core.h|  2 --
 2 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index b73a55b00fa7..60da86a8d95b 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -249,10 +249,10 @@ static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff 
*skb,
 
 done:
if (ret) {
-   ifp->stats.tx_dropped++;
+   ndev->stats.tx_dropped++;
} else {
-   ifp->stats.tx_packets++;
-   ifp->stats.tx_bytes += skb->len;
+   ndev->stats.tx_packets++;
+   ndev->stats.tx_bytes += skb->len;
}
 
/* Return ok: we always eat the packet */
@@ -296,15 +296,15 @@ void brcmf_txflowblock(struct device *dev, bool state)
 void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff *skb)
 {
if (skb->pkt_type == PACKET_MULTICAST)
-   ifp->stats.multicast++;
+   ifp->ndev->stats.multicast++;
 
if (!(ifp->ndev->flags & IFF_UP)) {
brcmu_pkt_buf_free_skb(skb);
return;
}
 
-   ifp->stats.rx_bytes += skb->len;
-   ifp->stats.rx_packets++;
+   ifp->ndev->stats.rx_bytes += skb->len;
+   ifp->ndev->stats.rx_packets++;
 
brcmf_dbg(DATA, "rx proto=0x%X\n", ntohs(skb->protocol));
if (in_interrupt())
@@ -327,7 +327,7 @@ static int brcmf_rx_hdrpull(struct brcmf_pub *drvr, struct 
sk_buff *skb,
 
if (ret || !(*ifp) || !(*ifp)->ndev) {
if (ret != -ENODATA && *ifp)
-   (*ifp)->stats.rx_errors++;
+   (*ifp)->ndev->stats.rx_errors++;
brcmu_pkt_buf_free_skb(skb);
return -ENODATA;
}
@@ -388,7 +388,7 @@ void brcmf_txfinalize(struct brcmf_if *ifp, struct sk_buff 
*txp, bool success)
}
 
if (!success)
-   ifp->stats.tx_errors++;
+   ifp->ndev->stats.tx_errors++;
 
brcmu_pkt_buf_free_skb(txp);
 }
@@ -411,15 +411,6 @@ void brcmf_txcomplete(struct device *dev, struct sk_buff 
*txp, bool success)
}
 }
 
-static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *ndev)
-{
-   struct brcmf_if *ifp = netdev_priv(ndev);
-
-   brcmf_dbg(TRACE, "Enter, bsscfgidx=%d\n", ifp->bsscfgidx);
-
-   return >stats;
-}
-
 static void brcmf_ethtool_get_drvinfo(struct net_device *ndev,
struct ethtool_drvinfo *info)
 {
@@ -492,7 +483,6 @@ static int brcmf_netdev_open(struct net_device *ndev)
 static const struct net_device_ops brcmf_netdev_ops_pri = {
.ndo_open = brcmf_netdev_open,
.ndo_stop = brcmf_netdev_stop,
-   .ndo_get_stats = brcmf_netdev_get_stats,
.ndo_start_xmit = brcmf_netdev_start_xmit,
.ndo_set_mac_address = brcmf_netdev_set_mac_address,
.ndo_set_rx_mode = brcmf_netdev_set_multicast_list
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
index de3197be5491..6aecd8dfd824 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
@@ -171,7 +171,6 @@ enum brcmf_netif_stop_reason {
  * @drvr: points to device related information.
  * @vif: points to cfg80211 specific interface information.
  * @ndev: associated network device.
- * @stats: interface specific network statistics.
  * @multicast_work: worker object for multicast provisioning.
  * @ndoffload_work: worker object for neighbor discovery offload configuration.
  * @fws_desc: interface specific firmware-signalling descriptor.
@@ -187,7 +186,6 @@ struct brcmf_if {
struct brcmf_pub *drvr;
struct brcmf_cfg80211_vif *vif;
struct net_device *ndev;
-   struct net_device_stats stats;
struct work_struct multicast_work;
struct work_struct ndoffload_work;
struct brcmf_fws_mac_descriptor *fws_desc;
-- 
2.11.0




[PATCH net-next] net: make net_device members garp_port and mrp_port conditional

2017-02-10 Thread Tobias Klauser
garp_port is only used in net/802/garp.c which is only compiled with
CONFIG_GARP enabled. Same goes for mrp_port which is only used in
net/802/mrp.c with CONFIG_MRP enabled.

Only include the two members in struct net_device if their respective
CONFIG_* is enabled. This saves a few bytes in struct net_device in case
CONFIG_GARP or CONFIG_MRP are not enabled.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 include/linux/netdevice.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 58afbd1cc659..7bb38f2c65c2 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1863,8 +1863,12 @@ struct net_device {
struct pcpu_vstats __percpu *vstats;
};
 
+#if IS_ENABLED(CONFIG_GARP)
struct garp_port __rcu  *garp_port;
+#endif
+#if IS_ENABLED(CONFIG_MRP)
struct mrp_port __rcu   *mrp_port;
+#endif
 
struct device   dev;
const struct attribute_group *sysfs_groups[4];
-- 
2.11.0




[PATCH] orinoco: Use net_device_stats from struct net_device

2017-02-10 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in
struct orinoco_private, use stats from struct net_device. Also remove
the now unnecessary .ndo_get_stats function.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/wireless/intersil/orinoco/main.c   | 27 ++
 drivers/net/wireless/intersil/orinoco/orinoco.h|  2 --
 .../net/wireless/intersil/orinoco/orinoco_usb.c|  6 ++---
 3 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/drivers/net/wireless/intersil/orinoco/main.c 
b/drivers/net/wireless/intersil/orinoco/main.c
index 9d96b7c928f7..28cf97489001 100644
--- a/drivers/net/wireless/intersil/orinoco/main.c
+++ b/drivers/net/wireless/intersil/orinoco/main.c
@@ -294,14 +294,6 @@ int orinoco_stop(struct net_device *dev)
 }
 EXPORT_SYMBOL(orinoco_stop);
 
-struct net_device_stats *orinoco_get_stats(struct net_device *dev)
-{
-   struct orinoco_private *priv = ndev_priv(dev);
-
-   return >stats;
-}
-EXPORT_SYMBOL(orinoco_get_stats);
-
 void orinoco_set_multicast_list(struct net_device *dev)
 {
struct orinoco_private *priv = ndev_priv(dev);
@@ -433,7 +425,7 @@ EXPORT_SYMBOL(orinoco_process_xmit_skb);
 static netdev_tx_t orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
 {
struct orinoco_private *priv = ndev_priv(dev);
-   struct net_device_stats *stats = >stats;
+   struct net_device_stats *stats = >stats;
struct hermes *hw = >hw;
int err = 0;
u16 txfid = priv->txfid;
@@ -593,10 +585,7 @@ static void __orinoco_ev_alloc(struct net_device *dev, 
struct hermes *hw)
 
 static void __orinoco_ev_tx(struct net_device *dev, struct hermes *hw)
 {
-   struct orinoco_private *priv = ndev_priv(dev);
-   struct net_device_stats *stats = >stats;
-
-   stats->tx_packets++;
+   dev->stats.tx_packets++;
 
netif_wake_queue(dev);
 
@@ -605,8 +594,7 @@ static void __orinoco_ev_tx(struct net_device *dev, struct 
hermes *hw)
 
 static void __orinoco_ev_txexc(struct net_device *dev, struct hermes *hw)
 {
-   struct orinoco_private *priv = ndev_priv(dev);
-   struct net_device_stats *stats = >stats;
+   struct net_device_stats *stats = >stats;
u16 fid = hermes_read_regn(hw, TXCOMPLFID);
u16 status;
struct hermes_txexc_data hdr;
@@ -662,7 +650,7 @@ static void __orinoco_ev_txexc(struct net_device *dev, 
struct hermes *hw)
 void orinoco_tx_timeout(struct net_device *dev)
 {
struct orinoco_private *priv = ndev_priv(dev);
-   struct net_device_stats *stats = >stats;
+   struct net_device_stats *stats = >stats;
struct hermes *hw = >hw;
 
printk(KERN_WARNING "%s: Tx timeout! "
@@ -749,7 +737,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 
rxfid,
int len;
struct sk_buff *skb;
struct orinoco_private *priv = ndev_priv(dev);
-   struct net_device_stats *stats = >stats;
+   struct net_device_stats *stats = >stats;
struct hermes *hw = >hw;
 
len = le16_to_cpu(desc->data_len);
@@ -840,7 +828,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 
rxfid,
 void __orinoco_ev_rx(struct net_device *dev, struct hermes *hw)
 {
struct orinoco_private *priv = ndev_priv(dev);
-   struct net_device_stats *stats = >stats;
+   struct net_device_stats *stats = >stats;
struct iw_statistics *wstats = >wstats;
struct sk_buff *skb = NULL;
u16 rxfid, status;
@@ -959,7 +947,7 @@ static void orinoco_rx(struct net_device *dev,
   struct sk_buff *skb)
 {
struct orinoco_private *priv = ndev_priv(dev);
-   struct net_device_stats *stats = >stats;
+   struct net_device_stats *stats = >stats;
u16 status, fc;
int length;
struct ethhdr *hdr;
@@ -2137,7 +2125,6 @@ static const struct net_device_ops orinoco_netdev_ops = {
.ndo_set_mac_address= eth_mac_addr,
.ndo_validate_addr  = eth_validate_addr,
.ndo_tx_timeout = orinoco_tx_timeout,
-   .ndo_get_stats  = orinoco_get_stats,
 };
 
 /* Allocate private data.
diff --git a/drivers/net/wireless/intersil/orinoco/orinoco.h 
b/drivers/net/wireless/intersil/orinoco/orinoco.h
index 5fa1c3e3713f..430862a6a24b 100644
--- a/drivers/net/wireless/intersil/orinoco/orinoco.h
+++ b/drivers/net/wireless/intersil/orinoco/orinoco.h
@@ -84,7 +84,6 @@ struct orinoco_private {
 
/* Net device stuff */
struct net_device *ndev;
-   struct net_device_stats stats;
struct iw_statistics wstats;
 
/* Hardware control variables */
@@ -206,7 +205,6 @@ int orinoco_process_xmit_skb(struct sk_buff *skb,
 /* Common ndo functions exported for reuse by orinoco_usb */
 int orinoco_open(struct net_device *dev);
 int orinoco_stop(struct net_device *dev);
-struct net_device_stats *orinoco_get_stats(struc

[PATCH] ath6kl: Use net_device_stats from struct net_device

2017-02-09 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
ath6kl_vif, use stats from struct net_device. Also remove the now
unnecessary .ndo_get_stats function.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/wireless/ath/ath6kl/core.h |  1 -
 drivers/net/wireless/ath/ath6kl/main.c |  8 
 drivers/net/wireless/ath/ath6kl/txrx.c | 22 +++---
 3 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/core.h 
b/drivers/net/wireless/ath/ath6kl/core.h
index ac25f1781b42..87e99c12d4ba 100644
--- a/drivers/net/wireless/ath/ath6kl/core.h
+++ b/drivers/net/wireless/ath/ath6kl/core.h
@@ -641,7 +641,6 @@ struct ath6kl_vif {
u32 txe_intvl;
u16 bg_scan_period;
u8 assoc_bss_dtim_period;
-   struct net_device_stats net_stats;
struct target_stats target_stats;
struct wmi_connect_cmd profile;
u16 rsn_capab;
diff --git a/drivers/net/wireless/ath/ath6kl/main.c 
b/drivers/net/wireless/ath/ath6kl/main.c
index 1af3fed5a72c..91ee542de3d7 100644
--- a/drivers/net/wireless/ath/ath6kl/main.c
+++ b/drivers/net/wireless/ath/ath6kl/main.c
@@ -1113,13 +1113,6 @@ static int ath6kl_close(struct net_device *dev)
return 0;
 }
 
-static struct net_device_stats *ath6kl_get_stats(struct net_device *dev)
-{
-   struct ath6kl_vif *vif = netdev_priv(dev);
-
-   return >net_stats;
-}
-
 static int ath6kl_set_features(struct net_device *dev,
   netdev_features_t features)
 {
@@ -1285,7 +1278,6 @@ static const struct net_device_ops ath6kl_netdev_ops = {
.ndo_open   = ath6kl_open,
.ndo_stop   = ath6kl_close,
.ndo_start_xmit = ath6kl_data_tx,
-   .ndo_get_stats  = ath6kl_get_stats,
.ndo_set_features   = ath6kl_set_features,
.ndo_set_rx_mode= ath6kl_set_multicast_list,
 };
diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c 
b/drivers/net/wireless/ath/ath6kl/txrx.c
index 9df41d5e3249..a531e0c5c1e2 100644
--- a/drivers/net/wireless/ath/ath6kl/txrx.c
+++ b/drivers/net/wireless/ath/ath6kl/txrx.c
@@ -405,7 +405,7 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device 
*dev)
skb = skb_realloc_headroom(skb, dev->needed_headroom);
kfree_skb(tmp_skb);
if (skb == NULL) {
-   vif->net_stats.tx_dropped++;
+   dev->stats.tx_dropped++;
return 0;
}
}
@@ -520,8 +520,8 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device 
*dev)
 fail_tx:
dev_kfree_skb(skb);
 
-   vif->net_stats.tx_dropped++;
-   vif->net_stats.tx_aborted_errors++;
+   dev->stats.tx_dropped++;
+   dev->stats.tx_aborted_errors++;
 
return 0;
 }
@@ -767,7 +767,7 @@ void ath6kl_tx_complete(struct htc_target *target,
/* a packet was flushed  */
flushing[if_idx] = true;
 
-   vif->net_stats.tx_errors++;
+   vif->ndev->stats.tx_errors++;
 
if (status != -ENOSPC && status != -ECANCELED)
ath6kl_warn("tx complete error: %d\n", status);
@@ -783,8 +783,8 @@ void ath6kl_tx_complete(struct htc_target *target,
   eid, "OK");
 
flushing[if_idx] = false;
-   vif->net_stats.tx_packets++;
-   vif->net_stats.tx_bytes += skb->len;
+   vif->ndev->stats.tx_packets++;
+   vif->ndev->stats.tx_bytes += skb->len;
}
 
ath6kl_tx_clear_node_map(vif, eid, map_no);
@@ -1365,8 +1365,8 @@ void ath6kl_rx(struct htc_target *target, struct 
htc_packet *packet)
 */
spin_lock_bh(>if_lock);
 
-   vif->net_stats.rx_packets++;
-   vif->net_stats.rx_bytes += packet->act_len;
+   vif->ndev->stats.rx_packets++;
+   vif->ndev->stats.rx_bytes += packet->act_len;
 
spin_unlock_bh(>if_lock);
 
@@ -1395,8 +1395,8 @@ void ath6kl_rx(struct htc_target *target, struct 
htc_packet *packet)
((packet->act_len < min_hdr_len) ||
 (packet->act_len > WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH))) {
ath6kl_info("frame len is too short or too long\n");
-   vif->net_stats.rx_errors++;
-   vif->net_stats.rx_length_errors++;
+   vif->ndev->stats.rx_errors++;
+   vif->ndev->stats.rx_length_errors++;
dev_kfree_skb(skb);
return;
}
@@ -1619,7 +1619,7 @@ void ath6kl_rx(struct htc_target *target

[PATCH] net: wan: Remove unused stats member from struct frad_local

2017-01-27 Thread Tobias Klauser
The stats member of struct frad_locl is used neither by the dlci nor the
sdla driver, so it might as well be removed.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 include/linux/if_frad.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/linux/if_frad.h b/include/linux/if_frad.h
index 4316aa173dde..46df7e565d6f 100644
--- a/include/linux/if_frad.h
+++ b/include/linux/if_frad.h
@@ -66,8 +66,6 @@ struct dlci_local
 
 struct frad_local
 {
-   struct net_device_stats stats;
-
/* devices which this FRAD is slaved to */
struct net_device *master[CONFIG_DLCI_MAX];
short dlci[CONFIG_DLCI_MAX];
-- 
2.11.0




[PATCH net-next] net: caif: Remove unused stats member from struct chnl_net

2017-01-19 Thread Tobias Klauser
The stats member of struct chnl_net is used nowhere in the code, so it
might as well be removed.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/caif/chnl_net.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
index 3408ed51b611..1816fc9f1ee7 100644
--- a/net/caif/chnl_net.c
+++ b/net/caif/chnl_net.c
@@ -44,7 +44,6 @@ enum caif_states {
 
 struct chnl_net {
struct cflayer chnl;
-   struct net_device_stats stats;
struct caif_connect_request conn_req;
struct list_head list_field;
struct net_device *netdev;
-- 
2.11.0




[PATCH net-next] net: Remove usage of net_device last_rx member

2017-01-18 Thread Tobias Klauser
The network stack no longer uses the last_rx member of struct net_device
since the bonding driver switched to use its own private last_rx in
commit 9f242738376d ("bonding: use last_arp_rx in slave_last_rx()").

However, some drivers still (ab)use the field for their own purposes and
some driver just update it without actually using it.

Previously, there was an accompanying comment for the last_rx member
added in commit 4dc89133f49b ("net: add a comment on netdev->last_rx")
which asked drivers not to update is, unless really needed. However,
this commend was removed in commit f8ff080dacec ("bonding: remove
useless updating of slave->dev->last_rx"), so some drivers added later
on still did update last_rx.

Remove all usage of last_rx and switch three drivers (sky2, atp and
smc91c92_cs) which actually read and write it to use their own private
copy in netdev_priv.

Compile-tested with allyesconfig and allmodconfig on x86 and arm.

Cc: Eric Dumazet <eric.duma...@gmail.com>
Cc: Jay Vosburgh <j.vosbu...@gmail.com>
Cc: Veaceslav Falico <vfal...@gmail.com>
Cc: Andy Gospodarek <a...@greyhouse.net>
Cc: Mirko Lindner <mlind...@marvell.com>
Cc: Stephen Hemminger <step...@networkplumber.org>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 arch/m68k/emu/nfeth.c  | 1 -
 drivers/net/ethernet/cavium/liquidio/lio_main.c| 1 -
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 1 -
 drivers/net/ethernet/hisilicon/hns/hns_enet.c  | 1 -
 drivers/net/ethernet/intel/e1000e/netdev.c | 6 +++---
 drivers/net/ethernet/intel/igb/igb_main.c  | 6 +++---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c  | 7 +++
 drivers/net/ethernet/marvell/sky2.c| 6 +++---
 drivers/net/ethernet/marvell/sky2.h| 1 +
 drivers/net/ethernet/qualcomm/emac/emac-mac.c  | 1 -
 drivers/net/ethernet/realtek/atp.c | 7 +++
 drivers/net/ethernet/smsc/smc91c92_cs.c| 6 --
 drivers/net/irda/bfin_sir.c| 5 ++---
 drivers/net/irda/sh_sir.c  | 1 -
 drivers/staging/ks7010/ks_hostif.c | 2 --
 drivers/staging/netlogic/xlr_net.c | 1 -
 drivers/staging/rtl8192e/rtllib_rx.c   | 1 -
 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c  | 4 
 drivers/staging/wlan-ng/hfa384x_usb.c  | 1 -
 drivers/staging/wlan-ng/p80211netdev.c | 2 --
 include/linux/netdevice.h  | 3 ---
 net/batman-adv/bridge_loop_avoidance.c | 1 -
 net/batman-adv/distributed-arp-table.c | 1 -
 net/batman-adv/soft-interface.c| 2 --
 24 files changed, 22 insertions(+), 46 deletions(-)

diff --git a/arch/m68k/emu/nfeth.c b/arch/m68k/emu/nfeth.c
index fc4be028c418..e45ce4243aaa 100644
--- a/arch/m68k/emu/nfeth.c
+++ b/arch/m68k/emu/nfeth.c
@@ -124,7 +124,6 @@ static inline void recv_packet(struct net_device *dev)
 
skb->protocol = eth_type_trans(skb, dev);
netif_rx(skb);
-   dev->last_rx = jiffies;
dev->stats.rx_packets++;
dev->stats.rx_bytes += pktlen;
 
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 2b89ec291b8b..5ee3f007c613 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -2360,7 +2360,6 @@ liquidio_push_packet(u32 octeon_id 
__attribute__((unused)),
if (packet_was_received) {
droq->stats.rx_bytes_received += len;
droq->stats.rx_pkts_received++;
-   netdev->last_rx = jiffies;
} else {
droq->stats.rx_dropped++;
netif_info(lio, rx_err, lio->netdev,
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 19d88fb387ce..e96cf6cdecfd 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -1571,7 +1571,6 @@ liquidio_push_packet(u32 octeon_id 
__attribute__((unused)),
if (packet_was_received) {
droq->stats.rx_bytes_received += len;
droq->stats.rx_pkts_received++;
-   netdev->last_rx = jiffies;
} else {
droq->stats.rx_dropped++;
netif_info(lio, rx_err, lio->netdev,
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c 
b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index b7cb61385ad8..f7b75e96c1c3 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -797,7 +797,6 @@ static void hns_nic_rx_up_pro(struct hns_nic_

[PATCH] net: ethoc: Make needlessly global struct ethtool_ops static

2017-01-17 Thread Tobias Klauser
Make the needlessly global struct ethtool_ops ethoc_ethtool_ops static
to fix a sparse warning.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/ethoc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 63e5e14174ee..c45757af9ade 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -995,7 +995,7 @@ static int ethoc_set_ringparam(struct net_device *dev,
return 0;
 }
 
-const struct ethtool_ops ethoc_ethtool_ops = {
+static const struct ethtool_ops ethoc_ethtool_ops = {
.get_regs_len = ethoc_get_regs_len,
.get_regs = ethoc_get_regs,
.nway_reset = phy_ethtool_nway_reset,
-- 
2.11.0




Re: [PATCH] cxgb4: Remove redundant memset before memcpy

2017-01-14 Thread Tobias Klauser
On 2017-01-14 at 02:17:40 +0100, Shyam Saini <mayhs11sa...@gmail.com> wrote:
> The region set by the call to memset, immediately overwritten by
> the subsequent call to memcpy and thus makes the  memset redundant.
> 
> Also remove the memset((, 0, sizeof(info)) on line 398 because
> info is memcpy()'ed to before being used in the loop and it isn't
> used outside of the loop.
> 
> Signed-off-by: Shyam Saini <mayhs11sa...@gmail.com>

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>


Re: [PATCH] cxgb4: Remove redundant memset before memcpy

2017-01-13 Thread Tobias Klauser
On 2017-01-13 at 10:52:49 +0100, Shyam Saini  wrote:
> The region set by the call to memset, immediately overwritten by the
> subsequent call to memcpy and thus makes the  memset redundant
> 
> Signed-off-by: Shyam Saini 
> ---
>  drivers/net/ethernet/chelsio/cxgb4/sched.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/sched.c 
> b/drivers/net/ethernet/chelsio/cxgb4/sched.c
> index cbd68a8..5725693 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/sched.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/sched.c
> @@ -398,7 +398,6 @@ static struct sched_class *t4_sched_class_lookup(struct 
> port_info *pi,
>   struct ch_sched_params tp;
>  
>   memset(, 0, sizeof(info));

This memset is also redundant because info is memcpy()'ed to before
being used in the loop (and it isn't used outside of the loop).

> - memset(, 0, sizeof(tp));
>  
>   memcpy(, p, sizeof(tp));
>   /* Don't try to match class parameter */
> @@ -409,7 +408,6 @@ static struct sched_class *t4_sched_class_lookup(struct 
> port_info *pi,
>   if (e->state == SCHED_STATE_UNUSED)
>   continue;
>  
> - memset(, 0, sizeof(info));
>   memcpy(, >info, sizeof(info));
>   /* Don't try to match class parameter */
>   info.u.params.class = SCHED_CLS_NONE;
> @@ -458,7 +456,6 @@ static struct sched_class *t4_sched_class_alloc(struct 
> port_info *pi,
>   if (!e)
>   goto out;
>  
> - memset(, 0, sizeof(np));
>   memcpy(, p, sizeof(np));
>   np.u.params.class = e->idx;
>  
> -- 
> 2.7.4
> 


Re: [PATCH v3 3/8] nios2: put setup.h in uapi

2017-01-13 Thread Tobias Klauser
On 2017-01-13 at 11:46:41 +0100, Nicolas Dichtel <nicolas.dich...@6wind.com> 
wrote:
> This header file is exported, but from a userland pov, it's just a wrapper
> to asm-generic/setup.h.
> 
> Signed-off-by: Nicolas Dichtel <nicolas.dich...@6wind.com>

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>


[PATCH net-next] bpf: Remove unused but set variable in __bpf_lru_list_shrink_inactive()

2017-01-10 Thread Tobias Klauser
Remove the unused but set variable 'first_node' in
__bpf_lru_list_shrink_inactive() to fix the following GCC warning when
building with 'W=1':

  kernel/bpf/bpf_lru_list.c:216:41: warning: variable ‘first_node’ set but not 
used [-Wunused-but-set-variable]

Cc: Martin KaFai Lau <ka...@fb.com>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 kernel/bpf/bpf_lru_list.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/bpf/bpf_lru_list.c b/kernel/bpf/bpf_lru_list.c
index 89b7ef41c86b..d78501ee0609 100644
--- a/kernel/bpf/bpf_lru_list.c
+++ b/kernel/bpf/bpf_lru_list.c
@@ -213,11 +213,10 @@ __bpf_lru_list_shrink_inactive(struct bpf_lru *lru,
   enum bpf_lru_list_type tgt_free_type)
 {
struct list_head *inactive = >lists[BPF_LRU_LIST_T_INACTIVE];
-   struct bpf_lru_node *node, *tmp_node, *first_node;
+   struct bpf_lru_node *node, *tmp_node;
unsigned int nshrinked = 0;
unsigned int i = 0;
 
-   first_node = list_first_entry(inactive, struct bpf_lru_node, list);
list_for_each_entry_safe_reverse(node, tmp_node, inactive, list) {
if (bpf_lru_node_is_ref(node)) {
__bpf_lru_node_move(l, node, BPF_LRU_LIST_T_ACTIVE);
-- 
2.11.0




[PATCH net-next] bpf: Make unnecessarily global functions static

2017-01-10 Thread Tobias Klauser
Make the functions __local_list_pop_free(), __local_list_pop_pending(),
bpf_common_lru_populate() and bpf_percpu_lru_populate() static as they
are not used outide of bpf_lru_list.c

This fixes the following GCC warnings when building with 'W=1':

  kernel/bpf/bpf_lru_list.c:363:22: warning: no previous prototype for 
‘__local_list_pop_free’ [-Wmissing-prototypes]
  kernel/bpf/bpf_lru_list.c:376:22: warning: no previous prototype for 
‘__local_list_pop_pending’ [-Wmissing-prototypes]
  kernel/bpf/bpf_lru_list.c:560:6: warning: no previous prototype for 
‘bpf_common_lru_populate’ [-Wmissing-prototypes]
  kernel/bpf/bpf_lru_list.c:577:6: warning: no previous prototype for 
‘bpf_percpu_lru_populate’ [-Wmissing-prototypes]

Cc: Martin KaFai Lau <ka...@fb.com>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 kernel/bpf/bpf_lru_list.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/kernel/bpf/bpf_lru_list.c b/kernel/bpf/bpf_lru_list.c
index d78501ee0609..f62d1d56f41d 100644
--- a/kernel/bpf/bpf_lru_list.c
+++ b/kernel/bpf/bpf_lru_list.c
@@ -360,7 +360,8 @@ static void __local_list_add_pending(struct bpf_lru *lru,
list_add(>list, local_pending_list(loc_l));
 }
 
-struct bpf_lru_node *__local_list_pop_free(struct bpf_lru_locallist *loc_l)
+static struct bpf_lru_node *
+__local_list_pop_free(struct bpf_lru_locallist *loc_l)
 {
struct bpf_lru_node *node;
 
@@ -373,8 +374,8 @@ struct bpf_lru_node *__local_list_pop_free(struct 
bpf_lru_locallist *loc_l)
return node;
 }
 
-struct bpf_lru_node *__local_list_pop_pending(struct bpf_lru *lru,
- struct bpf_lru_locallist *loc_l)
+static struct bpf_lru_node *
+__local_list_pop_pending(struct bpf_lru *lru, struct bpf_lru_locallist *loc_l)
 {
struct bpf_lru_node *node;
bool force = false;
@@ -557,8 +558,9 @@ void bpf_lru_push_free(struct bpf_lru *lru, struct 
bpf_lru_node *node)
bpf_common_lru_push_free(lru, node);
 }
 
-void bpf_common_lru_populate(struct bpf_lru *lru, void *buf, u32 node_offset,
-u32 elem_size, u32 nr_elems)
+static void bpf_common_lru_populate(struct bpf_lru *lru, void *buf,
+   u32 node_offset, u32 elem_size,
+   u32 nr_elems)
 {
struct bpf_lru_list *l = >common_lru.lru_list;
u32 i;
@@ -574,8 +576,9 @@ void bpf_common_lru_populate(struct bpf_lru *lru, void 
*buf, u32 node_offset,
}
 }
 
-void bpf_percpu_lru_populate(struct bpf_lru *lru, void *buf, u32 node_offset,
-u32 elem_size, u32 nr_elems)
+static void bpf_percpu_lru_populate(struct bpf_lru *lru, void *buf,
+   u32 node_offset, u32 elem_size,
+   u32 nr_elems)
 {
u32 i, pcpu_entries;
int cpu;
-- 
2.11.0




[PATCH net] net: socket: Make unnecessarily global sockfs_setattr() static

2017-01-10 Thread Tobias Klauser
Make sockfs_setattr() static as it is not used outside of net/socket.c

This fixes the following GCC warning:
net/socket.c:534:5: warning: no previous prototype for ‘sockfs_setattr’ 
[-Wmissing-prototypes]

Fixes: 86741ec25462 ("net: core: Add a UID field to struct sock.")
Cc: Lorenzo Colitti <lore...@google.com>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/socket.c b/net/socket.c
index 009dd12ab7f3..727dfd96da07 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -531,7 +531,7 @@ static ssize_t sockfs_listxattr(struct dentry *dentry, char 
*buffer,
return used;
 }
 
-int sockfs_setattr(struct dentry *dentry, struct iattr *iattr)
+static int sockfs_setattr(struct dentry *dentry, struct iattr *iattr)
 {
int err = simple_setattr(dentry, iattr);
 
-- 
2.11.0




[PATCH] net: xilinx: emaclite: Remove xemaclite_remove_ndev()

2017-01-05 Thread Tobias Klauser
xemaclite_remove_ndev() is a simple wrapper around free_netdev()
checking for NULL before the call. All possible paths calling
it are guaranteed to pass a non-NULL argument, so rather call
free_netdev() directly.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 18 ++
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c 
b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 93dc10b10c09..97dcc0bd5a85 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1029,20 +1029,6 @@ static int xemaclite_send(struct sk_buff *orig_skb, 
struct net_device *dev)
 }
 
 /**
- * xemaclite_remove_ndev - Free the network device
- * @ndev:  Pointer to the network device to be freed
- *
- * This function un maps the IO region of the Emaclite device and frees the net
- * device.
- */
-static void xemaclite_remove_ndev(struct net_device *ndev)
-{
-   if (ndev) {
-   free_netdev(ndev);
-   }
-}
-
-/**
  * get_bool - Get a parameter from the OF device
  * @ofdev: Pointer to OF device structure
  * @s: Property to be retrieved
@@ -1172,7 +1158,7 @@ static int xemaclite_of_probe(struct platform_device 
*ofdev)
return 0;
 
 error:
-   xemaclite_remove_ndev(ndev);
+   free_netdev(ndev);
return rc;
 }
 
@@ -1204,7 +1190,7 @@ static int xemaclite_of_remove(struct platform_device 
*of_dev)
of_node_put(lp->phy_node);
lp->phy_node = NULL;
 
-   xemaclite_remove_ndev(ndev);
+   free_netdev(ndev);
 
return 0;
 }
-- 
2.11.0




[PATCH] net: ethoc: Remove unused members from struct ethoc

2017-01-05 Thread Tobias Klauser
The io_region_size and dma_alloc members of struct ethoc are only
written but never read, so they might as well be removed.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/ethoc.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 45abc81f6f55..63e5e14174ee 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -180,8 +180,6 @@ MODULE_PARM_DESC(buffer_size, "DMA buffer allocation size");
  * struct ethoc - driver-private device structure
  * @iobase:pointer to I/O memory region
  * @membase:   pointer to buffer memory region
- * @dma_alloc: dma allocated buffer size
- * @io_region_size:I/O memory region size
  * @num_bd:number of buffer descriptors
  * @num_tx:number of send buffers
  * @cur_tx:last send buffer written
@@ -199,8 +197,6 @@ MODULE_PARM_DESC(buffer_size, "DMA buffer allocation size");
 struct ethoc {
void __iomem *iobase;
void __iomem *membase;
-   int dma_alloc;
-   resource_size_t io_region_size;
bool big_endian;
 
unsigned int num_bd;
@@ -1096,8 +1092,6 @@ static int ethoc_probe(struct platform_device *pdev)
/* setup driver-private data */
priv = netdev_priv(netdev);
priv->netdev = netdev;
-   priv->dma_alloc = 0;
-   priv->io_region_size = resource_size(mmio);
 
priv->iobase = devm_ioremap_nocache(>dev, netdev->base_addr,
resource_size(mmio));
@@ -1127,7 +1121,6 @@ static int ethoc_probe(struct platform_device *pdev)
goto free;
}
netdev->mem_end = netdev->mem_start + buffer_size;
-   priv->dma_alloc = buffer_size;
}
 
priv->big_endian = pdata ? pdata->big_endian :
-- 
2.11.0




[PATCH] ethernet: sfc: Add Kconfig entry for vendor Solarflare

2016-12-20 Thread Tobias Klauser
Since commit

  5a6681e22c14 ("sfc: separate out SFC4000 ("Falcon") support into new 
sfc-falcon driver")

there are two drivers for Solarflare devices, but both still show up
directly beneath "Ethernet driver support" in the Kconfig. Follow the
pattern of other vendors and group them beneath an own vendor Kconfig
entry for Solarflare.

Cc: Edward Cree <ec...@solarflare.com>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/Kconfig |  1 -
 drivers/net/ethernet/sfc/Kconfig | 21 +
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
index 6e16e441f85e..e4c28fed61d5 100644
--- a/drivers/net/ethernet/Kconfig
+++ b/drivers/net/ethernet/Kconfig
@@ -166,7 +166,6 @@ source "drivers/net/ethernet/seeq/Kconfig"
 source "drivers/net/ethernet/silan/Kconfig"
 source "drivers/net/ethernet/sis/Kconfig"
 source "drivers/net/ethernet/sfc/Kconfig"
-source "drivers/net/ethernet/sfc/falcon/Kconfig"
 source "drivers/net/ethernet/sgi/Kconfig"
 source "drivers/net/ethernet/smsc/Kconfig"
 source "drivers/net/ethernet/stmicro/Kconfig"
diff --git a/drivers/net/ethernet/sfc/Kconfig b/drivers/net/ethernet/sfc/Kconfig
index 46f7be85f5a3..2c032629c369 100644
--- a/drivers/net/ethernet/sfc/Kconfig
+++ b/drivers/net/ethernet/sfc/Kconfig
@@ -1,3 +1,20 @@
+#
+# Solarflare device configuration
+#
+
+config NET_VENDOR_SOLARFLARE
+   bool "Solarflare devices"
+   default y
+   ---help---
+ If you have a network (Ethernet) card belonging to this class, say Y.
+
+ Note that the answer to this question doesn't directly affect the
+ kernel: saying N will just cause the configurator to skip all
+ the questions about Solarflare devices. If you say Y, you will be 
asked
+ for your specific card in the following questions.
+
+if NET_VENDOR_SOLARFLARE
+
 config SFC
tristate "Solarflare SFC9000/SFC9100-family support"
depends on PCI
@@ -44,3 +61,7 @@ config SFC_MCDI_LOGGING
  Driver-Interface) commands and responses, allowing debugging of
  driver/firmware interaction.  The tracing is actually enabled by
  a sysfs file 'mcdi_logging' under the PCI device.
+
+source "drivers/net/ethernet/sfc/falcon/Kconfig"
+
+endif # NET_VENDOR_SOLARFLARE
-- 
2.11.0




Re: [PATCH] net: ipv4: tcp_offload: check segs for NULL

2016-12-15 Thread Tobias Klauser
On 2016-12-15 at 09:47:41 +0100, shakya@samsung.com 
 wrote:
> From: Shakya Sundar Das 
> 
> This patch will check segs for being NULL in tcp_gso_segment()
> before calling skb_shinfo(segs) from skb_is_gso(segs), otherwise
> kernel can run into a NULL-pointer dereference.

How can segs ever be NULL here? skb_segment() will always either return
an skb or an ERR_PTR(err).


[PATCH] net: ethernet: slicoss: use module_pci_driver()

2016-12-07 Thread Tobias Klauser
Use module_pci_driver() to get rid of some boilerplate code.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/alacritech/slicoss.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/alacritech/slicoss.c 
b/drivers/net/ethernet/alacritech/slicoss.c
index e77ecd5b307c..b9fbd0107008 100644
--- a/drivers/net/ethernet/alacritech/slicoss.c
+++ b/drivers/net/ethernet/alacritech/slicoss.c
@@ -1863,18 +1863,7 @@ static struct pci_driver slic_driver = {
.remove = slic_remove,
 };
 
-static int __init slic_init_module(void)
-{
-   return pci_register_driver(_driver);
-}
-
-static void __exit slic_cleanup_module(void)
-{
-   pci_unregister_driver(_driver);
-}
-
-module_init(slic_init_module);
-module_exit(slic_cleanup_module);
+module_pci_driver(slic_driver);
 
 MODULE_DESCRIPTION("Alacritech non-accelerated SLIC driver");
 MODULE_AUTHOR("Lino Sanfilippo <linosanfili...@gmx.de>");
-- 
2.11.0




Re: [PATCH] net: axienet: Utilize of_get_mac_address()

2016-12-07 Thread Tobias Klauser
On 2016-12-07 at 13:25:28 +0100, Tobias Klauser <tklau...@distanz.ch> wrote:
> Do not open code getting the MAC address exclusively from the
> "local-mac-address" property, but instead use of_get_mac_address()
> which looks up the MAC address using the 3 typical property names.
> 
> Also avoid casting away the const qualifier of the return value by
> making axienet_set_mac_address() take a const void* address.
> 
> Follows commit b34296a9c047 ("net: ethoc: Utilize
> of_get_mac_address()").
> 
> Cc: Florian Fainelli <f.faine...@gmail.com>
> Signed-off-by: Tobias Klauser <tklau...@distanz.ch>

Sorry for the duplicate, please disregard this patch.


[PATCH] net: axienet: Utilize of_get_mac_address()

2016-12-07 Thread Tobias Klauser
Do not open code getting the MAC address exclusively from the
"local-mac-address" property, but instead use of_get_mac_address()
which looks up the MAC address using the 3 typical property names.

Also avoid casting away the const qualifier of the return value by
making axienet_set_mac_address() take a const void* address.

Follows commit b34296a9c047 ("net: ethoc: Utilize
of_get_mac_address()").

Cc: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c 
b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index c9c8a3be9f1b..b96e96919e31 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -292,7 +293,8 @@ static int axienet_dma_bd_init(struct net_device *ndev)
  * This function is called to initialize the MAC address of the Axi Ethernet
  * core. It writes to the UAW0 and UAW1 registers of the core.
  */
-static void axienet_set_mac_address(struct net_device *ndev, void *address)
+static void axienet_set_mac_address(struct net_device *ndev,
+   const void *address)
 {
struct axienet_local *lp = netdev_priv(ndev);
 
@@ -1456,7 +1458,7 @@ static int axienet_probe(struct platform_device *pdev)
struct device_node *np;
struct axienet_local *lp;
struct net_device *ndev;
-   u8 mac_addr[6];
+   const void *mac_addr;
struct resource *ethres, dmares;
u32 value;
 
@@ -1567,13 +1569,12 @@ static int axienet_probe(struct platform_device *pdev)
}
 
/* Retrieve the MAC address */
-   ret = of_property_read_u8_array(pdev->dev.of_node,
-   "local-mac-address", mac_addr, 6);
-   if (ret) {
+   mac_addr = of_get_mac_address(pdev->dev.of_node);
+   if (!mac_addr) {
dev_err(>dev, "could not find MAC address\n");
goto free_netdev;
}
-   axienet_set_mac_address(ndev, (void *)mac_addr);
+   axienet_set_mac_address(ndev, mac_addr);
 
lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD;
lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD;
-- 
2.11.0




[PATCH] net: ll_temac: Utilize of_get_mac_address()

2016-12-07 Thread Tobias Klauser
Do not open code getting the MAC address exclusively from the
"local-mac-address" property, but instead use of_get_mac_address()
which looks up the MAC address using the 3 typical property names.

Also avoid casting away the const qualifier of the return value by
making temac_init_mac_address() take a const void* address.

Follows commit b34296a9c047 ("net: ethoc: Utilize
of_get_mac_address()").

Cc: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/xilinx/ll_temac_main.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c 
b/drivers/net/ethernet/xilinx/ll_temac_main.c
index bcd7b76dde9f..d73da8afe08e 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -332,7 +333,7 @@ static void temac_do_set_mac_address(struct net_device 
*ndev)
mutex_unlock(>indirect_mutex);
 }
 
-static int temac_init_mac_address(struct net_device *ndev, void *address)
+static int temac_init_mac_address(struct net_device *ndev, const void *address)
 {
memcpy(ndev->dev_addr, address, ETH_ALEN);
if (!is_valid_ether_addr(ndev->dev_addr))
@@ -982,7 +983,7 @@ static int temac_of_probe(struct platform_device *op)
struct net_device *ndev;
const void *addr;
__be32 *p;
-   int size, rc = 0;
+   int rc = 0;
 
/* Init network device structure */
ndev = alloc_etherdev(sizeof(*lp));
@@ -1074,13 +1075,13 @@ static int temac_of_probe(struct platform_device *op)
 
 
/* Retrieve the MAC address */
-   addr = of_get_property(op->dev.of_node, "local-mac-address", );
-   if ((!addr) || (size != 6)) {
+   addr = of_get_mac_address(op->dev.of_node);
+   if (!addr) {
dev_err(>dev, "could not find MAC address\n");
rc = -ENODEV;
goto err_iounmap_2;
}
-   temac_init_mac_address(ndev, (void *)addr);
+   temac_init_mac_address(ndev, addr);
 
rc = temac_mdio_setup(lp, op->dev.of_node);
if (rc)
-- 
2.11.0




[PATCH] net: axienet: Utilize of_get_mac_address()

2016-12-07 Thread Tobias Klauser
Do not open code getting the MAC address exclusively from the
"local-mac-address" property, but instead use of_get_mac_address()
which looks up the MAC address using the 3 typical property names.

Also avoid casting away the const qualifier of the return value by
making axienet_set_mac_address() take a const void* address.

Follows commit b34296a9c047 ("net: ethoc: Utilize
of_get_mac_address()").

Cc: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c 
b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index c9c8a3be9f1b..b96e96919e31 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -292,7 +293,8 @@ static int axienet_dma_bd_init(struct net_device *ndev)
  * This function is called to initialize the MAC address of the Axi Ethernet
  * core. It writes to the UAW0 and UAW1 registers of the core.
  */
-static void axienet_set_mac_address(struct net_device *ndev, void *address)
+static void axienet_set_mac_address(struct net_device *ndev,
+   const void *address)
 {
struct axienet_local *lp = netdev_priv(ndev);
 
@@ -1456,7 +1458,7 @@ static int axienet_probe(struct platform_device *pdev)
struct device_node *np;
struct axienet_local *lp;
struct net_device *ndev;
-   u8 mac_addr[6];
+   const void *mac_addr;
struct resource *ethres, dmares;
u32 value;
 
@@ -1567,13 +1569,12 @@ static int axienet_probe(struct platform_device *pdev)
}
 
/* Retrieve the MAC address */
-   ret = of_property_read_u8_array(pdev->dev.of_node,
-   "local-mac-address", mac_addr, 6);
-   if (ret) {
+   mac_addr = of_get_mac_address(pdev->dev.of_node);
+   if (!mac_addr) {
dev_err(>dev, "could not find MAC address\n");
goto free_netdev;
}
-   axienet_set_mac_address(ndev, (void *)mac_addr);
+   axienet_set_mac_address(ndev, mac_addr);
 
lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD;
lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD;
-- 
2.11.0




Re: [PATCH net-next 3/3] net: ethoc: Demote packet dropped error message to debug

2016-12-04 Thread Tobias Klauser
On 2016-12-04 at 21:40:30 +0100, Florian Fainelli <f.faine...@gmail.com> wrote:
> Spamming the console with: net eth1: packet dropped can happen
> fairly frequently if the adapter is busy transmitting, demote the
> message to a debug print.
> 
> Signed-off-by: Florian Fainelli <f.faine...@gmail.com>

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>


Re: [PATCH net-next 1/3] net: ethoc: Account for duplex changes

2016-12-04 Thread Tobias Klauser
On 2016-12-04 at 21:40:28 +0100, Florian Fainelli <f.faine...@gmail.com> wrote:
> ethoc_mdio_poll() which is our PHYLIB adjust_link callback does nothing,
> we should at least react to duplex changes and change MODER accordingly.
> Speed changes is not a problem, since the OpenCores Ethernet core seems
> to be reacting okay without us telling it.
> 
> Signed-off-by: Florian Fainelli <f.faine...@gmail.com>

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>


Re: [PATCH net-next 2/3] net: ethoc: Utilize of_get_mac_address()

2016-12-04 Thread Tobias Klauser
On 2016-12-04 at 21:40:29 +0100, Florian Fainelli <f.faine...@gmail.com> wrote:
> Do not open code getting the MAC address exclusively from the
> "local-mac-address" property, but instead use of_get_mac_address() which
> looks up the MAC address using the 3 typical property names.
> 
> Signed-off-by: Florian Fainelli <f.faine...@gmail.com>

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>


[PATCH] net/rtnetlink: fix attribute name in nlmsg_size() comments

2016-11-30 Thread Tobias Klauser
Use the correct attribute constant names IFLA_GSO_MAX_{SEGS,SIZE}
instead of IFLA_MAX_GSO_{SEGS,SIZE} for the comments int nlmsg_size().

Cc: Eric Dumazet <eduma...@google.com>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/core/rtnetlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index deb35acbefd0..a6196cf844f6 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -931,8 +931,8 @@ static noinline size_t if_nlmsg_size(const struct 
net_device *dev,
   + nla_total_size(4) /* IFLA_PROMISCUITY */
   + nla_total_size(4) /* IFLA_NUM_TX_QUEUES */
   + nla_total_size(4) /* IFLA_NUM_RX_QUEUES */
-  + nla_total_size(4) /* IFLA_MAX_GSO_SEGS */
-  + nla_total_size(4) /* IFLA_MAX_GSO_SIZE */
+  + nla_total_size(4) /* IFLA_GSO_MAX_SEGS */
+  + nla_total_size(4) /* IFLA_GSO_MAX_SIZE */
   + nla_total_size(1) /* IFLA_OPERSTATE */
   + nla_total_size(1) /* IFLA_LINKMODE */
   + nla_total_size(4) /* IFLA_CARRIER_CHANGES */
-- 
2.11.0




[PATCH] ehea: Remove unnecessary memset of stats in netdev private data

2016-11-29 Thread Tobias Klauser
The memory for netdev private data is allocated using kzalloc/vzalloc in
alloc_netdev_mqs, thus there is no need to zero the stats portion of it
again in the driver's probe function.

In any case, the size for the memset is wrong as the stats member is of
type rtnl_link_stats64, not net_device_stats.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/ibm/ehea/ehea_main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c 
b/drivers/net/ethernet/ibm/ehea/ehea_main.c
index fa66fa6f8bee..702446a93697 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_main.c
+++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c
@@ -3044,7 +3044,6 @@ static struct ehea_port *ehea_setup_single_port(struct 
ehea_adapter *adapter,
init_waitqueue_head(>swqe_avail_wq);
init_waitqueue_head(>restart_wq);
 
-   memset(>stats, 0, sizeof(struct net_device_stats));
ret = register_netdev(dev);
if (ret) {
pr_err("register_netdev failed. ret=%d\n", ret);
-- 
2.11.0.rc3.5.g7cdf2ab.dirty




Re: [PATCH net-next 2/5] net: ethoc: Implement ethtool::nway_reset

2016-11-15 Thread Tobias Klauser
On 2016-11-15 at 20:19:46 +0100, Florian Fainelli <f.faine...@gmail.com> wrote:
> Implement ethtool::nway_reset using phy_ethtool_nway_reset. We are
> already using dev->phydev all over the place so this comes for free.
> 
> Signed-off-by: Florian Fainelli <f.faine...@gmail.com>

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>


[PATCH] vhost/scsi: Remove unused but set variable

2016-11-11 Thread Tobias Klauser
Remove the unused but set variable se_tpg in vhost_scsi_nexus_cb() to
fix the following GCC warning when building with 'W=1':

  drivers/vhost/scsi.c:1752:26: warning: variable ‘se_tpg’ set but not used

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/vhost/scsi.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 6e29d053843d..e2be447752c2 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -1749,7 +1749,6 @@ static int vhost_scsi_nexus_cb(struct se_portal_group 
*se_tpg,
 static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg,
const char *name)
 {
-   struct se_portal_group *se_tpg;
struct vhost_scsi_nexus *tv_nexus;
 
mutex_lock(>tv_tpg_mutex);
@@ -1758,7 +1757,6 @@ static int vhost_scsi_make_nexus(struct vhost_scsi_tpg 
*tpg,
pr_debug("tpg->tpg_nexus already exists\n");
return -EEXIST;
}
-   se_tpg = >se_tpg;
 
tv_nexus = kzalloc(sizeof(struct vhost_scsi_nexus), GFP_KERNEL);
if (!tv_nexus) {
-- 
2.11.0.rc0.7.gbe5a750




[PATCH] vhost/vsock: Remove unused but set variable

2016-11-11 Thread Tobias Klauser
Remove the unused but set variable vq in vhost_transport_send_pkt() to
fix the following GCC warning when building with 'W=1':

  drivers/vhost/vsock.c:198:26: warning: variable ‘vq’ set but not used

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/vhost/vsock.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
index e3b30ea9ece5..9c3c68b9a49e 100644
--- a/drivers/vhost/vsock.c
+++ b/drivers/vhost/vsock.c
@@ -195,7 +195,6 @@ static int
 vhost_transport_send_pkt(struct virtio_vsock_pkt *pkt)
 {
struct vhost_vsock *vsock;
-   struct vhost_virtqueue *vq;
int len = pkt->len;
 
/* Find the vhost_vsock according to guest context id  */
@@ -205,8 +204,6 @@ vhost_transport_send_pkt(struct virtio_vsock_pkt *pkt)
return -ENODEV;
}
 
-   vq = >vqs[VSOCK_VQ_RX];
-
if (pkt->reply)
atomic_inc(>queued_replies);
 
-- 
2.11.0.rc0.7.gbe5a750




Re: [mm PATCH v3 12/23] arch/nios2: Add option to skip DMA sync as a part of map and unmap

2016-11-11 Thread Tobias Klauser
On 2016-11-10 at 12:35:18 +0100, Alexander Duyck <alexander.h.du...@intel.com> 
wrote:
> This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
> avoid invoking cache line invalidation if the driver will just handle it
> via a sync_for_cpu or sync_for_device call.
> 
> Cc: Ley Foon Tan <lf...@altera.com>
> Signed-off-by: Alexander Duyck <alexander.h.du...@intel.com>

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>


[PATCH] bpf: Remove unused but set variables

2016-11-08 Thread Tobias Klauser
Remove the unused but set variables min_set and max_set in
adjust_reg_min_max_vals to fix the following warning when building with
'W=1':

  kernel/bpf/verifier.c:1483:7: warning: variable ‘min_set’ set but not used 
[-Wunused-but-set-variable]

There is no warning about max_set being unused, but since it is only
used in the assignment of min_set it can be removed as well.

They were introduced in commit 484611357c19 ("bpf: allow access into map
value arrays") but seem to have never been used.

Cc: Josef Bacik <jba...@fb.com>
Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 kernel/bpf/verifier.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 846d7ceaf202..14345be4a2d2 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1480,7 +1480,6 @@ static void adjust_reg_min_max_vals(struct 
bpf_verifier_env *env,
 {
struct bpf_reg_state *regs = env->cur_state.regs, *dst_reg;
u64 min_val = BPF_REGISTER_MIN_RANGE, max_val = BPF_REGISTER_MAX_RANGE;
-   bool min_set = false, max_set = false;
u8 opcode = BPF_OP(insn->code);
 
dst_reg = [insn->dst_reg];
@@ -1503,7 +1502,6 @@ static void adjust_reg_min_max_vals(struct 
bpf_verifier_env *env,
} else if (insn->imm < BPF_REGISTER_MAX_RANGE &&
   (s64)insn->imm > BPF_REGISTER_MIN_RANGE) {
min_val = max_val = insn->imm;
-   min_set = max_set = true;
}
 
/* We don't know anything about what was done to this register, mark it
-- 
2.9.0




[PATCH] net: fs_enet: Use net_device_stats from struct net_device

2016-10-19 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in struct
fs_enet_private, use stats from struct net_device. Also remove the now
unnecessary .ndo_get_stats function.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 .../net/ethernet/freescale/fs_enet/fs_enet-main.c  | 43 +-
 drivers/net/ethernet/freescale/fs_enet/fs_enet.h   |  1 -
 2 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c 
b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
index 925d1bca6a26..44f50e168703 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -118,22 +118,22 @@ static int fs_enet_napi(struct napi_struct *napi, int 
budget)
  BD_ENET_TX_RL | BD_ENET_TX_UN | BD_ENET_TX_CSL)) {
 
if (sc & BD_ENET_TX_HB) /* No heartbeat */
-   fep->stats.tx_heartbeat_errors++;
+   dev->stats.tx_heartbeat_errors++;
if (sc & BD_ENET_TX_LC) /* Late collision */
-   fep->stats.tx_window_errors++;
+   dev->stats.tx_window_errors++;
if (sc & BD_ENET_TX_RL) /* Retrans limit */
-   fep->stats.tx_aborted_errors++;
+   dev->stats.tx_aborted_errors++;
if (sc & BD_ENET_TX_UN) /* Underrun */
-   fep->stats.tx_fifo_errors++;
+   dev->stats.tx_fifo_errors++;
if (sc & BD_ENET_TX_CSL)/* Carrier lost */
-   fep->stats.tx_carrier_errors++;
+   dev->stats.tx_carrier_errors++;
 
if (sc & (BD_ENET_TX_LC | BD_ENET_TX_RL | 
BD_ENET_TX_UN)) {
-   fep->stats.tx_errors++;
+   dev->stats.tx_errors++;
do_restart = 1;
}
} else
-   fep->stats.tx_packets++;
+   dev->stats.tx_packets++;
 
if (sc & BD_ENET_TX_READY) {
dev_warn(fep->dev,
@@ -145,7 +145,7 @@ static int fs_enet_napi(struct napi_struct *napi, int 
budget)
 * but we eventually sent the packet OK.
 */
if (sc & BD_ENET_TX_DEF)
-   fep->stats.collisions++;
+   dev->stats.collisions++;
 
/* unmap */
if (fep->mapped_as_page[dirtyidx])
@@ -212,19 +212,19 @@ static int fs_enet_napi(struct napi_struct *napi, int 
budget)
 */
if (sc & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_CL |
  BD_ENET_RX_NO | BD_ENET_RX_CR | BD_ENET_RX_OV)) {
-   fep->stats.rx_errors++;
+   dev->stats.rx_errors++;
/* Frame too long or too short. */
if (sc & (BD_ENET_RX_LG | BD_ENET_RX_SH))
-   fep->stats.rx_length_errors++;
+   dev->stats.rx_length_errors++;
/* Frame alignment */
if (sc & (BD_ENET_RX_NO | BD_ENET_RX_CL))
-   fep->stats.rx_frame_errors++;
+   dev->stats.rx_frame_errors++;
/* CRC Error */
if (sc & BD_ENET_RX_CR)
-   fep->stats.rx_crc_errors++;
+   dev->stats.rx_crc_errors++;
/* FIFO overrun */
if (sc & BD_ENET_RX_OV)
-   fep->stats.rx_crc_errors++;
+   dev->stats.rx_crc_errors++;
 
skbn = fep->rx_skbuff[curidx];
} else {
@@ -233,9 +233,9 @@ static int fs_enet_napi(struct napi_struct *napi, int 
budget)
/*
 * Process the incoming frame.
 */
-   fep->stats.rx_packets++;
+   dev->stats.rx_packets++;
pkt_len = CBDR_DATLEN(bdp) - 4; /* remove CRC */
-   fep->stats.rx_bytes += pkt_len + 4;
+   dev->stats.rx_bytes += pkt_len + 4;
 
if (pkt_len <= fpi->rx_copybreak) {
/* +2 to make IP header L1 cache aligned */
@@ -277,7 +277,7 @@ static int fs_enet_napi(struct napi_struct *napi, int 
budget)
received++;
  

[PATCH] tcp: Remove unused but set variable

2016-10-18 Thread Tobias Klauser
Remove the unused but set variable icsk in listening_get_next to fix the
following GCC warning when building with 'W=1':

  net/ipv4/tcp_ipv4.c: In function ‘listening_get_next’:
  net/ipv4/tcp_ipv4.c:1890:31: warning: variable ‘icsk’ set but not used 
[-Wunused-but-set-variable]

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/ipv4/tcp_ipv4.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index bd5e8d10893f..79d55eb3ec3f 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1887,7 +1887,6 @@ static void *listening_get_next(struct seq_file *seq, 
void *cur)
struct tcp_iter_state *st = seq->private;
struct net *net = seq_file_net(seq);
struct inet_listen_hashbucket *ilb;
-   struct inet_connection_sock *icsk;
struct sock *sk = cur;
 
if (!sk) {
@@ -1909,7 +1908,6 @@ static void *listening_get_next(struct seq_file *seq, 
void *cur)
continue;
if (sk->sk_family == st->family)
return sk;
-   icsk = inet_csk(sk);
}
spin_unlock_bh(>lock);
st->offset = 0;
-- 
2.9.0




[PATCH] ipv4: Remove unused but set variable

2016-10-18 Thread Tobias Klauser
Remove the unused but set variable dev in ip_do_fragment to fix the
following GCC warning when building with 'W=1':

  net/ipv4/ip_output.c: In function ‘ip_do_fragment’:
  net/ipv4/ip_output.c:541:21: warning: variable ‘dev’ set but not used 
[-Wunused-but-set-variable]

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/ipv4/ip_output.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 05d105832bdb..03e7f7310423 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -538,7 +538,6 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct 
sk_buff *skb,
 {
struct iphdr *iph;
int ptr;
-   struct net_device *dev;
struct sk_buff *skb2;
unsigned int mtu, hlen, left, len, ll_rs;
int offset;
@@ -546,8 +545,6 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct 
sk_buff *skb,
struct rtable *rt = skb_rtable(skb);
int err = 0;
 
-   dev = rt->dst.dev;
-
/* for offloaded checksums cleanup checksum before fragmentation */
if (skb->ip_summed == CHECKSUM_PARTIAL &&
(err = skb_checksum_help(skb)))
-- 
2.9.0




[PATCH] net/hsr: Remove unused but set variable

2016-10-18 Thread Tobias Klauser
Remove the unused but set variable master_dev in check_local_dest to fix
the following GCC warning when building with 'W=1':

  net/hsr/hsr_forward.c: In function ‘check_local_dest’:
  net/hsr/hsr_forward.c:303:21: warning: variable ‘master_dev’ set but not used 
[-Wunused-but-set-variable]

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/hsr/hsr_forward.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
index 5ee1d43f1310..4ebe2aa3e7d3 100644
--- a/net/hsr/hsr_forward.c
+++ b/net/hsr/hsr_forward.c
@@ -300,10 +300,6 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
 static void check_local_dest(struct hsr_priv *hsr, struct sk_buff *skb,
 struct hsr_frame_info *frame)
 {
-   struct net_device *master_dev;
-
-   master_dev = hsr_port_get_hsr(hsr, HSR_PT_MASTER)->dev;
-
if (hsr_addr_is_self(hsr, eth_hdr(skb)->h_dest)) {
frame->is_local_exclusive = true;
skb->pkt_type = PACKET_HOST;
-- 
2.9.0




[PATCH] vlan: Remove unnecessary comparison of unsigned against 0

2016-10-18 Thread Tobias Klauser
args.u.name_type is of type unsigned int and is always >= 0.

This fixes the following GCC warning:

  net/8021q/vlan.c: In function ‘vlan_ioctl_handler’:
  net/8021q/vlan.c:574:14: warning: comparison of unsigned expression >= 0 is 
always true [-Wtype-limits]

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 net/8021q/vlan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 8de138d3306b..f8903c1e1010 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -571,8 +571,7 @@ static int vlan_ioctl_handler(struct net *net, void __user 
*arg)
err = -EPERM;
if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
break;
-   if ((args.u.name_type >= 0) &&
-   (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
+   if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
struct vlan_net *vn;
 
vn = net_generic(net, vlan_net_id);
-- 
2.9.0




[PATCH] net: hip04: Remove superfluous ether_setup after alloc_etherdev

2016-10-17 Thread Tobias Klauser
There is no need to call ether_setup after alloc_ethdev since it was
already called there.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/hisilicon/hip04_eth.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c 
b/drivers/net/ethernet/hisilicon/hip04_eth.c
index 3c99ca420f57..854befde0a08 100644
--- a/drivers/net/ethernet/hisilicon/hip04_eth.c
+++ b/drivers/net/ethernet/hisilicon/hip04_eth.c
@@ -897,7 +897,6 @@ static int hip04_mac_probe(struct platform_device *pdev)
 
INIT_WORK(>tx_timeout_task, hip04_tx_timeout_task);
 
-   ether_setup(ndev);
ndev->netdev_ops = _netdev_ops;
ndev->ethtool_ops = _ethtool_ops;
ndev->watchdog_timeo = TX_TIMEOUT;
-- 
2.9.0




Re: [PATCH] net: axienet: Remove unused parameter from __axienet_device_reset

2016-10-13 Thread Tobias Klauser
On 2016-10-13 at 14:23:49 +0200, Michal Simek <michal.si...@xilinx.com> wrote:
> On 13.10.2016 13:28, Tobias Klauser wrote:
> > The dev parameter passed to __axienet_device_reset() is not used inside
> > the function, so remove it.
> > 
> > Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
> > ---
> >  drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 11 +--
> >  1 file changed, 5 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c 
> > b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> > index 35f9f9742a48..c688d68c39aa 100644
> > --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> > +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> > @@ -431,8 +431,7 @@ static void axienet_setoptions(struct net_device *ndev, 
> > u32 options)
> > lp->options |= options;
> >  }
> >  
> > -static void __axienet_device_reset(struct axienet_local *lp,
> > -  struct device *dev, off_t offset)
> > +static void __axienet_device_reset(struct axienet_local *lp, off_t offset)
> >  {
> > u32 timeout;
> > /* Reset Axi DMA. This would reset Axi Ethernet core as well. The reset
> > @@ -468,8 +467,8 @@ static void axienet_device_reset(struct net_device 
> > *ndev)
> > u32 axienet_status;
> > struct axienet_local *lp = netdev_priv(ndev);
> >  
> > -   __axienet_device_reset(lp, >dev, XAXIDMA_TX_CR_OFFSET);
> > -   __axienet_device_reset(lp, >dev, XAXIDMA_RX_CR_OFFSET);
> > +   __axienet_device_reset(lp, XAXIDMA_TX_CR_OFFSET);
> > +   __axienet_device_reset(lp, XAXIDMA_RX_CR_OFFSET);
> >  
> > lp->max_frm_size = XAE_MAX_VLAN_FRAME_SIZE;
> > lp->options |= XAE_OPTION_VLAN;
> > @@ -1338,8 +1337,8 @@ static void axienet_dma_err_handler(unsigned long 
> > data)
> > axienet_iow(lp, XAE_MDIO_MC_OFFSET, (mdio_mcreg &
> > ~XAE_MDIO_MC_MDIOEN_MASK));
> >  
> > -   __axienet_device_reset(lp, >dev, XAXIDMA_TX_CR_OFFSET);
> > -   __axienet_device_reset(lp, >dev, XAXIDMA_RX_CR_OFFSET);
> > +   __axienet_device_reset(lp, XAXIDMA_TX_CR_OFFSET);
> > +   __axienet_device_reset(lp, XAXIDMA_RX_CR_OFFSET);
> >  
> > axienet_iow(lp, XAE_MDIO_MC_OFFSET, mdio_mcreg);
> > axienet_mdio_wait_until_ready(lp);
> > 
> 
> Can you please send this directly to mainline?
> And put my:
> Reviewed-by: Michal Simek <michal.si...@xilinx.com>

The netdev mailing list was Cc'ed on the patch, so it should end up in
davem's patch queue.

Thanks


[PATCH] net: axienet: Remove unused parameter from __axienet_device_reset

2016-10-13 Thread Tobias Klauser
The dev parameter passed to __axienet_device_reset() is not used inside
the function, so remove it.

Signed-off-by: Tobias Klauser <tklau...@distanz.ch>
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c 
b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 35f9f9742a48..c688d68c39aa 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -431,8 +431,7 @@ static void axienet_setoptions(struct net_device *ndev, u32 
options)
lp->options |= options;
 }
 
-static void __axienet_device_reset(struct axienet_local *lp,
-  struct device *dev, off_t offset)
+static void __axienet_device_reset(struct axienet_local *lp, off_t offset)
 {
u32 timeout;
/* Reset Axi DMA. This would reset Axi Ethernet core as well. The reset
@@ -468,8 +467,8 @@ static void axienet_device_reset(struct net_device *ndev)
u32 axienet_status;
struct axienet_local *lp = netdev_priv(ndev);
 
-   __axienet_device_reset(lp, >dev, XAXIDMA_TX_CR_OFFSET);
-   __axienet_device_reset(lp, >dev, XAXIDMA_RX_CR_OFFSET);
+   __axienet_device_reset(lp, XAXIDMA_TX_CR_OFFSET);
+   __axienet_device_reset(lp, XAXIDMA_RX_CR_OFFSET);
 
lp->max_frm_size = XAE_MAX_VLAN_FRAME_SIZE;
lp->options |= XAE_OPTION_VLAN;
@@ -1338,8 +1337,8 @@ static void axienet_dma_err_handler(unsigned long data)
axienet_iow(lp, XAE_MDIO_MC_OFFSET, (mdio_mcreg &
~XAE_MDIO_MC_MDIOEN_MASK));
 
-   __axienet_device_reset(lp, >dev, XAXIDMA_TX_CR_OFFSET);
-   __axienet_device_reset(lp, >dev, XAXIDMA_RX_CR_OFFSET);
+   __axienet_device_reset(lp, XAXIDMA_TX_CR_OFFSET);
+   __axienet_device_reset(lp, XAXIDMA_RX_CR_OFFSET);
 
axienet_iow(lp, XAE_MDIO_MC_OFFSET, mdio_mcreg);
axienet_mdio_wait_until_ready(lp);
-- 
2.9.0




Re: [PATCH v2 2/2] net: ethernet: ethoc: use phy_ethtool_{get|set}_link_ksettings

2016-07-15 Thread Tobias Klauser
On 2016-07-15 at 09:59:12 +0200, Philippe Reynes <trem...@gmail.com> wrote:
> There are two generics functions phy_ethtool_{get|set}_link_ksettings,
> so we can use them instead of defining the same code in the driver.
> 
> Signed-off-by: Philippe Reynes <trem...@gmail.com>

Reviewed-by: Tobias Klauser <tklau...@distanz.ch>

Thanks


  1   2   >