* [PATCH v2 net-next 2/6] net: sock: allow eBPF programs to be attached to sockets
From: Alexei Starovoitov @ 2014-12-01 23:06 UTC (permalink / raw)
To: David S. Miller
Cc: Ingo Molnar, Andy Lutomirski, Daniel Borkmann,
Hannes Frederic Sowa, Eric Dumazet,
linux-api-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1417475199-15950-1-git-send-email-ast-uqk4Ao+rVK5Wk0Htik3J/w@public.gmane.org>
introduce new setsockopt() command:
setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd, sizeof(prog_fd))
where prog_fd was received from syscall bpf(BPF_PROG_LOAD, attr, ...)
and attr->prog_type == BPF_PROG_TYPE_SOCKET_FILTER
setsockopt() calls bpf_prog_get() which increments refcnt of the program,
so it doesn't get unloaded while socket is using the program.
The same eBPF program can be attached to multiple sockets.
User task exit automatically closes socket which calls sk_filter_uncharge()
which decrements refcnt of eBPF program
Signed-off-by: Alexei Starovoitov <ast-uqk4Ao+rVK5Wk0Htik3J/w@public.gmane.org>
---
v2: no changes
Note, I'm not happy about 'ifdef', but 'select or depend BPF_SYSCALL' will
make tinification folks cringe, so use ifdef until native eBPF use cases
become widespread.
arch/alpha/include/uapi/asm/socket.h | 3 +
arch/avr32/include/uapi/asm/socket.h | 3 +
arch/cris/include/uapi/asm/socket.h | 3 +
arch/frv/include/uapi/asm/socket.h | 3 +
arch/ia64/include/uapi/asm/socket.h | 3 +
arch/m32r/include/uapi/asm/socket.h | 3 +
arch/mips/include/uapi/asm/socket.h | 3 +
arch/mn10300/include/uapi/asm/socket.h | 3 +
arch/parisc/include/uapi/asm/socket.h | 3 +
arch/powerpc/include/uapi/asm/socket.h | 3 +
arch/s390/include/uapi/asm/socket.h | 3 +
arch/sparc/include/uapi/asm/socket.h | 3 +
arch/xtensa/include/uapi/asm/socket.h | 3 +
include/linux/bpf.h | 4 ++
include/linux/filter.h | 1 +
include/uapi/asm-generic/socket.h | 3 +
net/core/filter.c | 97 +++++++++++++++++++++++++++++++-
net/core/sock.c | 13 +++++
18 files changed, 155 insertions(+), 2 deletions(-)
diff --git a/arch/alpha/include/uapi/asm/socket.h b/arch/alpha/include/uapi/asm/socket.h
index e2fe0700b3b4..9a20821b111c 100644
--- a/arch/alpha/include/uapi/asm/socket.h
+++ b/arch/alpha/include/uapi/asm/socket.h
@@ -89,4 +89,7 @@
#define SO_INCOMING_CPU 49
+#define SO_ATTACH_BPF 50
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
#endif /* _UAPI_ASM_SOCKET_H */
diff --git a/arch/avr32/include/uapi/asm/socket.h b/arch/avr32/include/uapi/asm/socket.h
index 92121b0f5b98..2b65ed6b277c 100644
--- a/arch/avr32/include/uapi/asm/socket.h
+++ b/arch/avr32/include/uapi/asm/socket.h
@@ -82,4 +82,7 @@
#define SO_INCOMING_CPU 49
+#define SO_ATTACH_BPF 50
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
#endif /* _UAPI__ASM_AVR32_SOCKET_H */
diff --git a/arch/cris/include/uapi/asm/socket.h b/arch/cris/include/uapi/asm/socket.h
index 60f60f5b9b35..e2503d9f1869 100644
--- a/arch/cris/include/uapi/asm/socket.h
+++ b/arch/cris/include/uapi/asm/socket.h
@@ -84,6 +84,9 @@
#define SO_INCOMING_CPU 49
+#define SO_ATTACH_BPF 50
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
#endif /* _ASM_SOCKET_H */
diff --git a/arch/frv/include/uapi/asm/socket.h b/arch/frv/include/uapi/asm/socket.h
index 2c6890209ea6..4823ad125578 100644
--- a/arch/frv/include/uapi/asm/socket.h
+++ b/arch/frv/include/uapi/asm/socket.h
@@ -82,5 +82,8 @@
#define SO_INCOMING_CPU 49
+#define SO_ATTACH_BPF 50
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
#endif /* _ASM_SOCKET_H */
diff --git a/arch/ia64/include/uapi/asm/socket.h b/arch/ia64/include/uapi/asm/socket.h
index 09a93fb566f6..59be3d87f86d 100644
--- a/arch/ia64/include/uapi/asm/socket.h
+++ b/arch/ia64/include/uapi/asm/socket.h
@@ -91,4 +91,7 @@
#define SO_INCOMING_CPU 49
+#define SO_ATTACH_BPF 50
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
#endif /* _ASM_IA64_SOCKET_H */
diff --git a/arch/m32r/include/uapi/asm/socket.h b/arch/m32r/include/uapi/asm/socket.h
index e8589819c274..7bc4cb273856 100644
--- a/arch/m32r/include/uapi/asm/socket.h
+++ b/arch/m32r/include/uapi/asm/socket.h
@@ -82,4 +82,7 @@
#define SO_INCOMING_CPU 49
+#define SO_ATTACH_BPF 50
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
#endif /* _ASM_M32R_SOCKET_H */
diff --git a/arch/mips/include/uapi/asm/socket.h b/arch/mips/include/uapi/asm/socket.h
index 2e9ee8c55a10..dec3c850f36b 100644
--- a/arch/mips/include/uapi/asm/socket.h
+++ b/arch/mips/include/uapi/asm/socket.h
@@ -100,4 +100,7 @@
#define SO_INCOMING_CPU 49
+#define SO_ATTACH_BPF 50
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
#endif /* _UAPI_ASM_SOCKET_H */
diff --git a/arch/mn10300/include/uapi/asm/socket.h b/arch/mn10300/include/uapi/asm/socket.h
index f3492e8c9f70..cab7d6d50051 100644
--- a/arch/mn10300/include/uapi/asm/socket.h
+++ b/arch/mn10300/include/uapi/asm/socket.h
@@ -82,4 +82,7 @@
#define SO_INCOMING_CPU 49
+#define SO_ATTACH_BPF 50
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
#endif /* _ASM_SOCKET_H */
diff --git a/arch/parisc/include/uapi/asm/socket.h b/arch/parisc/include/uapi/asm/socket.h
index 7984a1cab3da..a5cd40cd8ee1 100644
--- a/arch/parisc/include/uapi/asm/socket.h
+++ b/arch/parisc/include/uapi/asm/socket.h
@@ -81,4 +81,7 @@
#define SO_INCOMING_CPU 0x402A
+#define SO_ATTACH_BPF 0x402B
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
#endif /* _UAPI_ASM_SOCKET_H */
diff --git a/arch/powerpc/include/uapi/asm/socket.h b/arch/powerpc/include/uapi/asm/socket.h
index 3474e4ef166d..c046666038f8 100644
--- a/arch/powerpc/include/uapi/asm/socket.h
+++ b/arch/powerpc/include/uapi/asm/socket.h
@@ -89,4 +89,7 @@
#define SO_INCOMING_CPU 49
+#define SO_ATTACH_BPF 50
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
#endif /* _ASM_POWERPC_SOCKET_H */
diff --git a/arch/s390/include/uapi/asm/socket.h b/arch/s390/include/uapi/asm/socket.h
index 8457636c33e1..296942d56e6a 100644
--- a/arch/s390/include/uapi/asm/socket.h
+++ b/arch/s390/include/uapi/asm/socket.h
@@ -88,4 +88,7 @@
#define SO_INCOMING_CPU 49
+#define SO_ATTACH_BPF 50
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
#endif /* _ASM_SOCKET_H */
diff --git a/arch/sparc/include/uapi/asm/socket.h b/arch/sparc/include/uapi/asm/socket.h
index 4a8003a94163..e6a16c40be5f 100644
--- a/arch/sparc/include/uapi/asm/socket.h
+++ b/arch/sparc/include/uapi/asm/socket.h
@@ -78,6 +78,9 @@
#define SO_INCOMING_CPU 0x0033
+#define SO_ATTACH_BPF 0x0034
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
/* Security levels - as per NRL IPv6 - don't actually do anything */
#define SO_SECURITY_AUTHENTICATION 0x5001
#define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
diff --git a/arch/xtensa/include/uapi/asm/socket.h b/arch/xtensa/include/uapi/asm/socket.h
index c46f6a696849..4120af086160 100644
--- a/arch/xtensa/include/uapi/asm/socket.h
+++ b/arch/xtensa/include/uapi/asm/socket.h
@@ -93,4 +93,7 @@
#define SO_INCOMING_CPU 49
+#define SO_ATTACH_BPF 50
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
#endif /* _XTENSA_SOCKET_H */
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 75e94eaa228b..bbfceb756452 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -128,7 +128,11 @@ struct bpf_prog_aux {
struct work_struct work;
};
+#ifdef CONFIG_BPF_SYSCALL
void bpf_prog_put(struct bpf_prog *prog);
+#else
+static inline void bpf_prog_put(struct bpf_prog *prog) {}
+#endif
struct bpf_prog *bpf_prog_get(u32 ufd);
/* verify correctness of eBPF program */
int bpf_check(struct bpf_prog *fp, union bpf_attr *attr);
diff --git a/include/linux/filter.h b/include/linux/filter.h
index ca95abd2bed1..caac2087a4d5 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -381,6 +381,7 @@ int bpf_prog_create(struct bpf_prog **pfp, struct sock_fprog_kern *fprog);
void bpf_prog_destroy(struct bpf_prog *fp);
int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
+int sk_attach_bpf(u32 ufd, struct sock *sk);
int sk_detach_filter(struct sock *sk);
int bpf_check_classic(const struct sock_filter *filter, unsigned int flen);
diff --git a/include/uapi/asm-generic/socket.h b/include/uapi/asm-generic/socket.h
index f541ccefd4ac..5c15c2a5c123 100644
--- a/include/uapi/asm-generic/socket.h
+++ b/include/uapi/asm-generic/socket.h
@@ -84,4 +84,7 @@
#define SO_INCOMING_CPU 49
+#define SO_ATTACH_BPF 50
+#define SO_DETACH_BPF SO_DETACH_FILTER
+
#endif /* __ASM_GENERIC_SOCKET_H */
diff --git a/net/core/filter.c b/net/core/filter.c
index 647b12265e18..8cc3c03078b3 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -44,6 +44,7 @@
#include <linux/ratelimit.h>
#include <linux/seccomp.h>
#include <linux/if_vlan.h>
+#include <linux/bpf.h>
/**
* sk_filter - run a packet through a socket filter
@@ -813,8 +814,12 @@ static void bpf_release_orig_filter(struct bpf_prog *fp)
static void __bpf_prog_release(struct bpf_prog *prog)
{
- bpf_release_orig_filter(prog);
- bpf_prog_free(prog);
+ if (prog->aux->prog_type == BPF_PROG_TYPE_SOCKET_FILTER) {
+ bpf_prog_put(prog);
+ } else {
+ bpf_release_orig_filter(prog);
+ bpf_prog_free(prog);
+ }
}
static void __sk_filter_release(struct sk_filter *fp)
@@ -1088,6 +1093,94 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk)
}
EXPORT_SYMBOL_GPL(sk_attach_filter);
+#ifdef CONFIG_BPF_SYSCALL
+int sk_attach_bpf(u32 ufd, struct sock *sk)
+{
+ struct sk_filter *fp, *old_fp;
+ struct bpf_prog *prog;
+
+ if (sock_flag(sk, SOCK_FILTER_LOCKED))
+ return -EPERM;
+
+ prog = bpf_prog_get(ufd);
+ if (!prog)
+ return -EINVAL;
+
+ if (prog->aux->prog_type != BPF_PROG_TYPE_SOCKET_FILTER) {
+ /* valid fd, but invalid program type */
+ bpf_prog_put(prog);
+ return -EINVAL;
+ }
+
+ fp = kmalloc(sizeof(*fp), GFP_KERNEL);
+ if (!fp) {
+ bpf_prog_put(prog);
+ return -ENOMEM;
+ }
+ fp->prog = prog;
+
+ atomic_set(&fp->refcnt, 0);
+
+ if (!sk_filter_charge(sk, fp)) {
+ __sk_filter_release(fp);
+ return -ENOMEM;
+ }
+
+ old_fp = rcu_dereference_protected(sk->sk_filter,
+ sock_owned_by_user(sk));
+ rcu_assign_pointer(sk->sk_filter, fp);
+
+ if (old_fp)
+ sk_filter_uncharge(sk, old_fp);
+
+ return 0;
+}
+
+/* allow socket filters to call
+ * bpf_map_lookup_elem(), bpf_map_update_elem(), bpf_map_delete_elem()
+ */
+static const struct bpf_func_proto *sock_filter_func_proto(enum bpf_func_id func_id)
+{
+ switch (func_id) {
+ case BPF_FUNC_map_lookup_elem:
+ return &bpf_map_lookup_elem_proto;
+ case BPF_FUNC_map_update_elem:
+ return &bpf_map_update_elem_proto;
+ case BPF_FUNC_map_delete_elem:
+ return &bpf_map_delete_elem_proto;
+ default:
+ return NULL;
+ }
+}
+
+static bool sock_filter_is_valid_access(int off, int size, enum bpf_access_type type)
+{
+ /* skb fields cannot be accessed yet */
+ return false;
+}
+
+static struct bpf_verifier_ops sock_filter_ops = {
+ .get_func_proto = sock_filter_func_proto,
+ .is_valid_access = sock_filter_is_valid_access,
+};
+
+static struct bpf_prog_type_list tl = {
+ .ops = &sock_filter_ops,
+ .type = BPF_PROG_TYPE_SOCKET_FILTER,
+};
+
+static int __init register_sock_filter_ops(void)
+{
+ bpf_register_prog_type(&tl);
+ return 0;
+}
+late_initcall(register_sock_filter_ops);
+#else
+int sk_attach_bpf(u32 ufd, struct sock *sk)
+{
+ return -EOPNOTSUPP;
+}
+#endif
int sk_detach_filter(struct sock *sk)
{
int ret = -ENOENT;
diff --git a/net/core/sock.c b/net/core/sock.c
index 0725cf0cb685..9a56b2000c3f 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -888,6 +888,19 @@ set_rcvbuf:
}
break;
+ case SO_ATTACH_BPF:
+ ret = -EINVAL;
+ if (optlen == sizeof(u32)) {
+ u32 ufd;
+
+ ret = -EFAULT;
+ if (copy_from_user(&ufd, optval, sizeof(ufd)))
+ break;
+
+ ret = sk_attach_bpf(ufd, sk);
+ }
+ break;
+
case SO_DETACH_FILTER:
ret = sk_detach_filter(sk);
break;
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 net-next 1/6] bpf: verifier: add checks for BPF_ABS | BPF_IND instructions
From: Alexei Starovoitov @ 2014-12-01 23:06 UTC (permalink / raw)
To: David S. Miller
Cc: Ingo Molnar, Andy Lutomirski, Daniel Borkmann,
Hannes Frederic Sowa, Eric Dumazet, linux-api, netdev,
linux-kernel
In-Reply-To: <1417475199-15950-1-git-send-email-ast@plumgrid.com>
introduce program type BPF_PROG_TYPE_SOCKET_FILTER that is used
for attaching programs to sockets where ctx == skb.
add verifier checks for ABS/IND instructions which can only be seen
in socket filters, therefore the check:
if (env->prog->aux->prog_type != BPF_PROG_TYPE_SOCKET_FILTER)
verbose("BPF_LD_ABS|IND instructions are only allowed in socket filters\n");
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
---
v2: no changes
include/uapi/linux/bpf.h | 1 +
kernel/bpf/verifier.c | 70 ++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 4a3d0f84f178..45da7ec7d274 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -117,6 +117,7 @@ enum bpf_map_type {
enum bpf_prog_type {
BPF_PROG_TYPE_UNSPEC,
+ BPF_PROG_TYPE_SOCKET_FILTER,
};
/* flags for BPF_MAP_UPDATE_ELEM command */
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index b6a1f7c14a67..a28e09c7825d 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1172,6 +1172,70 @@ static int check_ld_imm(struct verifier_env *env, struct bpf_insn *insn)
return 0;
}
+/* verify safety of LD_ABS|LD_IND instructions:
+ * - they can only appear in the programs where ctx == skb
+ * - since they are wrappers of function calls, they scratch R1-R5 registers,
+ * preserve R6-R9, and store return value into R0
+ *
+ * Implicit input:
+ * ctx == skb == R6 == CTX
+ *
+ * Explicit input:
+ * SRC == any register
+ * IMM == 32-bit immediate
+ *
+ * Output:
+ * R0 - 8/16/32-bit skb data converted to cpu endianness
+ */
+static int check_ld_abs(struct verifier_env *env, struct bpf_insn *insn)
+{
+ struct reg_state *regs = env->cur_state.regs;
+ u8 mode = BPF_MODE(insn->code);
+ struct reg_state *reg;
+ int i, err;
+
+ if (env->prog->aux->prog_type != BPF_PROG_TYPE_SOCKET_FILTER) {
+ verbose("BPF_LD_ABS|IND instructions are only allowed in socket filters\n");
+ return -EINVAL;
+ }
+
+ if (insn->dst_reg != BPF_REG_0 || insn->off != 0 ||
+ (mode == BPF_ABS && insn->src_reg != BPF_REG_0)) {
+ verbose("BPF_LD_ABS uses reserved fields\n");
+ return -EINVAL;
+ }
+
+ /* check whether implicit source operand (register R6) is readable */
+ err = check_reg_arg(regs, BPF_REG_6, SRC_OP);
+ if (err)
+ return err;
+
+ if (regs[BPF_REG_6].type != PTR_TO_CTX) {
+ verbose("at the time of BPF_LD_ABS|IND R6 != pointer to skb\n");
+ return -EINVAL;
+ }
+
+ if (mode == BPF_IND) {
+ /* check explicit source operand */
+ err = check_reg_arg(regs, insn->src_reg, SRC_OP);
+ if (err)
+ return err;
+ }
+
+ /* reset caller saved regs to unreadable */
+ for (i = 0; i < CALLER_SAVED_REGS; i++) {
+ reg = regs + caller_saved[i];
+ reg->type = NOT_INIT;
+ reg->imm = 0;
+ }
+
+ /* mark destination R0 register as readable, since it contains
+ * the value fetched from the packet
+ */
+ regs[BPF_REG_0].type = UNKNOWN_VALUE;
+ return 0;
+}
+
/* non-recursive DFS pseudo code
* 1 procedure DFS-iterative(G,v):
* 2 label v as discovered
@@ -1677,8 +1741,10 @@ process_bpf_exit:
u8 mode = BPF_MODE(insn->code);
if (mode == BPF_ABS || mode == BPF_IND) {
- verbose("LD_ABS is not supported yet\n");
- return -EINVAL;
+ err = check_ld_abs(env, insn);
+ if (err)
+ return err;
+
} else if (mode == BPF_IMM) {
err = check_ld_imm(env, insn);
if (err)
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 net-next 0/6] allow eBPF programs to be attached to sockets
From: Alexei Starovoitov @ 2014-12-01 23:06 UTC (permalink / raw)
To: David S. Miller
Cc: Ingo Molnar, Andy Lutomirski, Daniel Borkmann,
Hannes Frederic Sowa, Eric Dumazet, linux-api, netdev,
linux-kernel
V1->V2:
fixed comments in sample code to state clearly that packet data is accessed
with LD_ABS instructions and not internal skb fields.
Also replaced constants in:
BPF_LD_ABS(BPF_B, 14 + 9 /* R0 = ip->proto */),
with:
BPF_LD_ABS(BPF_B, ETH_HLEN + offsetof(struct iphdr, protocol) /* R0 = ip->proto */),
V1 cover:
Introduce BPF_PROG_TYPE_SOCKET_FILTER type of eBPF programs that can be
attached to sockets with setsockopt().
Allow such programs to access maps via lookup/update/delete helpers.
This feature was previewed by bpf manpage in commit b4fc1a460f30("Merge branch 'bpf-next'")
Now it can actually run.
1st patch adds LD_ABS/LD_IND instruction verification and
2nd patch adds new setsockopt() flag.
Patches 3-6 are examples in assembler and in C.
Though native eBPF programs are way more powerful than classic filters
(attachable through similar setsockopt() call), they don't have skb field
accessors yet. Like skb->pkt_type, skb->dev->ifindex are not accessible.
There are sevaral ways to achieve that. That will be in the next set of patches.
So in this set native eBPF programs can only read data from packet and
access maps.
The most powerful example is sockex2_kern.c from patch 6 where ~200 lines of C
are compiled into ~300 of eBPF instructions.
It shows how quite complex packet parsing can be done.
LLVM used to build examples is at https://github.com/iovisor/llvm
which is fork of llvm trunk that I'm cleaning up for upstreaming.
Alexei Starovoitov (6):
bpf: verifier: add checks for BPF_ABS | BPF_IND instructions
net: sock: allow eBPF programs to be attached to sockets
samples: bpf: example of stateful socket filtering
samples: bpf: elf_bpf file loader
samples: bpf: trivial eBPF program in C
samples: bpf: large eBPF program in C
arch/alpha/include/uapi/asm/socket.h | 3 +
arch/avr32/include/uapi/asm/socket.h | 3 +
arch/cris/include/uapi/asm/socket.h | 3 +
arch/frv/include/uapi/asm/socket.h | 3 +
arch/ia64/include/uapi/asm/socket.h | 3 +
arch/m32r/include/uapi/asm/socket.h | 3 +
arch/mips/include/uapi/asm/socket.h | 3 +
arch/mn10300/include/uapi/asm/socket.h | 3 +
arch/parisc/include/uapi/asm/socket.h | 3 +
arch/powerpc/include/uapi/asm/socket.h | 3 +
arch/s390/include/uapi/asm/socket.h | 3 +
arch/sparc/include/uapi/asm/socket.h | 3 +
arch/xtensa/include/uapi/asm/socket.h | 3 +
include/linux/bpf.h | 4 +
include/linux/filter.h | 1 +
include/uapi/asm-generic/socket.h | 3 +
include/uapi/linux/bpf.h | 1 +
kernel/bpf/verifier.c | 70 ++++++++++-
net/core/filter.c | 97 +++++++++++++-
net/core/sock.c | 13 ++
samples/bpf/Makefile | 20 +++
samples/bpf/bpf_helpers.h | 40 ++++++
samples/bpf/bpf_load.c | 203 ++++++++++++++++++++++++++++++
samples/bpf/bpf_load.h | 24 ++++
samples/bpf/libbpf.c | 28 +++++
samples/bpf/libbpf.h | 15 ++-
samples/bpf/sock_example.c | 101 +++++++++++++++
samples/bpf/sockex1_kern.c | 25 ++++
samples/bpf/sockex1_user.c | 49 ++++++++
samples/bpf/sockex2_kern.c | 215 ++++++++++++++++++++++++++++++++
samples/bpf/sockex2_user.c | 44 +++++++
31 files changed, 987 insertions(+), 5 deletions(-)
create mode 100644 samples/bpf/bpf_helpers.h
create mode 100644 samples/bpf/bpf_load.c
create mode 100644 samples/bpf/bpf_load.h
create mode 100644 samples/bpf/sock_example.c
create mode 100644 samples/bpf/sockex1_kern.c
create mode 100644 samples/bpf/sockex1_user.c
create mode 100644 samples/bpf/sockex2_kern.c
create mode 100644 samples/bpf/sockex2_user.c
--
1.7.9.5
^ permalink raw reply
* [PATCH net-next 4/4] openvswitch: Fix coding style.
From: Pravin B Shelar @ 2014-12-01 22:30 UTC (permalink / raw)
To: davem; +Cc: netdev, Pravin B Shelar
Fixes comment style issues, removes redundant egress_tun_info
reset.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
net/openvswitch/actions.c | 3 +--
net/openvswitch/datapath.c | 11 ++++++-----
net/openvswitch/flow.c | 11 ++++++-----
net/openvswitch/flow_netlink.c | 12 +++++++-----
net/openvswitch/flow_table.c | 3 ++-
5 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 770064c..453d5b8 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -90,7 +90,7 @@ static struct deferred_action *action_fifo_put(struct action_fifo *fifo)
return &fifo->fifo[fifo->head++];
}
-/* Return true if fifo is not full */
+/* Return queue entry if fifo is not full */
static struct deferred_action *add_deferred_actions(struct sk_buff *skb,
const struct sw_flow_key *key,
const struct nlattr *attr)
@@ -872,7 +872,6 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
int err;
this_cpu_inc(exec_actions_level);
- OVS_CB(skb)->egress_tun_info = NULL;
err = do_execute_actions(dp, skb, key,
acts->actions, acts->actions_len);
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 332b5a0..55ce8c8 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -78,7 +78,8 @@ static const struct genl_multicast_group ovs_dp_vport_multicast_group = {
};
/* Check if need to build a reply message.
- * OVS userspace sets the NLM_F_ECHO flag if it needs the reply. */
+ * OVS userspace sets the NLM_F_ECHO flag if it needs the reply.
+ */
static bool ovs_must_notify(struct genl_family *family, struct genl_info *info,
unsigned int group)
{
@@ -481,7 +482,8 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
}
/* Only reserve room for attribute header, packet data is added
- * in skb_zerocopy() */
+ * in skb_zerocopy()
+ */
if (!(nla = nla_reserve(user_skb, OVS_PACKET_ATTR_PACKET, 0))) {
err = -ENOBUFS;
goto out;
@@ -546,7 +548,8 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
/* Normally, setting the skb 'protocol' field would be handled by a
* call to eth_type_trans(), but it assumes there's a sending
- * device, which we may not have. */
+ * device, which we may not have.
+ */
if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN)
packet->protocol = eth->h_proto;
else
@@ -1894,7 +1897,6 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info)
goto exit_unlock_free;
}
-
if (a[OVS_VPORT_ATTR_UPCALL_PID]) {
struct nlattr *ids = a[OVS_VPORT_ATTR_UPCALL_PID];
@@ -1906,7 +1908,6 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info)
err = ovs_vport_cmd_fill_info(vport, reply, info->snd_portid,
info->snd_seq, 0, OVS_VPORT_CMD_NEW);
BUG_ON(err < 0);
-
ovs_unlock();
ovs_notify(&dp_vport_genl_family, reply, info);
return 0;
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 70bef2a..96480fe 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -552,7 +552,8 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)
struct icmphdr *icmp = icmp_hdr(skb);
/* The ICMP type and code fields use the 16-bit
* transport port fields, so we need to store
- * them in 16-bit network byte order. */
+ * them in 16-bit network byte order.
+ */
key->tp.src = htons(icmp->type);
key->tp.dst = htons(icmp->code);
} else {
@@ -686,17 +687,17 @@ int ovs_flow_key_extract(const struct ovs_tunnel_info *tun_info,
if (tun_info) {
memcpy(&key->tun_key, &tun_info->tunnel, sizeof(key->tun_key));
+ BUILD_BUG_ON(((1 << (sizeof(tun_info->options_len) * 8)) - 1) >
+ sizeof(key->tun_opts));
+
if (tun_info->options) {
- BUILD_BUG_ON((1 << (sizeof(tun_info->options_len) *
- 8)) - 1
- > sizeof(key->tun_opts));
memcpy(GENEVE_OPTS(key, tun_info->options_len),
tun_info->options, tun_info->options_len);
key->tun_opts_len = tun_info->options_len;
} else {
key->tun_opts_len = 0;
}
- } else {
+ } else {
key->tun_opts_len = 0;
memset(&key->tun_key, 0, sizeof(key->tun_key));
}
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index df3c7f2..3c92a86 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -18,8 +18,6 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-#include "flow.h"
-#include "datapath.h"
#include <linux/uaccess.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -48,6 +46,8 @@
#include <net/ndisc.h>
#include <net/mpls.h>
+#include "datapath.h"
+#include "flow.h"
#include "flow_netlink.h"
static void update_range(struct sw_flow_match *match,
@@ -118,7 +118,8 @@ static bool match_validate(const struct sw_flow_match *match,
u64 mask_allowed = key_attrs; /* At most allow all key attributes */
/* The following mask attributes allowed only if they
- * pass the validation tests. */
+ * pass the validation tests.
+ */
mask_allowed &= ~((1 << OVS_KEY_ATTR_IPV4)
| (1 << OVS_KEY_ATTR_IPV6)
| (1 << OVS_KEY_ATTR_TCP)
@@ -833,7 +834,7 @@ static int ovs_key_from_nlattrs(struct sw_flow_match *match, u64 attrs,
mpls_key->mpls_lse, is_mask);
attrs &= ~(1 << OVS_KEY_ATTR_MPLS);
- }
+ }
if (attrs & (1 << OVS_KEY_ATTR_TCP)) {
const struct ovs_key_tcp *tcp_key;
@@ -1366,7 +1367,8 @@ static struct sw_flow_actions *nla_alloc_flow_actions(int size, bool log)
}
/* Schedules 'sf_acts' to be freed after the next RCU grace period.
- * The caller must hold rcu_read_lock for this to be sensible. */
+ * The caller must hold rcu_read_lock for this to be sensible.
+ */
void ovs_nla_free_flow_actions(struct sw_flow_actions *sf_acts)
{
kfree_rcu(sf_acts, rcu);
diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c
index e0a7fef..d40fdb2 100644
--- a/net/openvswitch/flow_table.c
+++ b/net/openvswitch/flow_table.c
@@ -617,7 +617,8 @@ int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,
}
/* Initializes the flow module.
- * Returns zero if successful or a negative error code. */
+ * Returns zero if successful or a negative error code.
+ */
int ovs_flow_init(void)
{
BUILD_BUG_ON(__alignof__(struct sw_flow_key) % __alignof__(long));
--
1.7.1
^ permalink raw reply related
* [PATCH net-next 2/4] vlan: Fix mac_len adjustment.
From: Pravin B Shelar @ 2014-12-01 22:30 UTC (permalink / raw)
To: davem; +Cc: netdev, Pravin B Shelar
skb_reset_mac_len() sets length according to ethernet and network
offsets, but mpls expects mac-length to be offset to mpls header (ref.
skb_mpls_header()). Therefore rather than reset we need to subtract
VLAN_HLEN from mac_len.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
net/core/skbuff.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 92116df..c45888f 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4178,7 +4178,7 @@ static int __skb_vlan_pop(struct sk_buff *skb, u16 *vlan_tci)
if (skb_network_offset(skb) < ETH_HLEN)
skb_set_network_header(skb, ETH_HLEN);
- skb_reset_mac_len(skb);
+ skb->mac_len -= VLAN_HLEN;
pull:
__skb_pull(skb, offset);
--
1.7.1
^ permalink raw reply related
* [PATCH net-next 3/4] mpls: Fix allowed protocols for mpls gso
From: Pravin B Shelar @ 2014-12-01 22:30 UTC (permalink / raw)
To: davem; +Cc: netdev, Pravin B Shelar
MPLS and Tunnel GSO does not work together. Reject packet which
request such GSO.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
net/mpls/mpls_gso.c | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/net/mpls/mpls_gso.c b/net/mpls/mpls_gso.c
index ca27837..349295d 100644
--- a/net/mpls/mpls_gso.c
+++ b/net/mpls/mpls_gso.c
@@ -31,10 +31,7 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
SKB_GSO_TCPV6 |
SKB_GSO_UDP |
SKB_GSO_DODGY |
- SKB_GSO_TCP_ECN |
- SKB_GSO_GRE |
- SKB_GSO_GRE_CSUM |
- SKB_GSO_IPIP)))
+ SKB_GSO_TCP_ECN)))
goto out;
/* Setup inner SKB. */
--
1.7.1
^ permalink raw reply related
* [PATCH net-next 1/4] openvswitch: Set inner-most protocol for MPLS.
From: Pravin B Shelar @ 2014-12-01 22:30 UTC (permalink / raw)
To: davem; +Cc: netdev, Pravin B Shelar
MPLS GSO needs to know inner most protocol to process GSO packets.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
net/openvswitch/actions.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 764fdc3..770064c 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -147,7 +147,8 @@ static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key,
hdr = eth_hdr(skb);
hdr->h_proto = mpls->mpls_ethertype;
- skb_set_inner_protocol(skb, skb->protocol);
+ if (!skb->inner_protocol)
+ skb_set_inner_protocol(skb, skb->protocol);
skb->protocol = mpls->mpls_ethertype;
invalidate_flow_key(key);
--
1.7.1
^ permalink raw reply related
* [PATCH net-next 0/4] openvswitch: MPLS related fixes.
From: Pravin B Shelar @ 2014-12-01 22:30 UTC (permalink / raw)
To: davem; +Cc: netdev, Pravin B Shelar
First three patches fixes and improves OVS MPLS support. Last
patch is general code cleanup.
Pravin B Shelar (4):
openvswitch: Set inner-most protocol for MPLS.
vlan: Fix mac_len adjustment.
mpls: Fix allowed protocols for mpls gso
openvswitch: Fix coding style.
net/core/skbuff.c | 2 +-
net/mpls/mpls_gso.c | 5 +----
net/openvswitch/actions.c | 6 +++---
net/openvswitch/datapath.c | 11 ++++++-----
net/openvswitch/flow.c | 11 ++++++-----
net/openvswitch/flow_netlink.c | 12 +++++++-----
net/openvswitch/flow_table.c | 3 ++-
7 files changed, 26 insertions(+), 24 deletions(-)
^ permalink raw reply
* [PATCH v2 net-next] net: bcmgenet: enable driver to work without a device tree
From: Petri Gynther @ 2014-12-01 22:08 UTC (permalink / raw)
To: netdev; +Cc: davem, f.fainelli
Broadcom 7xxx MIPS-based STB platforms do not use device trees.
Modify bcmgenet driver so that it can be used on those platforms.
Signed-off-by: Petri Gynther <pgynther@google.com>
---
drivers/net/ethernet/broadcom/Kconfig | 1 -
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 31 ++++--
drivers/net/ethernet/broadcom/genet/bcmmii.c | 134 +++++++++++++++++++++----
include/linux/platform_data/bcmgenet.h | 18 ++++
4 files changed, 152 insertions(+), 32 deletions(-)
create mode 100644 include/linux/platform_data/bcmgenet.h
diff --git a/drivers/net/ethernet/broadcom/Kconfig b/drivers/net/ethernet/broadcom/Kconfig
index c3e260c..888247a 100644
--- a/drivers/net/ethernet/broadcom/Kconfig
+++ b/drivers/net/ethernet/broadcom/Kconfig
@@ -62,7 +62,6 @@ config BCM63XX_ENET
config BCMGENET
tristate "Broadcom GENET internal MAC support"
- depends on OF
select MII
select PHYLIB
select FIXED_PHY if BCMGENET=y
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index f2fadb0..861c298 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -42,6 +42,7 @@
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/phy.h>
+#include <linux/platform_data/bcmgenet.h>
#include <asm/unaligned.h>
@@ -2586,6 +2587,7 @@ static const struct of_device_id bcmgenet_match[] = {
static int bcmgenet_probe(struct platform_device *pdev)
{
+ struct bcmgenet_platform_data *pd = pdev->dev.platform_data;
struct device_node *dn = pdev->dev.of_node;
const struct of_device_id *of_id;
struct bcmgenet_priv *priv;
@@ -2601,9 +2603,13 @@ static int bcmgenet_probe(struct platform_device *pdev)
return -ENOMEM;
}
- of_id = of_match_node(bcmgenet_match, dn);
- if (!of_id)
- return -EINVAL;
+ if (dn) {
+ of_id = of_match_node(bcmgenet_match, dn);
+ if (!of_id)
+ return -EINVAL;
+ } else {
+ of_id = NULL;
+ }
priv = netdev_priv(dev);
priv->irq0 = platform_get_irq(pdev, 0);
@@ -2615,11 +2621,15 @@ static int bcmgenet_probe(struct platform_device *pdev)
goto err;
}
- macaddr = of_get_mac_address(dn);
- if (!macaddr) {
- dev_err(&pdev->dev, "can't find MAC address\n");
- err = -EINVAL;
- goto err;
+ if (dn) {
+ macaddr = of_get_mac_address(dn);
+ if (!macaddr) {
+ dev_err(&pdev->dev, "can't find MAC address\n");
+ err = -EINVAL;
+ goto err;
+ }
+ } else {
+ macaddr = pd->macaddr;
}
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -2659,7 +2669,10 @@ static int bcmgenet_probe(struct platform_device *pdev)
priv->dev = dev;
priv->pdev = pdev;
- priv->version = (enum bcmgenet_version)of_id->data;
+ if (of_id)
+ priv->version = (enum bcmgenet_version)of_id->data;
+ else
+ priv->version = pd->genet_version;
priv->clk = devm_clk_get(&priv->pdev->dev, "enet");
if (IS_ERR(priv->clk))
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index 933cd7e..f758686 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -23,6 +23,7 @@
#include <linux/of.h>
#include <linux/of_net.h>
#include <linux/of_mdio.h>
+#include <linux/platform_data/bcmgenet.h>
#include "bcmgenet.h"
@@ -312,22 +313,6 @@ static int bcmgenet_mii_probe(struct net_device *dev)
u32 phy_flags;
int ret;
- if (priv->phydev) {
- pr_info("PHY already attached\n");
- return 0;
- }
-
- /* In the case of a fixed PHY, the DT node associated
- * to the PHY is the Ethernet MAC DT node.
- */
- if (!priv->phy_dn && of_phy_is_fixed_link(dn)) {
- ret = of_phy_register_fixed_link(dn);
- if (ret)
- return ret;
-
- priv->phy_dn = of_node_get(dn);
- }
-
/* Communicate the integrated PHY revision */
phy_flags = priv->gphy_rev;
@@ -337,11 +322,39 @@ static int bcmgenet_mii_probe(struct net_device *dev)
priv->old_duplex = -1;
priv->old_pause = -1;
- phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup,
- phy_flags, priv->phy_interface);
- if (!phydev) {
- pr_err("could not attach to PHY\n");
- return -ENODEV;
+ if (dn) {
+ if (priv->phydev) {
+ pr_info("PHY already attached\n");
+ return 0;
+ }
+
+ /* In the case of a fixed PHY, the DT node associated
+ * to the PHY is the Ethernet MAC DT node.
+ */
+ if (!priv->phy_dn && of_phy_is_fixed_link(dn)) {
+ ret = of_phy_register_fixed_link(dn);
+ if (ret)
+ return ret;
+
+ priv->phy_dn = of_node_get(dn);
+ }
+
+ phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup,
+ phy_flags, priv->phy_interface);
+ if (!phydev) {
+ pr_err("could not attach to PHY\n");
+ return -ENODEV;
+ }
+ } else {
+ phydev = priv->phydev;
+ phydev->dev_flags = phy_flags;
+
+ ret = phy_connect_direct(dev, phydev, bcmgenet_mii_setup,
+ priv->phy_interface);
+ if (ret) {
+ pr_err("could not attach to PHY\n");
+ return -ENODEV;
+ }
}
priv->phydev = phydev;
@@ -438,6 +451,83 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
return 0;
}
+static int bcmgenet_mii_pd_init(struct bcmgenet_priv *priv)
+{
+ struct device *kdev = &priv->pdev->dev;
+ struct bcmgenet_platform_data *pd = kdev->platform_data;
+ struct mii_bus *mdio = priv->mii_bus;
+ struct phy_device *phydev;
+ int ret;
+ int i;
+
+ if (pd->phy_type != PHY_INTERFACE_MODE_MOCA && pd->mdio_enabled) {
+ /*
+ * Internal or external PHY with MDIO access
+ */
+ if (pd->phy_addr >= 0 && pd->phy_addr < PHY_MAX_ADDR)
+ mdio->phy_mask = ~(1 << pd->phy_addr);
+ else
+ mdio->phy_mask = 0;
+
+ ret = mdiobus_register(mdio);
+ if (ret) {
+ dev_err(kdev, "failed to register MDIO bus\n");
+ return ret;
+ }
+
+ if (pd->phy_addr >= 0 && pd->phy_addr < PHY_MAX_ADDR) {
+ phydev = mdio->phy_map[pd->phy_addr];
+ } else {
+ phydev = NULL;
+ for (i = 0; i < PHY_MAX_ADDR; i++) {
+ if (mdio->phy_map[i]) {
+ phydev = mdio->phy_map[i];
+ break;
+ }
+ }
+ }
+
+ if (!phydev) {
+ dev_err(kdev, "failed to register PHY device\n");
+ mdiobus_unregister(mdio);
+ return -ENODEV;
+ }
+ } else {
+ /*
+ * MoCA port or no MDIO access.
+ * Use 1000/FD fixed PHY to represent the link layer.
+ */
+ struct fixed_phy_status fphy_status = {
+ .link = 1,
+ .duplex = DUPLEX_FULL,
+ .speed = SPEED_1000,
+ .pause = 0,
+ .asym_pause = 0,
+ };
+
+ phydev = fixed_phy_register(PHY_POLL, &fphy_status, NULL);
+ if (!phydev || IS_ERR(phydev)) {
+ dev_err(kdev, "failed to register fixed PHY device\n");
+ return -ENODEV;
+ }
+ }
+
+ priv->phydev = phydev;
+ priv->phy_interface = pd->phy_type;
+
+ return 0;
+}
+
+static int bcmgenet_mii_bus_init(struct bcmgenet_priv *priv)
+{
+ struct device_node *dn = priv->pdev->dev.of_node;
+
+ if (dn)
+ return bcmgenet_mii_of_init(priv);
+ else
+ return bcmgenet_mii_pd_init(priv);
+}
+
int bcmgenet_mii_init(struct net_device *dev)
{
struct bcmgenet_priv *priv = netdev_priv(dev);
@@ -447,7 +537,7 @@ int bcmgenet_mii_init(struct net_device *dev)
if (ret)
return ret;
- ret = bcmgenet_mii_of_init(priv);
+ ret = bcmgenet_mii_bus_init(priv);
if (ret)
goto out_free;
diff --git a/include/linux/platform_data/bcmgenet.h b/include/linux/platform_data/bcmgenet.h
new file mode 100644
index 0000000..3660133
--- /dev/null
+++ b/include/linux/platform_data/bcmgenet.h
@@ -0,0 +1,18 @@
+#ifndef __LINUX_PLATFORM_DATA_BCMGENET_H__
+#define __LINUX_PLATFORM_DATA_BCMGENET_H__
+
+#include <linux/compiler.h>
+#include <linux/if_ether.h>
+
+struct bcmgenet_platform_data {
+ void __iomem *base_reg;
+ int irq0;
+ int irq1;
+ bool mdio_enabled;
+ int phy_type;
+ int phy_addr;
+ u8 macaddr[ETH_ALEN];
+ int genet_version;
+};
+
+#endif
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related
* Re: BCM4313 & brcmsmac & 3.12: only semi-working?
From: Maximilian Engelhardt @ 2014-12-01 22:06 UTC (permalink / raw)
To: Arend van Spriel
Cc: Michael Tokarev, Rafał Miłecki, Seth Forshee,
brcm80211 development, linux-wireless@vger.kernel.org,
Network Development
In-Reply-To: <5475A2DC.80502@msgid.tls.msk.ru>
[-- Attachment #1: Type: text/plain, Size: 10527 bytes --]
Hi Arend,
sorry for my late reply, it took me a bit to get the modules compiled with
your patches. Here is the information from my card. During this test I had
very bad performance with my wifi connection with big latency and lots of
packet loss.
[ 1642.407735] bcma: bus0: Found chip with id 0x4313, rev 0x01 and package 0x08
[ 1642.407766] bcma: bus0: Core 0 found: ChipCommon (manuf 0x4BF, id 0x800, rev 0x24, class 0x0)
[ 1642.407794] bcma: bus0: Core 1 found: IEEE 802.11 (manuf 0x4BF, id 0x812, rev 0x18, class 0x0)
[ 1642.407829] bcma: bus0: Core 2 found: PCIe (manuf 0x4BF, id 0x820, rev 0x11, class 0x0)
[ 1642.407913] bcma: bus0: Found rev 8 PMU (capabilities 0x084C3008)
[ 1642.407978] bcma: bus0: SPROM offset 0x830
[ 1642.410625] bcma: bcmasprom:
[ 1642.410630] bcma:
[ 1642.410635] bcma: 2801
[ 1642.410637] bcma: 0000
[ 1642.410640] bcma: 0608
[ 1642.410642] bcma: 14E4
[ 1642.410645] bcma: 0070
[ 1642.410647] bcma: EDBE
[ 1642.410649] bcma: 0000
[ 1642.410651] bcma: 2BC4
[ 1642.410654] bcma: 2A64
[ 1642.410655] bcma: 2964
[ 1642.410658] bcma:
[ 1642.410659] bcma: 2C64
[ 1642.410662] bcma: 3CE7
[ 1642.410663] bcma: 46FF
[ 1642.410666] bcma: 47FF
[ 1642.410667] bcma: 0C00
[ 1642.410670] bcma: 0820
[ 1642.410671] bcma: 0030
[ 1642.410674] bcma: 1002
[ 1642.410676] bcma: 9F28
[ 1642.410678] bcma: 5D44
[ 1642.410679] bcma:
[ 1642.410683] bcma: 8080
[ 1642.410684] bcma: 1D8F
[ 1642.410687] bcma: 0032
[ 1642.410689] bcma: 0100
[ 1642.410691] bcma: DF00
[ 1642.410693] bcma: 71F5
[ 1642.410695] bcma: 8400
[ 1642.410697] bcma: 0083
[ 1642.410699] bcma: 8500
[ 1642.410701] bcma: 2010
[ 1642.410703] bcma:
[ 1642.410705] bcma: 0001
[ 1642.410707] bcma: 0000
[ 1642.410709] bcma: 0000
[ 1642.410711] bcma: 0000
[ 1642.410713] bcma: 0000
[ 1642.410715] bcma: 0000
[ 1642.410717] bcma: 0000
[ 1642.410719] bcma: 0000
[ 1642.410721] bcma: 0000
[ 1642.410723] bcma: 0000
[ 1642.410724] bcma:
[ 1642.410728] bcma: 0000
[ 1642.410730] bcma: 0000
[ 1642.410732] bcma: 1008
[ 1642.410734] bcma: 0305
[ 1642.410736] bcma: 0000
[ 1642.410738] bcma: 0000
[ 1642.410740] bcma: 0000
[ 1642.410742] bcma: 0000
[ 1642.410744] bcma: 4727
[ 1642.410746] bcma: 8000
[ 1642.410748] bcma:
[ 1642.410749] bcma: 0002
[ 1642.410752] bcma: 0000
[ 1642.410753] bcma: 1F30
[ 1642.410756] bcma: 1800
[ 1642.410757] bcma: 0000
[ 1642.410760] bcma: 0000
[ 1642.410761] bcma: 0000
[ 1642.410764] bcma: 0000
[ 1642.410765] bcma: 0000
[ 1642.410768] bcma: 0000
[ 1642.410769] bcma:
[ 1642.410773] bcma: 0000
[ 1642.410774] bcma: 0000
[ 1642.410777] bcma: 0000
[ 1642.410778] bcma: 0000
[ 1642.410781] bcma: 5372
[ 1642.410782] bcma: 1109
[ 1642.410785] bcma: 2201
[ 1642.410786] bcma: 0040
[ 1642.410789] bcma: 0884
[ 1642.410790] bcma: 0000
[ 1642.410793] bcma:
[ 1642.410794] bcma: C014
[ 1642.410797] bcma: 3DC1
[ 1642.410798] bcma: 809D
[ 1642.410801] bcma: 5856
[ 1642.410802] bcma: 0001
[ 1642.410805] bcma: FFFF
[ 1642.410807] bcma: 83FF
[ 1642.410809] bcma: FFFF
[ 1642.410811] bcma: 0003
[ 1642.410813] bcma: 0202
[ 1642.410814] bcma:
[ 1642.410818] bcma: FFFF
[ 1642.410819] bcma: 0011
[ 1642.410822] bcma: 017A
[ 1642.410824] bcma: 0000
[ 1642.410826] bcma: 0000
[ 1642.410828] bcma: 0000
[ 1642.410830] bcma: 0000
[ 1642.410832] bcma: 0201
[ 1642.410834] bcma: 0000
[ 1642.410836] bcma: 7800
[ 1642.410838] bcma:
[ 1642.410839] bcma: 01FF
[ 1642.410842] bcma: E398
[ 1642.410844] bcma: 0008
[ 1642.410846] bcma: 0000
[ 1642.410848] bcma: 0000
[ 1642.410850] bcma: 0000
[ 1642.410852] bcma: 0044
[ 1642.410854] bcma: 2400
[ 1642.410856] bcma: FCF7
[ 1642.410858] bcma: 0089
[ 1642.410860] bcma:
[ 1642.410863] bcma: 0000
[ 1642.410865] bcma: 0000
[ 1642.410867] bcma: 0000
[ 1642.410869] bcma: 0000
[ 1642.410871] bcma: 0000
[ 1642.410873] bcma: 0000
[ 1642.410875] bcma: 0000
[ 1642.410877] bcma: 0000
[ 1642.410879] bcma: 0000
[ 1642.410881] bcma: 0000
[ 1642.410883] bcma:
[ 1642.410884] bcma: 0000
[ 1642.410887] bcma: 0000
[ 1642.410888] bcma: 0048
[ 1642.410891] bcma: FED2
[ 1642.410892] bcma: 15D9
[ 1642.410895] bcma: FAC6
[ 1642.410897] bcma: 0000
[ 1642.410899] bcma: 0000
[ 1642.410901] bcma: 0000
[ 1642.410903] bcma: 0000
[ 1642.410904] bcma:
[ 1642.410908] bcma: 0000
[ 1642.410909] bcma: 0000
[ 1642.410912] bcma: 0000
[ 1642.410913] bcma: 0000
[ 1642.410916] bcma: 0000
[ 1642.410917] bcma: 0000
[ 1642.410920] bcma: 0000
[ 1642.410921] bcma: 0000
[ 1642.410924] bcma: 0000
[ 1642.410925] bcma: 0000
[ 1642.410927] bcma:
[ 1642.410929] bcma: 0000
[ 1642.410931] bcma: 0000
[ 1642.410933] bcma: 0000
[ 1642.410935] bcma: 0000
[ 1642.410937] bcma: 0000
[ 1642.410939] bcma: 0000
[ 1642.410941] bcma: 0000
[ 1642.410943] bcma: 0000
[ 1642.410945] bcma: 0000
[ 1642.410947] bcma: 0000
[ 1642.410949] bcma:
[ 1642.410952] bcma: 0000
[ 1642.410954] bcma: 0000
[ 1642.410956] bcma: 0000
[ 1642.410958] bcma: 0000
[ 1642.410960] bcma: 0000
[ 1642.410962] bcma: 0000
[ 1642.410964] bcma: 0000
[ 1642.410966] bcma: 0000
[ 1642.410968] bcma: 0000
[ 1642.410970] bcma: 0000
[ 1642.410972] bcma:
[ 1642.410974] bcma: 0000
[ 1642.410976] bcma: 0000
[ 1642.410978] bcma: 0000
[ 1642.410980] bcma: 0000
[ 1642.410982] bcma: 0000
[ 1642.410984] bcma: 0000
[ 1642.410986] bcma: 0000
[ 1642.410988] bcma: 0000
[ 1642.410990] bcma: 0000
[ 1642.410992] bcma: 0000
[ 1642.410994] bcma:
[ 1642.410997] bcma: 0000
[ 1642.410999] bcma: 1111
[ 1642.411001] bcma: 1111
[ 1642.411003] bcma: 0000
[ 1642.411005] bcma: 0000
[ 1642.411007] bcma: 0000
[ 1642.411009] bcma: 0000
[ 1642.411010] bcma: 0000
[ 1642.411013] bcma: 0000
[ 1642.411015] bcma: 2222
[ 1642.411017] bcma:
[ 1642.411018] bcma: 3222
[ 1642.411021] bcma: 0000
[ 1642.411022] bcma: 0000
[ 1642.411025] bcma: 0000
[ 1642.411026] bcma: 0000
[ 1642.411029] bcma: 0000
[ 1642.411030] bcma: 0000
[ 1642.411033] bcma: 0000
[ 1642.411034] bcma: 0000
[ 1642.411037] bcma: 0000
[ 1642.411038] bcma:
[ 1642.411041] bcma: 0000
[ 1642.411043] bcma: 0000
[ 1642.411045] bcma: 0000
[ 1642.411047] bcma: 0000
[ 1642.411050] bcma: 0000
[ 1642.411051] bcma: 0000
[ 1642.411054] bcma: 0000
[ 1642.411055] bcma: 0000
[ 1642.411058] bcma: 0000
[ 1642.411059] bcma: 0000
[ 1642.411061] bcma:
[ 1642.411063] bcma: 0000
[ 1642.411065] bcma: 0000
[ 1642.411067] bcma: 0000
[ 1642.411069] bcma: 0000
[ 1642.411071] bcma: 0000
[ 1642.411073] bcma: 0000
[ 1642.411075] bcma: 0000
[ 1642.411077] bcma: 0000
[ 1642.411079] bcma: 0000
[ 1642.411081] bcma: 0000
[ 1642.411083] bcma:
[ 1642.411086] bcma: 0000
[ 1642.411088] bcma: 0000
[ 1642.411090] bcma: 0000
[ 1642.411092] bcma: 0000
[ 1642.411094] bcma: 0000
[ 1642.411096] bcma: 0000
[ 1642.411098] bcma: 0000
[ 1642.411100] bcma: 0000
[ 1642.411102] bcma: 0000
[ 1642.411104] bcma: 0000
[ 1642.411106] bcma:
[ 1642.411107] bcma: 0000
[ 1642.411110] bcma: 0000
[ 1642.411111] bcma: 0000
[ 1642.411114] bcma: 0000
[ 1642.411115] bcma: 0000
[ 1642.411118] bcma: 0000
[ 1642.411119] bcma: 0000
[ 1642.411122] bcma: 0000
[ 1642.411123] bcma: 0000
[ 1642.411127] bcma: bus0: Found SPROM revision 8
[ 1642.434510] bcma: bus0: GPIO driver not activated
[ 1642.434518] bcma: bus0: Bus registered
[ 1642.449971] brcmsmac bcma0:0: mfg 4bf core 812 rev 24 class 0 irq 17
[ 1642.450095] bcma: bus0: Switched to core: 0x812
[ 1642.451446] ieee80211 phy1: Selected rate control algorithm 'minstrel_ht'
[ 4112.897927] brcmsmac bcma0:0: brcms_ops_bss_info_changed: qos enabled: false (implement)
[ 4112.898113] brcmsmac bcma0:0: brcms_ops_config: change power-save mode: false (implement)
[ 4112.899832] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 4113.830658] wlan0: authenticate with e8:de:27:44:3b:33
[ 4113.830764] wlan0: send auth to e8:de:27:44:3b:33 (try 1/3)
[ 4113.832620] wlan0: authenticated
[ 4113.833859] wlan0: associate with e8:de:27:44:3b:33 (try 1/3)
[ 4113.837231] wlan0: RX AssocResp from e8:de:27:44:3b:33 (capab=0x431 status=0 aid=1)
[ 4113.837591] brcmsmac bcma0:0: brcmsmac: brcms_ops_bss_info_changed: associated
[ 4113.837752] brcmsmac bcma0:0: brcms_ops_bss_info_changed: arp filtering: 1 addresses (implement)
[ 4113.837861] brcmsmac bcma0:0: brcms_ops_bss_info_changed: qos enabled: true (implement)
[ 4113.838209] wlan0: associated
[ 4113.838228] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[ 4113.838771] cfg80211: Calling CRDA for country: DE
[ 4113.847285] cfg80211: Regulatory domain changed to country: DE
[ 4113.847298] cfg80211: DFS Master region: ETSI
[ 4113.847302] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[ 4113.847308] cfg80211: (2400000 KHz - 2483500 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
[ 4113.847313] cfg80211: (5150000 KHz - 5250000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
[ 4113.847318] cfg80211: (5250000 KHz - 5350000 KHz @ 80000 KHz), (N/A, 2000 mBm), (0 s)
[ 4113.847322] cfg80211: (5470000 KHz - 5725000 KHz @ 80000 KHz), (N/A, 2698 mBm), (0 s)
[ 4113.847327] cfg80211: (57240000 KHz - 65880000 KHz @ 2160000 KHz), (N/A, 4000 mBm), (N/A)
$ cat brcmsmac/bcma0\:0/hardware
chipnum 0x4313
chiprev 0x1
chippackage 0x8
corerev 0x18
boardid 0x608
boardvendor 0x14e4
boardrev P109
boardflags 0x402201
boardflags2 0x884
ucoderev 0x262032c
radiorev 0x1
phytype 0x8
phyrev 0x1
anarev 0xa
nvramrev 8
$ cat brcmsmac/bcma0\:0/macstat
txallfrm: 1622
txrtsfrm: 739
txctsfrm: 269
txackfrm: 128
txdnlfrm: 0
txbcnfrm: 0
txfunfl[8]: 0 0 0 0 0 0 0 0
txtplunfl: 0
txphyerr: 0
pktengrxducast: 0
pktengrxdmcast: 0
rxfrmtoolong: 927
rxfrmtooshrt: 158
rxinvmachdr: 3145
rxbadfcs: 7459
rxbadplcp: 28631
rxcrsglitch: 945
rxstrt: 17138
rxdfrmucastmbss: 112
rxmfrmucastmbss: 16
rxcfrmucast: 745
rxrtsucast: 269
rxctsucast: 311
rxackucast: 38
rxdfrmocast: 21
rxmfrmocast: 16
rxcfrmocast: 7664
rxrtsocast: 379
rxctsocast: 6351
rxdfrmmcast: 5
rxmfrmmcast: 141
rxcfrmmcast: 0
rxbeaconmbss: 47
rxdfrmucastobss: 0
rxbeaconobss: 55
rxrsptmout: 650
bcntxcancl: 0
rxf0ovfl: 0
rxf1ovfl: 0
rxf2ovfl: 0
txsfovfl: 0
pmqovfl: 0
rxcgprqfrm: 0
rxcgprsqovfl: 0
txcgprsfail: 0
txcgprssuc: 0
prs_timeout: 0
rxnack: 0
frmscons: 0
txnack: 0
txglitch_nack: 127
txburst: 0
bphy_rxcrsglitch: 1
phywatchdog: 0
bphy_badplcp: 0
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply
* Re: Is this 32-bit NCM?
From: Eli Britstein @ 2014-12-01 22:02 UTC (permalink / raw)
To: Enrico Mioso
Cc: Kevin Zhu, Bjørn Mork, Alex Strizhevsky, Midge Shaojun Tan,
youtux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <alpine.LNX.2.03.1412012202480.1301-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Hi Enrico and all,
Maybe I missed something but what is the difference by the driver point of view between the dhcp discover and request (that are ok) to others (like arp, that is nok)?
Maybe we can trace to compare them?
Sent from my iPhone
> On 1 בדצמ 2014, at 23:11, "Enrico Mioso" <mrkiko.rs@gmail.com> wrote:
>
> So ... I have two ideas left for now.
> We know for sure the problem is in the way we TX frames, not the way we RX them
> (the way we send, generate them, not the way we receive them).
> Si I have two ideas, and I ask for help from the Linux-usb mailing list for
> this first one.
>
> 1 - Does a wayexist to "replay" traffic crom a usb capture?
> We might try to take the usb frames generated by Windows, and send them to the
> device to see if there is any reaction. It should not be science fiction, I saw
> them do that in the eciadsl old project.
> 2 - The huawei ndis driver: does it work with these devices?
> It should be a little bit out-dated now (at least in terms of dates, it might
> work as well): the code is A LOT but, just in case, to see if there is any
> chances it'll work. It remains to be seen in which kernels it can actually
> compile again.
>
> If this works we might analyse what's happening and try to debug this out.
> But I really would like this to work in the cdc_ncm driver + huawei_cdc_ncm.
> Thank you.
________________________________
This email and any files transmitted with it are confidential material. They are intended solely for the use of the designated individual or entity to whom they are addressed. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, use, distribution or copying of this communication is strictly prohibited and may be unlawful.
If you have received this email in error please immediately notify the sender and delete or destroy any copy of this message
^ permalink raw reply
* [PATCH net-next] hyperv: Add support for vNIC hot removal
From: Haiyang Zhang @ 2014-12-01 21:28 UTC (permalink / raw)
To: davem, netdev; +Cc: olaf, jasowang, driverdev-devel, linux-kernel, haiyangz
This patch adds proper handling of the vNIC hot removal event, which includes
a rescind-channel-offer message from the host side that triggers vNIC close and
removal. In this case, the notices to the host during close and removal is not
necessary because the channel is rescinded. This patch blocks these unnecessary
messages, and lets vNIC removal process complete normally.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/hv/channel_mgmt.c | 2 ++
drivers/net/hyperv/netvsc.c | 3 +++
drivers/net/hyperv/rndis_filter.c | 3 +++
include/linux/hyperv.h | 2 ++
4 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index a2d1a96..191a6a3 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -517,6 +517,8 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
/* Just return here, no channel found */
return;
+ channel->rescind = true;
+
/* work is initialized for vmbus_process_rescind_offer() from
* vmbus_process_offer() where the channel got created */
queue_work(channel->controlwq, &channel->work);
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 6fc834e..dd867e6 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -764,6 +764,9 @@ int netvsc_send(struct hv_device *device,
out_channel = device->channel;
packet->channel = out_channel;
+ if (out_channel->rescind)
+ return -ENODEV;
+
if (packet->page_buf_cnt) {
ret = vmbus_sendpacket_pagebuffer(out_channel,
packet->page_buf,
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 7b2c5d1..ec0c40a 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -958,6 +958,9 @@ static int rndis_filter_close_device(struct rndis_device *dev)
return 0;
ret = rndis_filter_set_packet_filter(dev, 0);
+ if (ret == -ENODEV)
+ ret = 0;
+
if (ret == 0)
dev->state = RNDIS_DEV_INITIALIZED;
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 08cfaff..476c685 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -650,6 +650,8 @@ struct vmbus_channel {
u8 monitor_grp;
u8 monitor_bit;
+ bool rescind; /* got rescind msg */
+
u32 ringbuffer_gpadlhandle;
/* Allocated memory for ring buffer */
--
1.7.1
^ permalink raw reply related
* Re: [PATCH net-next] net: bcmgenet: enable driver to work without a device tree
From: Florian Fainelli @ 2014-12-01 21:20 UTC (permalink / raw)
To: Petri Gynther; +Cc: netdev, David Miller, Kevin Cernekee
In-Reply-To: <CAGXr9JGgPD_LTCqbdNBgZi+pGboadRX0A3ZbdmAxp3rNBb12ww@mail.gmail.com>
On 01/12/14 13:13, Petri Gynther wrote:
> Hi Florian,
>
> Getting back to this (finally). I have made changes per your comments.
> Sending a new patch shortly.
Ok, I am still a little bit hesitant in accepting these changes
considering that Kevin spent some time making a BMIPS multiplatform
kernel to work on 7425, 7435 [1]. Let's see how your changes look like,
and we can decide by then.
https://lwn.net/Articles/622947/
>
> -- Petri
>
> On Fri, Oct 10, 2014 at 12:46 PM, Petri Gynther <pgynther@google.com> wrote:
>> Hi Florian,
>>
>> On Fri, Oct 10, 2014 at 11:59 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
>>> On 10/10/2014 11:35 AM, Petri Gynther wrote:
>>>> Broadcom 7xxx MIPS-based STB platforms do not use device trees.
>>>> Modify bcmgenet driver so that it can be used on those platforms.
>>>>
>>>> Signed-off-by: Petri Gynther <pgynther@google.com>
>>>> ---
>>>
>>> [snip]
>>>
>>>> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
>>>> index dbf524e..5191e3f 100644
>>>> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h
>>>> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
>>>> @@ -17,6 +17,17 @@
>>>> #include <linux/if_vlan.h>
>>>> #include <linux/phy.h>
>>>>
>>>> +struct bcmgenet_platform_data {
>>>> + void __iomem *base_reg;
>>>> + int irq0;
>>>> + int irq1;
>>>
>>> Why would these members here? The platform device should provide those
>>> as standard resources that the driver fetches using
>>> platform_get_resource() and platform_get_irq().
>>>
>>
>> I modeled this on struct bcmemac_platform_data that was used in the
>> legacy BRCMSTB code.
>> include/linux/brcmstb/brcmstb.h:
>>
>> struct bcmemac_platform_data {
>> /* used by the BSP code only */
>> uintptr_t base_reg;
>> int irq0;
>> int irq1;
>>
>> int phy_type;
>> int phy_id;
>> int phy_speed;
>> u8 macaddr[ETH_ALEN];
>> };
>>
>> The legacy BRCMSTB code stores all relevant GENET info in this struct
>> and then creates the resources from that info:
>>
>> static void __init brcm_register_genet(int id, struct bcmemac_platform_data *pd)
>> {
>> struct resource res[3];
>> struct platform_device *pdev;
>>
>> memset(&res, 0, sizeof(res));
>> res[0].start = BPHYSADDR(pd->base_reg);
>> res[0].end = BPHYSADDR(pd->base_reg + 0x4fff);
>> res[0].flags = IORESOURCE_MEM;
>>
>> res[1].start = res[1].end = pd->irq0;
>> res[1].flags = IORESOURCE_IRQ;
>>
>> res[2].start = res[2].end = pd->irq1;
>> res[2].flags = IORESOURCE_IRQ;
>>
>> brcm_alloc_macaddr(pd->macaddr);
>>
>> pdev = platform_device_alloc("bcmgenet", id);
>> platform_device_add_resources(pdev, res, 3);
>> platform_device_add_data(pdev, pd, sizeof(*pd));
>> platform_device_add(pdev);
>> }
>>
>>>> + int phy_type;
>>>> + int phy_addr;
>>>> + int phy_speed;
>>>> + u8 macaddr[ETH_ALEN];
>>>> + int genet_version;
>>>> +};
>>>
>>> I would rather we put this in include/linux/platform_data/bcmgenet.h
>>> where it belongs.
>>>
>>
>> I wasn't aware of the directory include/linux/platform_data/. Yes,
>> that's where this belongs.
>>
>>>> +
>>>> /* total number of Buffer Descriptors, same for Rx/Tx */
>>>> #define TOTAL_DESC 256
>>>>
>>>> diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
>>>> index 9ff799a..e5ff913 100644
>>>> --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
>>>> +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
>>>> @@ -157,6 +157,21 @@ static void bcmgenet_mii_setup(struct net_device *dev)
>>>> phy_print_status(phydev);
>>>> }
>>>>
>>>> +static int bcmgenet_moca_fphy_update(struct net_device *dev,
>>>> + struct fixed_phy_status *status)
>>>> +{
>>>> + struct bcmgenet_priv *priv = netdev_priv(dev);
>>>> + struct phy_device *phydev = priv->phydev;
>>>> +
>>>> + /*
>>>> + * MoCA daemon updates phydev->autoneg to reflect the link status.
>>>> + * Update MoCA fixed PHY status accordingly, so that the PHY state
>>>> + * machine becomes aware of the real link status.
>>>> + */
>>>> + status->link = phydev->autoneg;
>>>> + return 0;
>>>> +}
>>>
>>> I don't want to see that in the upstream driver, please enable the link
>>> interrupts like I suggested before and do not use the autoneg field at
>>> all, which should require no MoCA daemon modifications.
>>>
>>
>> I added debug printk's to bcmgenet_isr0 to check on UMAC_IRQ_LINK_UP
>> and UMAC_IRQ_LINK_DOWN.
>> I am not getting those interrupts on eth1 (MoCA) port when coax is
>> removed/inserted.
>> But, they do work on eth0.
>>
>> I'll modify init_umac() to enable those interrupts for MoCA port and retest.
>>
>>> [snip]
>>>
>>>>
>>>> priv->phydev = phydev;
>>>> @@ -437,6 +464,104 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
>>>> return 0;
>>>> }
>>>>
>>>> +static int bcmgenet_mii_pd_init(struct bcmgenet_priv *priv)
>>>> +{
>>>> + struct device *kdev = &priv->pdev->dev;
>>>> + struct bcmgenet_platform_data *pd = kdev->platform_data;
>>>> + struct mii_bus *mdio = priv->mii_bus;
>>>> + int phy_addr = pd->phy_addr;
>>>> + struct phy_device *phydev;
>>>> + int ret;
>>>> + int i;
>>>> +
>>>> + /* Disable automatic MDIO bus scan */
>>>> + mdio->phy_mask = ~0;
>>>> +
>>>> + /* Clear all the IRQ properties */
>>>> + if (mdio->irq)
>>>> + for (i = 0; i < PHY_MAX_ADDR; i++)
>>>> + mdio->irq[i] = PHY_POLL;
>>>> +
>>>> + /* Register the MDIO bus */
>>>> + ret = mdiobus_register(mdio);
>>>> + if (ret) {
>>>> + dev_err(kdev, "failed to register MDIO bus\n");
>>>> + return ret;
>>>> + }
>>>> +
>>>> + /*
>>>> + * bcmgenet_platform_data needs to pass a valid PHY address for
>>>> + * internal/external PHY or -1 for MoCA PHY.
>>>> + */
>>>> + if (phy_addr >= 0 && phy_addr < PHY_MAX_ADDR) {
>>>
>>> We do too much low-level PHY device handling, and since you already have
>>> the phy_type provided via platform_data, we can use that hint to do the
>>> following:
>>>
>>> 1) an internal or external PHY with MDIO accesses should leave the bus
>>> auto-probing on with the specified PHY address in the mdio bus phy_mask
>>>
>>> 2) a MoCA PHY or an external PHY with MDIO accesses disabled should use
>>> the fixed-0 MII bus instead.
>>>
>>> This would look like this:
>>>
>>> if (pd->phy_type != PHY_INTERFACE_MODE_MOCA || pd->mdio_enabled)
>>> mdio->phy_mask = ~(1 << pd->phy_addr);
>>>
>>> ...
>>> mdiobus_register()
>>>
>>> priv->phydev = mdio->bus->phy_map[pd->phy_addr];
>>>
>>> phydev->phy_flags |= mask;
>>>
>>> if (pd->phy_type == PHY_INTERFACE_MODE_MOCA || !pd->mdio_enabled)
>>> priv->phydev = fixed_phy_register(...);
>>>
>>> and in both cases, later on you do connect to the PHY device
>>>
>>> I can cook a patch to illustrate what I think this could look like since
>>> I realize using pseudo-code to explain might not be the best thing.
>>>
>>
>> I think I understand what you mean. I'll make a change.
>>
>>>> + /*
>>>> + * 10/100/1000 Ethernet port with external or internal PHY.
>>>> + */
>>>> + phydev = get_phy_device(mdio, phy_addr, false);
>>>> + if (!phydev || IS_ERR(phydev)) {
>>>> + dev_err(kdev, "failed to create PHY device\n");
>>>> + mdiobus_unregister(mdio);
>>>> + return 1;
>>>> + }
>>>> +
>>>> + phydev->irq = PHY_POLL;
>>>> +
>>>> + ret = phy_device_register(phydev);
>>>> + if (ret) {
>>>> + dev_err(kdev, "failed to register PHY device\n");
>>>> + phy_device_free(phydev);
>>>> + mdiobus_unregister(mdio);
>>>> + return 1;
>>>> + }
>>>> +
>>>> + priv->phydev = phydev;
>>>> + priv->phy_interface = pd->phy_type;
>>>> + } else {
>>>> + /*
>>>> + * MoCA port with no MDIO-accessible PHY.
>>>> + * We need to use 1000/HD fixed PHY to represent the link layer.
>>>> + * MoCA daemon interacts with this PHY via ethtool.
>>>> + */
>>>> + struct fixed_phy_status moca_fphy_status = {
>>>> + .link = 0,
>>>> + .duplex = 0,
>>>
>>> This should be DUPLEX_FULL here, the link between GENET and the MoCA
>>> Ethernet convergence layer is full-duplex by nature (despite we report
>>> the PHY being half-duplex, which is a mistake in the downstream driver),
>>> the MoCA medium on the coaxial cable is half-duplex though, but that is
>>> handled by the MoCA HW.
>>>
>>> NB: I had issues in the past using a half-duplex link with the MoCA
>>> ethernet convergence layer, causing various types of packet loss because
>>> we use a simplified signaling internally in the hardware.
>>>
>>
>> I picked this setting from 3.3 GENET driver. I'll test 1000/FULL on my
>> platform to see if it works.
>>
>>>> + .speed = 1000,
>>>> + .pause = 0,
>>>> + .asym_pause = 0,
>>>> + };
>>>> +
>>>> + phydev = fixed_phy_register(PHY_POLL, &moca_fphy_status, NULL);
>>>> + if (!phydev || IS_ERR(phydev)) {
>>>> + dev_err(kdev, "failed to register fixed PHY device\n");
>>>> + mdiobus_unregister(mdio);
>>>> + return 1;
>>>> + }
>>>> +
>>>> + phydev->autoneg = AUTONEG_DISABLE;
>>>> +
>>>> + ret = fixed_phy_set_link_update(phydev,
>>>> + bcmgenet_moca_fphy_update);
>>>> + if (ret) {
>>>> + dev_err(kdev, "failed to set fixed PHY link update\n");
>>>> + }
>>>
>>> Should not we propagate this error to the caller?
>>
>> Good catch. Yes.
>>
>>> --
>>> Florian
^ permalink raw reply
* Re: [PATCH net-next] net: bcmgenet: enable driver to work without a device tree
From: Petri Gynther @ 2014-12-01 21:13 UTC (permalink / raw)
To: Florian Fainelli; +Cc: netdev, David Miller
In-Reply-To: <CAGXr9JH2w1xoUwzzfdC4gi99iu3Eo4zkyWCsZi1b_x_gm+OKqg@mail.gmail.com>
Hi Florian,
Getting back to this (finally). I have made changes per your comments.
Sending a new patch shortly.
-- Petri
On Fri, Oct 10, 2014 at 12:46 PM, Petri Gynther <pgynther@google.com> wrote:
> Hi Florian,
>
> On Fri, Oct 10, 2014 at 11:59 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
>> On 10/10/2014 11:35 AM, Petri Gynther wrote:
>>> Broadcom 7xxx MIPS-based STB platforms do not use device trees.
>>> Modify bcmgenet driver so that it can be used on those platforms.
>>>
>>> Signed-off-by: Petri Gynther <pgynther@google.com>
>>> ---
>>
>> [snip]
>>
>>> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
>>> index dbf524e..5191e3f 100644
>>> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h
>>> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
>>> @@ -17,6 +17,17 @@
>>> #include <linux/if_vlan.h>
>>> #include <linux/phy.h>
>>>
>>> +struct bcmgenet_platform_data {
>>> + void __iomem *base_reg;
>>> + int irq0;
>>> + int irq1;
>>
>> Why would these members here? The platform device should provide those
>> as standard resources that the driver fetches using
>> platform_get_resource() and platform_get_irq().
>>
>
> I modeled this on struct bcmemac_platform_data that was used in the
> legacy BRCMSTB code.
> include/linux/brcmstb/brcmstb.h:
>
> struct bcmemac_platform_data {
> /* used by the BSP code only */
> uintptr_t base_reg;
> int irq0;
> int irq1;
>
> int phy_type;
> int phy_id;
> int phy_speed;
> u8 macaddr[ETH_ALEN];
> };
>
> The legacy BRCMSTB code stores all relevant GENET info in this struct
> and then creates the resources from that info:
>
> static void __init brcm_register_genet(int id, struct bcmemac_platform_data *pd)
> {
> struct resource res[3];
> struct platform_device *pdev;
>
> memset(&res, 0, sizeof(res));
> res[0].start = BPHYSADDR(pd->base_reg);
> res[0].end = BPHYSADDR(pd->base_reg + 0x4fff);
> res[0].flags = IORESOURCE_MEM;
>
> res[1].start = res[1].end = pd->irq0;
> res[1].flags = IORESOURCE_IRQ;
>
> res[2].start = res[2].end = pd->irq1;
> res[2].flags = IORESOURCE_IRQ;
>
> brcm_alloc_macaddr(pd->macaddr);
>
> pdev = platform_device_alloc("bcmgenet", id);
> platform_device_add_resources(pdev, res, 3);
> platform_device_add_data(pdev, pd, sizeof(*pd));
> platform_device_add(pdev);
> }
>
>>> + int phy_type;
>>> + int phy_addr;
>>> + int phy_speed;
>>> + u8 macaddr[ETH_ALEN];
>>> + int genet_version;
>>> +};
>>
>> I would rather we put this in include/linux/platform_data/bcmgenet.h
>> where it belongs.
>>
>
> I wasn't aware of the directory include/linux/platform_data/. Yes,
> that's where this belongs.
>
>>> +
>>> /* total number of Buffer Descriptors, same for Rx/Tx */
>>> #define TOTAL_DESC 256
>>>
>>> diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
>>> index 9ff799a..e5ff913 100644
>>> --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
>>> +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
>>> @@ -157,6 +157,21 @@ static void bcmgenet_mii_setup(struct net_device *dev)
>>> phy_print_status(phydev);
>>> }
>>>
>>> +static int bcmgenet_moca_fphy_update(struct net_device *dev,
>>> + struct fixed_phy_status *status)
>>> +{
>>> + struct bcmgenet_priv *priv = netdev_priv(dev);
>>> + struct phy_device *phydev = priv->phydev;
>>> +
>>> + /*
>>> + * MoCA daemon updates phydev->autoneg to reflect the link status.
>>> + * Update MoCA fixed PHY status accordingly, so that the PHY state
>>> + * machine becomes aware of the real link status.
>>> + */
>>> + status->link = phydev->autoneg;
>>> + return 0;
>>> +}
>>
>> I don't want to see that in the upstream driver, please enable the link
>> interrupts like I suggested before and do not use the autoneg field at
>> all, which should require no MoCA daemon modifications.
>>
>
> I added debug printk's to bcmgenet_isr0 to check on UMAC_IRQ_LINK_UP
> and UMAC_IRQ_LINK_DOWN.
> I am not getting those interrupts on eth1 (MoCA) port when coax is
> removed/inserted.
> But, they do work on eth0.
>
> I'll modify init_umac() to enable those interrupts for MoCA port and retest.
>
>> [snip]
>>
>>>
>>> priv->phydev = phydev;
>>> @@ -437,6 +464,104 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
>>> return 0;
>>> }
>>>
>>> +static int bcmgenet_mii_pd_init(struct bcmgenet_priv *priv)
>>> +{
>>> + struct device *kdev = &priv->pdev->dev;
>>> + struct bcmgenet_platform_data *pd = kdev->platform_data;
>>> + struct mii_bus *mdio = priv->mii_bus;
>>> + int phy_addr = pd->phy_addr;
>>> + struct phy_device *phydev;
>>> + int ret;
>>> + int i;
>>> +
>>> + /* Disable automatic MDIO bus scan */
>>> + mdio->phy_mask = ~0;
>>> +
>>> + /* Clear all the IRQ properties */
>>> + if (mdio->irq)
>>> + for (i = 0; i < PHY_MAX_ADDR; i++)
>>> + mdio->irq[i] = PHY_POLL;
>>> +
>>> + /* Register the MDIO bus */
>>> + ret = mdiobus_register(mdio);
>>> + if (ret) {
>>> + dev_err(kdev, "failed to register MDIO bus\n");
>>> + return ret;
>>> + }
>>> +
>>> + /*
>>> + * bcmgenet_platform_data needs to pass a valid PHY address for
>>> + * internal/external PHY or -1 for MoCA PHY.
>>> + */
>>> + if (phy_addr >= 0 && phy_addr < PHY_MAX_ADDR) {
>>
>> We do too much low-level PHY device handling, and since you already have
>> the phy_type provided via platform_data, we can use that hint to do the
>> following:
>>
>> 1) an internal or external PHY with MDIO accesses should leave the bus
>> auto-probing on with the specified PHY address in the mdio bus phy_mask
>>
>> 2) a MoCA PHY or an external PHY with MDIO accesses disabled should use
>> the fixed-0 MII bus instead.
>>
>> This would look like this:
>>
>> if (pd->phy_type != PHY_INTERFACE_MODE_MOCA || pd->mdio_enabled)
>> mdio->phy_mask = ~(1 << pd->phy_addr);
>>
>> ...
>> mdiobus_register()
>>
>> priv->phydev = mdio->bus->phy_map[pd->phy_addr];
>>
>> phydev->phy_flags |= mask;
>>
>> if (pd->phy_type == PHY_INTERFACE_MODE_MOCA || !pd->mdio_enabled)
>> priv->phydev = fixed_phy_register(...);
>>
>> and in both cases, later on you do connect to the PHY device
>>
>> I can cook a patch to illustrate what I think this could look like since
>> I realize using pseudo-code to explain might not be the best thing.
>>
>
> I think I understand what you mean. I'll make a change.
>
>>> + /*
>>> + * 10/100/1000 Ethernet port with external or internal PHY.
>>> + */
>>> + phydev = get_phy_device(mdio, phy_addr, false);
>>> + if (!phydev || IS_ERR(phydev)) {
>>> + dev_err(kdev, "failed to create PHY device\n");
>>> + mdiobus_unregister(mdio);
>>> + return 1;
>>> + }
>>> +
>>> + phydev->irq = PHY_POLL;
>>> +
>>> + ret = phy_device_register(phydev);
>>> + if (ret) {
>>> + dev_err(kdev, "failed to register PHY device\n");
>>> + phy_device_free(phydev);
>>> + mdiobus_unregister(mdio);
>>> + return 1;
>>> + }
>>> +
>>> + priv->phydev = phydev;
>>> + priv->phy_interface = pd->phy_type;
>>> + } else {
>>> + /*
>>> + * MoCA port with no MDIO-accessible PHY.
>>> + * We need to use 1000/HD fixed PHY to represent the link layer.
>>> + * MoCA daemon interacts with this PHY via ethtool.
>>> + */
>>> + struct fixed_phy_status moca_fphy_status = {
>>> + .link = 0,
>>> + .duplex = 0,
>>
>> This should be DUPLEX_FULL here, the link between GENET and the MoCA
>> Ethernet convergence layer is full-duplex by nature (despite we report
>> the PHY being half-duplex, which is a mistake in the downstream driver),
>> the MoCA medium on the coaxial cable is half-duplex though, but that is
>> handled by the MoCA HW.
>>
>> NB: I had issues in the past using a half-duplex link with the MoCA
>> ethernet convergence layer, causing various types of packet loss because
>> we use a simplified signaling internally in the hardware.
>>
>
> I picked this setting from 3.3 GENET driver. I'll test 1000/FULL on my
> platform to see if it works.
>
>>> + .speed = 1000,
>>> + .pause = 0,
>>> + .asym_pause = 0,
>>> + };
>>> +
>>> + phydev = fixed_phy_register(PHY_POLL, &moca_fphy_status, NULL);
>>> + if (!phydev || IS_ERR(phydev)) {
>>> + dev_err(kdev, "failed to register fixed PHY device\n");
>>> + mdiobus_unregister(mdio);
>>> + return 1;
>>> + }
>>> +
>>> + phydev->autoneg = AUTONEG_DISABLE;
>>> +
>>> + ret = fixed_phy_set_link_update(phydev,
>>> + bcmgenet_moca_fphy_update);
>>> + if (ret) {
>>> + dev_err(kdev, "failed to set fixed PHY link update\n");
>>> + }
>>
>> Should not we propagate this error to the caller?
>
> Good catch. Yes.
>
>> --
>> Florian
^ permalink raw reply
* Re: Is this 32-bit NCM?
From: Enrico Mioso @ 2014-12-01 21:11 UTC (permalink / raw)
To: Mingying.Zhu
Cc: Bjørn Mork, Alex Strizhevsky, ShaojunMidge.Tan, youtux,
linux-usb, netdev, Eli.Britstein
In-Reply-To: <87ppc71xne.fsf@nemi.mork.no>
So ... I have two ideas left for now.
We know for sure the problem is in the way we TX frames, not the way we RX them
(the way we send, generate them, not the way we receive them).
Si I have two ideas, and I ask for help from the Linux-usb mailing list for
this first one.
1 - Does a wayexist to "replay" traffic crom a usb capture?
We might try to take the usb frames generated by Windows, and send them to the
device to see if there is any reaction. It should not be science fiction, I saw
them do that in the eciadsl old project.
2 - The huawei ndis driver: does it work with these devices?
It should be a little bit out-dated now (at least in terms of dates, it might
work as well): the code is A LOT but, just in case, to see if there is any
chances it'll work. It remains to be seen in which kernels it can actually
compile again.
If this works we might analyse what's happening and try to debug this out.
But I really would like this to work in the cdc_ncm driver + huawei_cdc_ncm.
Thank you.
^ permalink raw reply
* Re: [PATCH] SSB / B44: fix WOL for BCM4401
From: Michael Büsch @ 2014-12-01 21:10 UTC (permalink / raw)
To: Andrey Skvortsov
Cc: Rafael J. Wysocki, Gary Zambrano, netdev, linux-kernel, b43-dev,
Rafał Miłecki, Larry Finger
In-Reply-To: <1417466798-15735-1-git-send-email-Andrej.Skvortzov@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 4854 bytes --]
On Mon, 1 Dec 2014 23:46:38 +0300
Andrey Skvortsov <andrej.skvortzov@gmail.com> wrote:
> Wake On Lan was not working on laptop DELL Vostro 1500.
> If WOL was turned on, BCM4401 was powered up in suspend mode. LEDs blinked.
> But the laptop could not be woken up with the Magic Packet. The reason for
> that was that PCIE was not enabled as a system wakeup source and
> therefore the host PCI bridge was not powered up in suspend mode.
> PCIE was not enabled in suspend by PM because no child devices were
> registered as wakeup source during suspend process.
> On laptop BCM4401 is connected through the SSB bus, that is connected to the
> PCI-Express bus. SSB and B44 did not use standard PM wakeup functions
> and did not forward wakeup settings to their parents.
> To fix that B44 driver enables PM wakeup and registers new wakeup source
> using device_set_wakeup_enable(). Wakeup is automatically reported to the parent SSB
> bus via power.wakeup_path. SSB bus enables wakeup for the parent PCI bridge, if there is any
> child devices with enabled wakeup functionality. All other steps are
> done by PM core code.
Thanks, this looks good.
I assume you tested this (I currently don't have a device to test this).
Larry, Rafał, any other b43 user:
Can you please test whether this doesn't cause regressions for suspend/resume on b43?
(Patch is attached as reference)
> Signed-off-by: Andrey Skvortsov <Andrej.Skvortzov@gmail.com>
> ---
> drivers/net/ethernet/broadcom/b44.c | 2 ++
> drivers/ssb/pcihost_wrapper.c | 33 ++++++++++++++++++++++-----------
> 2 files changed, 24 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
> index 416620f..ffeaf47 100644
> --- a/drivers/net/ethernet/broadcom/b44.c
> +++ b/drivers/net/ethernet/broadcom/b44.c
> @@ -2104,6 +2104,7 @@ static int b44_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
> bp->flags &= ~B44_FLAG_WOL_ENABLE;
> spin_unlock_irq(&bp->lock);
>
> + device_set_wakeup_enable(bp->sdev->dev, wol->wolopts & WAKE_MAGIC);
> return 0;
> }
>
> @@ -2452,6 +2453,7 @@ static int b44_init_one(struct ssb_device *sdev,
> }
> }
>
> + device_set_wakeup_capable(sdev->dev, true);
> netdev_info(dev, "%s %pM\n", DRV_DESCRIPTION, dev->dev_addr);
>
> return 0;
> diff --git a/drivers/ssb/pcihost_wrapper.c b/drivers/ssb/pcihost_wrapper.c
> index 69161bb..410215c 100644
> --- a/drivers/ssb/pcihost_wrapper.c
> +++ b/drivers/ssb/pcihost_wrapper.c
> @@ -11,15 +11,17 @@
> * Licensed under the GNU/GPL. See COPYING for details.
> */
>
> +#include <linux/pm.h>
> #include <linux/pci.h>
> #include <linux/export.h>
> #include <linux/slab.h>
> #include <linux/ssb/ssb.h>
>
>
> -#ifdef CONFIG_PM
> -static int ssb_pcihost_suspend(struct pci_dev *dev, pm_message_t state)
> +#ifdef CONFIG_PM_SLEEP
> +static int ssb_pcihost_suspend(struct device *d)
> {
> + struct pci_dev *dev = to_pci_dev(d);
> struct ssb_bus *ssb = pci_get_drvdata(dev);
> int err;
>
> @@ -28,17 +30,23 @@ static int ssb_pcihost_suspend(struct pci_dev *dev, pm_message_t state)
> return err;
> pci_save_state(dev);
> pci_disable_device(dev);
> - pci_set_power_state(dev, pci_choose_state(dev, state));
> +
> + /* if there is a wakeup enabled child device on ssb bus,
> + enable pci wakeup posibility. */
> + device_set_wakeup_enable(d, d->power.wakeup_path);
> +
> + pci_prepare_to_sleep(dev);
>
> return 0;
> }
>
> -static int ssb_pcihost_resume(struct pci_dev *dev)
> +static int ssb_pcihost_resume(struct device *d)
> {
> + struct pci_dev *dev = to_pci_dev(d);
> struct ssb_bus *ssb = pci_get_drvdata(dev);
> int err;
>
> - pci_set_power_state(dev, PCI_D0);
> + pci_back_from_sleep(dev);
> err = pci_enable_device(dev);
> if (err)
> return err;
> @@ -49,10 +57,12 @@ static int ssb_pcihost_resume(struct pci_dev *dev)
>
> return 0;
> }
> -#else /* CONFIG_PM */
> -# define ssb_pcihost_suspend NULL
> -# define ssb_pcihost_resume NULL
> -#endif /* CONFIG_PM */
> +
> +static const struct dev_pm_ops ssb_pcihost_pm_ops = {
> + SET_SYSTEM_SLEEP_PM_OPS(ssb_pcihost_suspend, ssb_pcihost_resume)
> +};
> +
> +#endif /* CONFIG_PM_SLEEP */
>
> static int ssb_pcihost_probe(struct pci_dev *dev,
> const struct pci_device_id *id)
> @@ -115,8 +125,9 @@ int ssb_pcihost_register(struct pci_driver *driver)
> {
> driver->probe = ssb_pcihost_probe;
> driver->remove = ssb_pcihost_remove;
> - driver->suspend = ssb_pcihost_suspend;
> - driver->resume = ssb_pcihost_resume;
> +#ifdef CONFIG_PM_SLEEP
> + driver->driver.pm = &ssb_pcihost_pm_ops;
> +#endif
>
> return pci_register_driver(driver);
> }
--
Michael
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: b44_wol.patch --]
[-- Type: text/x-patch, Size: 4357 bytes --]
From: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Subject: [PATCH] SSB / B44: fix WOL for BCM4401
Wake On Lan was not working on laptop DELL Vostro 1500.
If WOL was turned on, BCM4401 was powered up in suspend mode. LEDs blinked.
But the laptop could not be woken up with the Magic Packet. The reason for
that was that PCIE was not enabled as a system wakeup source and
therefore the host PCI bridge was not powered up in suspend mode.
PCIE was not enabled in suspend by PM because no child devices were
registered as wakeup source during suspend process.
On laptop BCM4401 is connected through the SSB bus, that is connected to the
PCI-Express bus. SSB and B44 did not use standard PM wakeup functions
and did not forward wakeup settings to their parents.
To fix that B44 driver enables PM wakeup and registers new wakeup source
using device_set_wakeup_enable(). Wakeup is automatically reported to the parent SSB
bus via power.wakeup_path. SSB bus enables wakeup for the parent PCI bridge, if there is any
child devices with enabled wakeup functionality. All other steps are
done by PM core code.
Signed-off-by: Andrey Skvortsov <Andrej.Skvortzov@gmail.com>
---
drivers/net/ethernet/broadcom/b44.c | 2 ++
drivers/ssb/pcihost_wrapper.c | 33 ++++++++++++++++++++++-----------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index 416620f..ffeaf47 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -2104,6 +2104,7 @@ static int b44_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
bp->flags &= ~B44_FLAG_WOL_ENABLE;
spin_unlock_irq(&bp->lock);
+ device_set_wakeup_enable(bp->sdev->dev, wol->wolopts & WAKE_MAGIC);
return 0;
}
@@ -2452,6 +2453,7 @@ static int b44_init_one(struct ssb_device *sdev,
}
}
+ device_set_wakeup_capable(sdev->dev, true);
netdev_info(dev, "%s %pM\n", DRV_DESCRIPTION, dev->dev_addr);
return 0;
diff --git a/drivers/ssb/pcihost_wrapper.c b/drivers/ssb/pcihost_wrapper.c
index 69161bb..410215c 100644
--- a/drivers/ssb/pcihost_wrapper.c
+++ b/drivers/ssb/pcihost_wrapper.c
@@ -11,15 +11,17 @@
* Licensed under the GNU/GPL. See COPYING for details.
*/
+#include <linux/pm.h>
#include <linux/pci.h>
#include <linux/export.h>
#include <linux/slab.h>
#include <linux/ssb/ssb.h>
-#ifdef CONFIG_PM
-static int ssb_pcihost_suspend(struct pci_dev *dev, pm_message_t state)
+#ifdef CONFIG_PM_SLEEP
+static int ssb_pcihost_suspend(struct device *d)
{
+ struct pci_dev *dev = to_pci_dev(d);
struct ssb_bus *ssb = pci_get_drvdata(dev);
int err;
@@ -28,17 +30,23 @@ static int ssb_pcihost_suspend(struct pci_dev *dev, pm_message_t state)
return err;
pci_save_state(dev);
pci_disable_device(dev);
- pci_set_power_state(dev, pci_choose_state(dev, state));
+
+ /* if there is a wakeup enabled child device on ssb bus,
+ enable pci wakeup posibility. */
+ device_set_wakeup_enable(d, d->power.wakeup_path);
+
+ pci_prepare_to_sleep(dev);
return 0;
}
-static int ssb_pcihost_resume(struct pci_dev *dev)
+static int ssb_pcihost_resume(struct device *d)
{
+ struct pci_dev *dev = to_pci_dev(d);
struct ssb_bus *ssb = pci_get_drvdata(dev);
int err;
- pci_set_power_state(dev, PCI_D0);
+ pci_back_from_sleep(dev);
err = pci_enable_device(dev);
if (err)
return err;
@@ -49,10 +57,12 @@ static int ssb_pcihost_resume(struct pci_dev *dev)
return 0;
}
-#else /* CONFIG_PM */
-# define ssb_pcihost_suspend NULL
-# define ssb_pcihost_resume NULL
-#endif /* CONFIG_PM */
+
+static const struct dev_pm_ops ssb_pcihost_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(ssb_pcihost_suspend, ssb_pcihost_resume)
+};
+
+#endif /* CONFIG_PM_SLEEP */
static int ssb_pcihost_probe(struct pci_dev *dev,
const struct pci_device_id *id)
@@ -115,8 +125,9 @@ int ssb_pcihost_register(struct pci_driver *driver)
{
driver->probe = ssb_pcihost_probe;
driver->remove = ssb_pcihost_remove;
- driver->suspend = ssb_pcihost_suspend;
- driver->resume = ssb_pcihost_resume;
+#ifdef CONFIG_PM_SLEEP
+ driver->driver.pm = &ssb_pcihost_pm_ops;
+#endif
return pci_register_driver(driver);
}
--
1.7.2.5
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply related
* Re: [PATCH] wireless/p54: Remove duplicated net2280 header
From: Ricardo Ribalda Delgado @ 2014-12-01 20:56 UTC (permalink / raw)
To: John W. Linville
Cc: Christian Lamparter, LKML, linux-wireless, netdev, David Miller
In-Reply-To: <20141201195924.GA7266@tuxdriver.com>
Hello John
No sorry. I only checked patchwork and the mailing list. I was
expecting the typical mail when a patch is merged into a tree :),
sorry about that, first contrib to the wireless subsystem.
Thanks
On Mon, Dec 1, 2014 at 8:59 PM, John W. Linville <linville@tuxdriver.com> wrote:
> Did you check the wireless-next tree's git logs?
>
> commit a831f20b6d6460640b83644d1c1df6e7e8ca9f68
> Author: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> Date: Mon Nov 24 11:19:51 2014 +0100
>
> wireless/p54: Remove duplicated net2280 header
>
> The usb gadget driver net2280 has exported a header file with the
> register definition of the net2280 chip.
>
> Remove the custom/duplicated header file in favor of that header file
> in include/linux
>
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> Signed-off-by: John W. Linville <linville@tuxdriver.com>
>
> On Mon, Dec 01, 2014 at 11:46:43AM +0100, Ricardo Ribalda Delgado wrote:
>> David Miller has marked the patch as "Awaiting Upstream", which I
>> think means that it should be merged through the wireless tree.
>>
>> Any comment from there?
>>
>> On Mon, Nov 24, 2014 at 11:19 AM, Ricardo Ribalda Delgado
>> <ricardo.ribalda@gmail.com> wrote:
>> > The usb gadget driver net2280 has exported a header file with the
>> > register definition of the net2280 chip.
>> >
>> > Remove the custom/duplicated header file in favor of that header file
>> > in include/linux
>> >
>> > Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
>> > ---
>> > drivers/net/wireless/p54/net2280.h | 451 -------------------------------------
>> > drivers/net/wireless/p54/p54usb.h | 13 +-
>> > 2 files changed, 12 insertions(+), 452 deletions(-)
>> > delete mode 100644 drivers/net/wireless/p54/net2280.h
>> >
>> > diff --git a/drivers/net/wireless/p54/net2280.h b/drivers/net/wireless/p54/net2280.h
>> > deleted file mode 100644
>> > index aedfaf2..0000000
>> > --- a/drivers/net/wireless/p54/net2280.h
>> > +++ /dev/null
>> > @@ -1,451 +0,0 @@
>> > -#ifndef NET2280_H
>> > -#define NET2280_H
>> > -/*
>> > - * NetChip 2280 high/full speed USB device controller.
>> > - * Unlike many such controllers, this one talks PCI.
>> > - */
>> > -
>> > -/*
>> > - * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
>> > - * Copyright (C) 2003 David Brownell
>> > - *
>> > - * This program is free software; you can redistribute it and/or modify
>> > - * it under the terms of the GNU General Public License as published by
>> > - * the Free Software Foundation; either version 2 of the License, or
>> > - * (at your option) any later version.
>> > - *
>> > - * This program is distributed in the hope that it will be useful,
>> > - * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> > - * GNU General Public License for more details.
>> > - *
>> > - * You should have received a copy of the GNU General Public License
>> > - * along with this program; if not, see <http://www.gnu.org/licenses/>.
>> > - */
>> > -
>> > -/*-------------------------------------------------------------------------*/
>> > -
>> > -/* NET2280 MEMORY MAPPED REGISTERS
>> > - *
>> > - * The register layout came from the chip documentation, and the bit
>> > - * number definitions were extracted from chip specification.
>> > - *
>> > - * Use the shift operator ('<<') to build bit masks, with readl/writel
>> > - * to access the registers through PCI.
>> > - */
>> > -
>> > -/* main registers, BAR0 + 0x0000 */
>> > -struct net2280_regs {
>> > - /* offset 0x0000 */
>> > - __le32 devinit;
>> > -#define LOCAL_CLOCK_FREQUENCY 8
>> > -#define FORCE_PCI_RESET 7
>> > -#define PCI_ID 6
>> > -#define PCI_ENABLE 5
>> > -#define FIFO_SOFT_RESET 4
>> > -#define CFG_SOFT_RESET 3
>> > -#define PCI_SOFT_RESET 2
>> > -#define USB_SOFT_RESET 1
>> > -#define M8051_RESET 0
>> > - __le32 eectl;
>> > -#define EEPROM_ADDRESS_WIDTH 23
>> > -#define EEPROM_CHIP_SELECT_ACTIVE 22
>> > -#define EEPROM_PRESENT 21
>> > -#define EEPROM_VALID 20
>> > -#define EEPROM_BUSY 19
>> > -#define EEPROM_CHIP_SELECT_ENABLE 18
>> > -#define EEPROM_BYTE_READ_START 17
>> > -#define EEPROM_BYTE_WRITE_START 16
>> > -#define EEPROM_READ_DATA 8
>> > -#define EEPROM_WRITE_DATA 0
>> > - __le32 eeclkfreq;
>> > - u32 _unused0;
>> > - /* offset 0x0010 */
>> > -
>> > - __le32 pciirqenb0; /* interrupt PCI master ... */
>> > -#define SETUP_PACKET_INTERRUPT_ENABLE 7
>> > -#define ENDPOINT_F_INTERRUPT_ENABLE 6
>> > -#define ENDPOINT_E_INTERRUPT_ENABLE 5
>> > -#define ENDPOINT_D_INTERRUPT_ENABLE 4
>> > -#define ENDPOINT_C_INTERRUPT_ENABLE 3
>> > -#define ENDPOINT_B_INTERRUPT_ENABLE 2
>> > -#define ENDPOINT_A_INTERRUPT_ENABLE 1
>> > -#define ENDPOINT_0_INTERRUPT_ENABLE 0
>> > - __le32 pciirqenb1;
>> > -#define PCI_INTERRUPT_ENABLE 31
>> > -#define POWER_STATE_CHANGE_INTERRUPT_ENABLE 27
>> > -#define PCI_ARBITER_TIMEOUT_INTERRUPT_ENABLE 26
>> > -#define PCI_PARITY_ERROR_INTERRUPT_ENABLE 25
>> > -#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE 20
>> > -#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE 19
>> > -#define PCI_TARGET_ABORT_ASSERTED_INTERRUPT_ENABLE 18
>> > -#define PCI_RETRY_ABORT_INTERRUPT_ENABLE 17
>> > -#define PCI_MASTER_CYCLE_DONE_INTERRUPT_ENABLE 16
>> > -#define GPIO_INTERRUPT_ENABLE 13
>> > -#define DMA_D_INTERRUPT_ENABLE 12
>> > -#define DMA_C_INTERRUPT_ENABLE 11
>> > -#define DMA_B_INTERRUPT_ENABLE 10
>> > -#define DMA_A_INTERRUPT_ENABLE 9
>> > -#define EEPROM_DONE_INTERRUPT_ENABLE 8
>> > -#define VBUS_INTERRUPT_ENABLE 7
>> > -#define CONTROL_STATUS_INTERRUPT_ENABLE 6
>> > -#define ROOT_PORT_RESET_INTERRUPT_ENABLE 4
>> > -#define SUSPEND_REQUEST_INTERRUPT_ENABLE 3
>> > -#define SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE 2
>> > -#define RESUME_INTERRUPT_ENABLE 1
>> > -#define SOF_INTERRUPT_ENABLE 0
>> > - __le32 cpu_irqenb0; /* ... or onboard 8051 */
>> > -#define SETUP_PACKET_INTERRUPT_ENABLE 7
>> > -#define ENDPOINT_F_INTERRUPT_ENABLE 6
>> > -#define ENDPOINT_E_INTERRUPT_ENABLE 5
>> > -#define ENDPOINT_D_INTERRUPT_ENABLE 4
>> > -#define ENDPOINT_C_INTERRUPT_ENABLE 3
>> > -#define ENDPOINT_B_INTERRUPT_ENABLE 2
>> > -#define ENDPOINT_A_INTERRUPT_ENABLE 1
>> > -#define ENDPOINT_0_INTERRUPT_ENABLE 0
>> > - __le32 cpu_irqenb1;
>> > -#define CPU_INTERRUPT_ENABLE 31
>> > -#define POWER_STATE_CHANGE_INTERRUPT_ENABLE 27
>> > -#define PCI_ARBITER_TIMEOUT_INTERRUPT_ENABLE 26
>> > -#define PCI_PARITY_ERROR_INTERRUPT_ENABLE 25
>> > -#define PCI_INTA_INTERRUPT_ENABLE 24
>> > -#define PCI_PME_INTERRUPT_ENABLE 23
>> > -#define PCI_SERR_INTERRUPT_ENABLE 22
>> > -#define PCI_PERR_INTERRUPT_ENABLE 21
>> > -#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE 20
>> > -#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE 19
>> > -#define PCI_RETRY_ABORT_INTERRUPT_ENABLE 17
>> > -#define PCI_MASTER_CYCLE_DONE_INTERRUPT_ENABLE 16
>> > -#define GPIO_INTERRUPT_ENABLE 13
>> > -#define DMA_D_INTERRUPT_ENABLE 12
>> > -#define DMA_C_INTERRUPT_ENABLE 11
>> > -#define DMA_B_INTERRUPT_ENABLE 10
>> > -#define DMA_A_INTERRUPT_ENABLE 9
>> > -#define EEPROM_DONE_INTERRUPT_ENABLE 8
>> > -#define VBUS_INTERRUPT_ENABLE 7
>> > -#define CONTROL_STATUS_INTERRUPT_ENABLE 6
>> > -#define ROOT_PORT_RESET_INTERRUPT_ENABLE 4
>> > -#define SUSPEND_REQUEST_INTERRUPT_ENABLE 3
>> > -#define SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE 2
>> > -#define RESUME_INTERRUPT_ENABLE 1
>> > -#define SOF_INTERRUPT_ENABLE 0
>> > -
>> > - /* offset 0x0020 */
>> > - u32 _unused1;
>> > - __le32 usbirqenb1;
>> > -#define USB_INTERRUPT_ENABLE 31
>> > -#define POWER_STATE_CHANGE_INTERRUPT_ENABLE 27
>> > -#define PCI_ARBITER_TIMEOUT_INTERRUPT_ENABLE 26
>> > -#define PCI_PARITY_ERROR_INTERRUPT_ENABLE 25
>> > -#define PCI_INTA_INTERRUPT_ENABLE 24
>> > -#define PCI_PME_INTERRUPT_ENABLE 23
>> > -#define PCI_SERR_INTERRUPT_ENABLE 22
>> > -#define PCI_PERR_INTERRUPT_ENABLE 21
>> > -#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE 20
>> > -#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE 19
>> > -#define PCI_RETRY_ABORT_INTERRUPT_ENABLE 17
>> > -#define PCI_MASTER_CYCLE_DONE_INTERRUPT_ENABLE 16
>> > -#define GPIO_INTERRUPT_ENABLE 13
>> > -#define DMA_D_INTERRUPT_ENABLE 12
>> > -#define DMA_C_INTERRUPT_ENABLE 11
>> > -#define DMA_B_INTERRUPT_ENABLE 10
>> > -#define DMA_A_INTERRUPT_ENABLE 9
>> > -#define EEPROM_DONE_INTERRUPT_ENABLE 8
>> > -#define VBUS_INTERRUPT_ENABLE 7
>> > -#define CONTROL_STATUS_INTERRUPT_ENABLE 6
>> > -#define ROOT_PORT_RESET_INTERRUPT_ENABLE 4
>> > -#define SUSPEND_REQUEST_INTERRUPT_ENABLE 3
>> > -#define SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE 2
>> > -#define RESUME_INTERRUPT_ENABLE 1
>> > -#define SOF_INTERRUPT_ENABLE 0
>> > - __le32 irqstat0;
>> > -#define INTA_ASSERTED 12
>> > -#define SETUP_PACKET_INTERRUPT 7
>> > -#define ENDPOINT_F_INTERRUPT 6
>> > -#define ENDPOINT_E_INTERRUPT 5
>> > -#define ENDPOINT_D_INTERRUPT 4
>> > -#define ENDPOINT_C_INTERRUPT 3
>> > -#define ENDPOINT_B_INTERRUPT 2
>> > -#define ENDPOINT_A_INTERRUPT 1
>> > -#define ENDPOINT_0_INTERRUPT 0
>> > - __le32 irqstat1;
>> > -#define POWER_STATE_CHANGE_INTERRUPT 27
>> > -#define PCI_ARBITER_TIMEOUT_INTERRUPT 26
>> > -#define PCI_PARITY_ERROR_INTERRUPT 25
>> > -#define PCI_INTA_INTERRUPT 24
>> > -#define PCI_PME_INTERRUPT 23
>> > -#define PCI_SERR_INTERRUPT 22
>> > -#define PCI_PERR_INTERRUPT 21
>> > -#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT 20
>> > -#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT 19
>> > -#define PCI_RETRY_ABORT_INTERRUPT 17
>> > -#define PCI_MASTER_CYCLE_DONE_INTERRUPT 16
>> > -#define GPIO_INTERRUPT 13
>> > -#define DMA_D_INTERRUPT 12
>> > -#define DMA_C_INTERRUPT 11
>> > -#define DMA_B_INTERRUPT 10
>> > -#define DMA_A_INTERRUPT 9
>> > -#define EEPROM_DONE_INTERRUPT 8
>> > -#define VBUS_INTERRUPT 7
>> > -#define CONTROL_STATUS_INTERRUPT 6
>> > -#define ROOT_PORT_RESET_INTERRUPT 4
>> > -#define SUSPEND_REQUEST_INTERRUPT 3
>> > -#define SUSPEND_REQUEST_CHANGE_INTERRUPT 2
>> > -#define RESUME_INTERRUPT 1
>> > -#define SOF_INTERRUPT 0
>> > - /* offset 0x0030 */
>> > - __le32 idxaddr;
>> > - __le32 idxdata;
>> > - __le32 fifoctl;
>> > -#define PCI_BASE2_RANGE 16
>> > -#define IGNORE_FIFO_AVAILABILITY 3
>> > -#define PCI_BASE2_SELECT 2
>> > -#define FIFO_CONFIGURATION_SELECT 0
>> > - u32 _unused2;
>> > - /* offset 0x0040 */
>> > - __le32 memaddr;
>> > -#define START 28
>> > -#define DIRECTION 27
>> > -#define FIFO_DIAGNOSTIC_SELECT 24
>> > -#define MEMORY_ADDRESS 0
>> > - __le32 memdata0;
>> > - __le32 memdata1;
>> > - u32 _unused3;
>> > - /* offset 0x0050 */
>> > - __le32 gpioctl;
>> > -#define GPIO3_LED_SELECT 12
>> > -#define GPIO3_INTERRUPT_ENABLE 11
>> > -#define GPIO2_INTERRUPT_ENABLE 10
>> > -#define GPIO1_INTERRUPT_ENABLE 9
>> > -#define GPIO0_INTERRUPT_ENABLE 8
>> > -#define GPIO3_OUTPUT_ENABLE 7
>> > -#define GPIO2_OUTPUT_ENABLE 6
>> > -#define GPIO1_OUTPUT_ENABLE 5
>> > -#define GPIO0_OUTPUT_ENABLE 4
>> > -#define GPIO3_DATA 3
>> > -#define GPIO2_DATA 2
>> > -#define GPIO1_DATA 1
>> > -#define GPIO0_DATA 0
>> > - __le32 gpiostat;
>> > -#define GPIO3_INTERRUPT 3
>> > -#define GPIO2_INTERRUPT 2
>> > -#define GPIO1_INTERRUPT 1
>> > -#define GPIO0_INTERRUPT 0
>> > -} __packed;
>> > -
>> > -/* usb control, BAR0 + 0x0080 */
>> > -struct net2280_usb_regs {
>> > - /* offset 0x0080 */
>> > - __le32 stdrsp;
>> > -#define STALL_UNSUPPORTED_REQUESTS 31
>> > -#define SET_TEST_MODE 16
>> > -#define GET_OTHER_SPEED_CONFIGURATION 15
>> > -#define GET_DEVICE_QUALIFIER 14
>> > -#define SET_ADDRESS 13
>> > -#define ENDPOINT_SET_CLEAR_HALT 12
>> > -#define DEVICE_SET_CLEAR_DEVICE_REMOTE_WAKEUP 11
>> > -#define GET_STRING_DESCRIPTOR_2 10
>> > -#define GET_STRING_DESCRIPTOR_1 9
>> > -#define GET_STRING_DESCRIPTOR_0 8
>> > -#define GET_SET_INTERFACE 6
>> > -#define GET_SET_CONFIGURATION 5
>> > -#define GET_CONFIGURATION_DESCRIPTOR 4
>> > -#define GET_DEVICE_DESCRIPTOR 3
>> > -#define GET_ENDPOINT_STATUS 2
>> > -#define GET_INTERFACE_STATUS 1
>> > -#define GET_DEVICE_STATUS 0
>> > - __le32 prodvendid;
>> > -#define PRODUCT_ID 16
>> > -#define VENDOR_ID 0
>> > - __le32 relnum;
>> > - __le32 usbctl;
>> > -#define SERIAL_NUMBER_INDEX 16
>> > -#define PRODUCT_ID_STRING_ENABLE 13
>> > -#define VENDOR_ID_STRING_ENABLE 12
>> > -#define USB_ROOT_PORT_WAKEUP_ENABLE 11
>> > -#define VBUS_PIN 10
>> > -#define TIMED_DISCONNECT 9
>> > -#define SUSPEND_IMMEDIATELY 7
>> > -#define SELF_POWERED_USB_DEVICE 6
>> > -#define REMOTE_WAKEUP_SUPPORT 5
>> > -#define PME_POLARITY 4
>> > -#define USB_DETECT_ENABLE 3
>> > -#define PME_WAKEUP_ENABLE 2
>> > -#define DEVICE_REMOTE_WAKEUP_ENABLE 1
>> > -#define SELF_POWERED_STATUS 0
>> > - /* offset 0x0090 */
>> > - __le32 usbstat;
>> > -#define HIGH_SPEED 7
>> > -#define FULL_SPEED 6
>> > -#define GENERATE_RESUME 5
>> > -#define GENERATE_DEVICE_REMOTE_WAKEUP 4
>> > - __le32 xcvrdiag;
>> > -#define FORCE_HIGH_SPEED_MODE 31
>> > -#define FORCE_FULL_SPEED_MODE 30
>> > -#define USB_TEST_MODE 24
>> > -#define LINE_STATE 16
>> > -#define TRANSCEIVER_OPERATION_MODE 2
>> > -#define TRANSCEIVER_SELECT 1
>> > -#define TERMINATION_SELECT 0
>> > - __le32 setup0123;
>> > - __le32 setup4567;
>> > - /* offset 0x0090 */
>> > - u32 _unused0;
>> > - __le32 ouraddr;
>> > -#define FORCE_IMMEDIATE 7
>> > -#define OUR_USB_ADDRESS 0
>> > - __le32 ourconfig;
>> > -} __packed;
>> > -
>> > -/* pci control, BAR0 + 0x0100 */
>> > -struct net2280_pci_regs {
>> > - /* offset 0x0100 */
>> > - __le32 pcimstctl;
>> > -#define PCI_ARBITER_PARK_SELECT 13
>> > -#define PCI_MULTI LEVEL_ARBITER 12
>> > -#define PCI_RETRY_ABORT_ENABLE 11
>> > -#define DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE 10
>> > -#define DMA_READ_MULTIPLE_ENABLE 9
>> > -#define DMA_READ_LINE_ENABLE 8
>> > -#define PCI_MASTER_COMMAND_SELECT 6
>> > -#define MEM_READ_OR_WRITE 0
>> > -#define IO_READ_OR_WRITE 1
>> > -#define CFG_READ_OR_WRITE 2
>> > -#define PCI_MASTER_START 5
>> > -#define PCI_MASTER_READ_WRITE 4
>> > -#define PCI_MASTER_WRITE 0
>> > -#define PCI_MASTER_READ 1
>> > -#define PCI_MASTER_BYTE_WRITE_ENABLES 0
>> > - __le32 pcimstaddr;
>> > - __le32 pcimstdata;
>> > - __le32 pcimststat;
>> > -#define PCI_ARBITER_CLEAR 2
>> > -#define PCI_EXTERNAL_ARBITER 1
>> > -#define PCI_HOST_MODE 0
>> > -} __packed;
>> > -
>> > -/* dma control, BAR0 + 0x0180 ... array of four structs like this,
>> > - * for channels 0..3. see also struct net2280_dma: descriptor
>> > - * that can be loaded into some of these registers.
>> > - */
>> > -struct net2280_dma_regs { /* [11.7] */
>> > - /* offset 0x0180, 0x01a0, 0x01c0, 0x01e0, */
>> > - __le32 dmactl;
>> > -#define DMA_SCATTER_GATHER_DONE_INTERRUPT_ENABLE 25
>> > -#define DMA_CLEAR_COUNT_ENABLE 21
>> > -#define DESCRIPTOR_POLLING_RATE 19
>> > -#define POLL_CONTINUOUS 0
>> > -#define POLL_1_USEC 1
>> > -#define POLL_100_USEC 2
>> > -#define POLL_1_MSEC 3
>> > -#define DMA_VALID_BIT_POLLING_ENABLE 18
>> > -#define DMA_VALID_BIT_ENABLE 17
>> > -#define DMA_SCATTER_GATHER_ENABLE 16
>> > -#define DMA_OUT_AUTO_START_ENABLE 4
>> > -#define DMA_PREEMPT_ENABLE 3
>> > -#define DMA_FIFO_VALIDATE 2
>> > -#define DMA_ENABLE 1
>> > -#define DMA_ADDRESS_HOLD 0
>> > - __le32 dmastat;
>> > -#define DMA_SCATTER_GATHER_DONE_INTERRUPT 25
>> > -#define DMA_TRANSACTION_DONE_INTERRUPT 24
>> > -#define DMA_ABORT 1
>> > -#define DMA_START 0
>> > - u32 _unused0[2];
>> > - /* offset 0x0190, 0x01b0, 0x01d0, 0x01f0, */
>> > - __le32 dmacount;
>> > -#define VALID_BIT 31
>> > -#define DMA_DIRECTION 30
>> > -#define DMA_DONE_INTERRUPT_ENABLE 29
>> > -#define END_OF_CHAIN 28
>> > -#define DMA_BYTE_COUNT_MASK ((1<<24)-1)
>> > -#define DMA_BYTE_COUNT 0
>> > - __le32 dmaaddr;
>> > - __le32 dmadesc;
>> > - u32 _unused1;
>> > -} __packed;
>> > -
>> > -/* dedicated endpoint registers, BAR0 + 0x0200 */
>> > -
>> > -struct net2280_dep_regs { /* [11.8] */
>> > - /* offset 0x0200, 0x0210, 0x220, 0x230, 0x240 */
>> > - __le32 dep_cfg;
>> > - /* offset 0x0204, 0x0214, 0x224, 0x234, 0x244 */
>> > - __le32 dep_rsp;
>> > - u32 _unused[2];
>> > -} __packed;
>> > -
>> > -/* configurable endpoint registers, BAR0 + 0x0300 ... array of seven structs
>> > - * like this, for ep0 then the configurable endpoints A..F
>> > - * ep0 reserved for control; E and F have only 64 bytes of fifo
>> > - */
>> > -struct net2280_ep_regs { /* [11.9] */
>> > - /* offset 0x0300, 0x0320, 0x0340, 0x0360, 0x0380, 0x03a0, 0x03c0 */
>> > - __le32 ep_cfg;
>> > -#define ENDPOINT_BYTE_COUNT 16
>> > -#define ENDPOINT_ENABLE 10
>> > -#define ENDPOINT_TYPE 8
>> > -#define ENDPOINT_DIRECTION 7
>> > -#define ENDPOINT_NUMBER 0
>> > - __le32 ep_rsp;
>> > -#define SET_NAK_OUT_PACKETS 15
>> > -#define SET_EP_HIDE_STATUS_PHASE 14
>> > -#define SET_EP_FORCE_CRC_ERROR 13
>> > -#define SET_INTERRUPT_MODE 12
>> > -#define SET_CONTROL_STATUS_PHASE_HANDSHAKE 11
>> > -#define SET_NAK_OUT_PACKETS_MODE 10
>> > -#define SET_ENDPOINT_TOGGLE 9
>> > -#define SET_ENDPOINT_HALT 8
>> > -#define CLEAR_NAK_OUT_PACKETS 7
>> > -#define CLEAR_EP_HIDE_STATUS_PHASE 6
>> > -#define CLEAR_EP_FORCE_CRC_ERROR 5
>> > -#define CLEAR_INTERRUPT_MODE 4
>> > -#define CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE 3
>> > -#define CLEAR_NAK_OUT_PACKETS_MODE 2
>> > -#define CLEAR_ENDPOINT_TOGGLE 1
>> > -#define CLEAR_ENDPOINT_HALT 0
>> > - __le32 ep_irqenb;
>> > -#define SHORT_PACKET_OUT_DONE_INTERRUPT_ENABLE 6
>> > -#define SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE 5
>> > -#define DATA_PACKET_RECEIVED_INTERRUPT_ENABLE 3
>> > -#define DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE 2
>> > -#define DATA_OUT_PING_TOKEN_INTERRUPT_ENABLE 1
>> > -#define DATA_IN_TOKEN_INTERRUPT_ENABLE 0
>> > - __le32 ep_stat;
>> > -#define FIFO_VALID_COUNT 24
>> > -#define HIGH_BANDWIDTH_OUT_TRANSACTION_PID 22
>> > -#define TIMEOUT 21
>> > -#define USB_STALL_SENT 20
>> > -#define USB_IN_NAK_SENT 19
>> > -#define USB_IN_ACK_RCVD 18
>> > -#define USB_OUT_PING_NAK_SENT 17
>> > -#define USB_OUT_ACK_SENT 16
>> > -#define FIFO_OVERFLOW 13
>> > -#define FIFO_UNDERFLOW 12
>> > -#define FIFO_FULL 11
>> > -#define FIFO_EMPTY 10
>> > -#define FIFO_FLUSH 9
>> > -#define SHORT_PACKET_OUT_DONE_INTERRUPT 6
>> > -#define SHORT_PACKET_TRANSFERRED_INTERRUPT 5
>> > -#define NAK_OUT_PACKETS 4
>> > -#define DATA_PACKET_RECEIVED_INTERRUPT 3
>> > -#define DATA_PACKET_TRANSMITTED_INTERRUPT 2
>> > -#define DATA_OUT_PING_TOKEN_INTERRUPT 1
>> > -#define DATA_IN_TOKEN_INTERRUPT 0
>> > - /* offset 0x0310, 0x0330, 0x0350, 0x0370, 0x0390, 0x03b0, 0x03d0 */
>> > - __le32 ep_avail;
>> > - __le32 ep_data;
>> > - u32 _unused0[2];
>> > -} __packed;
>> > -
>> > -struct net2280_reg_write {
>> > - __le16 port;
>> > - __le32 addr;
>> > - __le32 val;
>> > -} __packed;
>> > -
>> > -struct net2280_reg_read {
>> > - __le16 port;
>> > - __le32 addr;
>> > -} __packed;
>> > -#endif /* NET2280_H */
>> > diff --git a/drivers/net/wireless/p54/p54usb.h b/drivers/net/wireless/p54/p54usb.h
>> > index d273be7..a5f5f0f 100644
>> > --- a/drivers/net/wireless/p54/p54usb.h
>> > +++ b/drivers/net/wireless/p54/p54usb.h
>> > @@ -16,7 +16,7 @@
>> >
>> > /* for isl3886 register definitions used on ver 1 devices */
>> > #include "p54pci.h"
>> > -#include "net2280.h"
>> > +#include <linux/usb/net2280.h>
>> >
>> > /* pci */
>> > #define NET2280_BASE 0x10000000
>> > @@ -93,6 +93,17 @@ enum net2280_op_type {
>> > NET2280_DEV_CFG_U16 = 0x0883
>> > };
>> >
>> > +struct net2280_reg_write {
>> > + __le16 port;
>> > + __le32 addr;
>> > + __le32 val;
>> > +} __packed;
>> > +
>> > +struct net2280_reg_read {
>> > + __le16 port;
>> > + __le32 addr;
>> > +} __packed;
>> > +
>> > #define P54U_FW_BLOCK 2048
>> >
>> > #define X2_SIGNATURE "x2 "
>> > --
>> > 2.1.3
>> >
>>
>>
>>
>> --
>> Ricardo Ribalda
>>
>
> --
> John W. Linville Someday the world will need a hero, and you
> linville@tuxdriver.com might be all we have. Be ready.
--
Ricardo Ribalda
^ permalink raw reply
* Re: no connectivity on PF with Intel 82599/SR-IOV/OVS
From: Alexei Starovoitov @ 2014-12-01 20:47 UTC (permalink / raw)
To: Dmitry N., netdev@vger.kernel.org; +Cc: linux-kernel@vger.kernel.org
cc-ing netdev
On Mon, Dec 1, 2014 at 3:45 AM, Dmitry N. <plretbox@gmail.com> wrote:
> Hello all.
>
> I'm having an issue with SR-IOV on 82599 NIC in lab env. Basically
> what I have is Ubuntu 12.04 with a set of vanilla kernels and Open
> vSwitch.
>
> A simplified scheme for ovs setup:
> br-mgmt -> [vlan 102]br-eth0 -> eth0 -> fabric
>
> When VFs are disabled, connectivity works fine. However when at least
> one VF is enabled, traffic just doesn't go any further than br-eth0.
> Oddly enough, it acts this way only if VLAN is configured on br-eth0
> via OVS. When I try to configure VLAN with ip link, it works just
> fine.
>
> It's not an udev issue because re-adding eth0 to br-eth0 doesn't help.
> I've tried different OVS and ixgbe/ixgbevf versions against different
> kernel versions and ruled out issues with OVS and ixgbe.
>
> This could be a kernel bug.
>
> Kernel versions I've tried:
> 3.11.0 works fine
> 3.12.24 has this issue
> 3.14.23 has this issue
> 3.15.10 has this issue
> 3.16.7 and later kernels: the situation is opposite: when VFs are
> disabled, there is no connectivity on PF; as soon as at leas 1 VF is
> enabled, connectivity appears.
>
> OVS versions:
> 2.3.0 for user space
> 2.3.0 (and kernel native where 2.3.0 is not supported - starting with
> 3.15.x) for kernel space
>
> ixgbe:
> latest from Intel website (3.22.3)
>
> ixgbevf:
> latest from Intel website (2.15.3)
>
> Any suggestions? Thanks.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply
* [PATCH] SSB / B44: fix WOL for BCM4401
From: Andrey Skvortsov @ 2014-12-01 20:46 UTC (permalink / raw)
To: Rafael J. Wysocki, Gary Zambrano, Michael Buesch, netdev,
linux-kernel
Cc: Andrey Skvortsov
In-Reply-To: <20141201111125.GA11974@localhost.localdomain>
Wake On Lan was not working on laptop DELL Vostro 1500.
If WOL was turned on, BCM4401 was powered up in suspend mode. LEDs blinked.
But the laptop could not be woken up with the Magic Packet. The reason for
that was that PCIE was not enabled as a system wakeup source and
therefore the host PCI bridge was not powered up in suspend mode.
PCIE was not enabled in suspend by PM because no child devices were
registered as wakeup source during suspend process.
On laptop BCM4401 is connected through the SSB bus, that is connected to the
PCI-Express bus. SSB and B44 did not use standard PM wakeup functions
and did not forward wakeup settings to their parents.
To fix that B44 driver enables PM wakeup and registers new wakeup source
using device_set_wakeup_enable(). Wakeup is automatically reported to the parent SSB
bus via power.wakeup_path. SSB bus enables wakeup for the parent PCI bridge, if there is any
child devices with enabled wakeup functionality. All other steps are
done by PM core code.
Signed-off-by: Andrey Skvortsov <Andrej.Skvortzov@gmail.com>
---
drivers/net/ethernet/broadcom/b44.c | 2 ++
drivers/ssb/pcihost_wrapper.c | 33 ++++++++++++++++++++++-----------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index 416620f..ffeaf47 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -2104,6 +2104,7 @@ static int b44_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
bp->flags &= ~B44_FLAG_WOL_ENABLE;
spin_unlock_irq(&bp->lock);
+ device_set_wakeup_enable(bp->sdev->dev, wol->wolopts & WAKE_MAGIC);
return 0;
}
@@ -2452,6 +2453,7 @@ static int b44_init_one(struct ssb_device *sdev,
}
}
+ device_set_wakeup_capable(sdev->dev, true);
netdev_info(dev, "%s %pM\n", DRV_DESCRIPTION, dev->dev_addr);
return 0;
diff --git a/drivers/ssb/pcihost_wrapper.c b/drivers/ssb/pcihost_wrapper.c
index 69161bb..410215c 100644
--- a/drivers/ssb/pcihost_wrapper.c
+++ b/drivers/ssb/pcihost_wrapper.c
@@ -11,15 +11,17 @@
* Licensed under the GNU/GPL. See COPYING for details.
*/
+#include <linux/pm.h>
#include <linux/pci.h>
#include <linux/export.h>
#include <linux/slab.h>
#include <linux/ssb/ssb.h>
-#ifdef CONFIG_PM
-static int ssb_pcihost_suspend(struct pci_dev *dev, pm_message_t state)
+#ifdef CONFIG_PM_SLEEP
+static int ssb_pcihost_suspend(struct device *d)
{
+ struct pci_dev *dev = to_pci_dev(d);
struct ssb_bus *ssb = pci_get_drvdata(dev);
int err;
@@ -28,17 +30,23 @@ static int ssb_pcihost_suspend(struct pci_dev *dev, pm_message_t state)
return err;
pci_save_state(dev);
pci_disable_device(dev);
- pci_set_power_state(dev, pci_choose_state(dev, state));
+
+ /* if there is a wakeup enabled child device on ssb bus,
+ enable pci wakeup posibility. */
+ device_set_wakeup_enable(d, d->power.wakeup_path);
+
+ pci_prepare_to_sleep(dev);
return 0;
}
-static int ssb_pcihost_resume(struct pci_dev *dev)
+static int ssb_pcihost_resume(struct device *d)
{
+ struct pci_dev *dev = to_pci_dev(d);
struct ssb_bus *ssb = pci_get_drvdata(dev);
int err;
- pci_set_power_state(dev, PCI_D0);
+ pci_back_from_sleep(dev);
err = pci_enable_device(dev);
if (err)
return err;
@@ -49,10 +57,12 @@ static int ssb_pcihost_resume(struct pci_dev *dev)
return 0;
}
-#else /* CONFIG_PM */
-# define ssb_pcihost_suspend NULL
-# define ssb_pcihost_resume NULL
-#endif /* CONFIG_PM */
+
+static const struct dev_pm_ops ssb_pcihost_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(ssb_pcihost_suspend, ssb_pcihost_resume)
+};
+
+#endif /* CONFIG_PM_SLEEP */
static int ssb_pcihost_probe(struct pci_dev *dev,
const struct pci_device_id *id)
@@ -115,8 +125,9 @@ int ssb_pcihost_register(struct pci_driver *driver)
{
driver->probe = ssb_pcihost_probe;
driver->remove = ssb_pcihost_remove;
- driver->suspend = ssb_pcihost_suspend;
- driver->resume = ssb_pcihost_resume;
+#ifdef CONFIG_PM_SLEEP
+ driver->driver.pm = &ssb_pcihost_pm_ops;
+#endif
return pci_register_driver(driver);
}
--
1.7.2.5
^ permalink raw reply related
* Re: [PATCH 1/1] net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
From: Olof Johansson @ 2014-12-01 20:36 UTC (permalink / raw)
To: SF Markus Elfring
Cc: Network Development, LKML, kernel-janitors, Julia Lawall
In-Reply-To: <547A09B1.9090102@users.sourceforge.net>
On Sat, Nov 29, 2014 at 10:00 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 29 Nov 2014 18:55:40 +0100
>
> The pci_dev_put() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call
> is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
For this particular case:
Acked-by: Olof Johansson <olof@lixom.net>
Note that the "this might cause problems with backports" case is
mostly academic in the scope of _this particular driver_. It's still a
very valid discussion and issue though.
So I'll be happy to give the ack on this driver, but the larger
problem needs consideration still.
-Olof
^ permalink raw reply
* Re: net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
From: Julia Lawall @ 2014-12-01 20:34 UTC (permalink / raw)
To: Johannes Berg
Cc: SF Markus Elfring, Lino Sanfilippo, Olof Johansson, netdev,
backports, LKML, kernel-janitors, Luis R. Rodriguez
In-Reply-To: <1417465745.28610.0.camel@sipsolutions.net>
On Mon, 1 Dec 2014, Johannes Berg wrote:
> On Mon, 2014-12-01 at 02:34 +0100, SF Markus Elfring wrote:
>
> > > Some of those NULL pointer checks on input parameters may have been
> > > added subsequently to functions. So there may be older kernel versions
> > > out there in which those checks dont exists in some cases. If some of
> > > the now "cleaned up" code is backported to such a kernel chances are
> > > good that those missing checks are overseen. And then neither caller nor
> > > callee is doing the NULL pointer check.
>
> > I assume that a few backporters can tell you more about their corresponding
> > software development experiences.
> > http://www.do-not-panic.com/2014/04/automatic-linux-kernel-backporting-with-coccinelle.html
>
> In such cases we just provide an appropriate wrapper and replace callers
> of the original function by callers of the wrapper, typically with a
> #define.
>
> So this kind of evolution is no problem for the (automated) backports
> using the backports project - although it can be difficult to detect
> such a thing is needed.
That is exactly the problem...
julia
^ permalink raw reply
* Re: net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
From: Johannes Berg @ 2014-12-01 20:29 UTC (permalink / raw)
To: SF Markus Elfring
Cc: Lino Sanfilippo, Olof Johansson, netdev, backports, LKML,
kernel-janitors, Julia Lawall, Luis R. Rodriguez
In-Reply-To: <547BC5AD.6090500@users.sourceforge.net>
On Mon, 2014-12-01 at 02:34 +0100, SF Markus Elfring wrote:
> > Some of those NULL pointer checks on input parameters may have been
> > added subsequently to functions. So there may be older kernel versions
> > out there in which those checks dont exists in some cases. If some of
> > the now "cleaned up" code is backported to such a kernel chances are
> > good that those missing checks are overseen. And then neither caller nor
> > callee is doing the NULL pointer check.
> I assume that a few backporters can tell you more about their corresponding
> software development experiences.
> http://www.do-not-panic.com/2014/04/automatic-linux-kernel-backporting-with-coccinelle.html
In such cases we just provide an appropriate wrapper and replace callers
of the original function by callers of the wrapper, typically with a
#define.
So this kind of evolution is no problem for the (automated) backports
using the backports project - although it can be difficult to detect
such a thing is needed.
johannes
^ permalink raw reply
* Re: [PATCH] stmmac: platform: fix stmmac probe failure
From: Dinh Nguyen @ 2014-12-01 20:14 UTC (permalink / raw)
To: davem, peppe.cavallaro
Cc: dinh.linux, maxime.ripard, olof, vbridger, netdev, linux-kernel
In-Reply-To: <1417464054-8777-1-git-send-email-dinguyen@opensource.altera.com>
Apologies for the noise, but it looks like Arnd has already send a patch
for this.
http://www.spinics.net/lists/netdev/msg306603.html
Dinh
On 12/1/14, 2:00 PM, dinguyen@opensource.altera.com wrote:
> From: Dinh Nguyen <dinguyen@opensource.altera.com>
>
> The commit 571dcfde23712b ("stmmac: platform: fix default values of the filter
> bins setting") broke support for stmmac probe for all CONFIG_OF platforms.
>
> [ 0.743567] Unable to handle kernel NULL pointer dereference at virtual address 00000048
> [ 0.751679] pgd = c0004000
> [ 0.754384] [00000048] *pgd=00000000
> [ 0.757983] Internal error: Oops: 805 [#1] SMP ARM
> [ 0.762774] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.18.0-rc7 #1
> [ 0.769034] task: ee86c000 ti: ee870000 task.ti: ee870000
> [ 0.774429] PC is at stmmac_pltfr_probe+0x40/0x5d0
> [ 0.779217] LR is at devm_ioremap_nocache+0x54/0x74
> ...
> [ 0.951644] [<c0287938>] (stmmac_pltfr_probe) from [<c0234c4c>] (platform_drv_probe+0x44/0xa4)
> [ 0.960250] [<c0234c4c>] (platform_drv_probe) from [<c023390c>] (driver_probe_device+0x10c/0x240)
> [ 0.969113] [<c023390c>] (driver_probe_device) from [<c0233b10>] (__driver_attach+0x8c/0x90)
> [ 0.977544] [<c0233b10>] (__driver_attach) from [<c02320fc>] (bus_for_each_dev+0x6c/0xa0)
>
> The reason is that in stmmac_pltfr_probe(), the plat_dat on a CONFIG_OF
> platform is NULL until devm_kzalloc() is called to allocate plat_dat.
>
> Signed-off-by: Dinh Nguyen <dinguyen@opensource.altera.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> index 5b0da39..62c9e75 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> @@ -265,12 +265,6 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
>
> plat_dat = dev_get_platdata(&pdev->dev);
>
> - /* Set default value for multicast hash bins */
> - plat_dat->multicast_filter_bins = HASH_TABLE_SIZE;
> -
> - /* Set default value for unicast filter entries */
> - plat_dat->unicast_filter_entries = 1;
> -
> if (pdev->dev.of_node) {
> if (!plat_dat)
> plat_dat = devm_kzalloc(&pdev->dev,
> @@ -288,6 +282,12 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
> }
> }
>
> + /* Set default value for multicast hash bins */
> + plat_dat->multicast_filter_bins = HASH_TABLE_SIZE;
> +
> + /* Set default value for unicast filter entries */
> + plat_dat->unicast_filter_entries = 1;
> +
> /* Custom setup (if needed) */
> if (plat_dat->setup) {
> plat_dat->bsp_priv = plat_dat->setup(pdev);
>
^ permalink raw reply
* [PATCH] stmmac: platform: fix stmmac probe failure
From: dinguyen @ 2014-12-01 20:00 UTC (permalink / raw)
To: davem, peppe.cavallaro
Cc: dinh.linux, maxime.ripard, olof, vbridger, netdev, linux-kernel,
Dinh Nguyen
From: Dinh Nguyen <dinguyen@opensource.altera.com>
The commit 571dcfde23712b ("stmmac: platform: fix default values of the filter
bins setting") broke support for stmmac probe for all CONFIG_OF platforms.
[ 0.743567] Unable to handle kernel NULL pointer dereference at virtual address 00000048
[ 0.751679] pgd = c0004000
[ 0.754384] [00000048] *pgd=00000000
[ 0.757983] Internal error: Oops: 805 [#1] SMP ARM
[ 0.762774] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.18.0-rc7 #1
[ 0.769034] task: ee86c000 ti: ee870000 task.ti: ee870000
[ 0.774429] PC is at stmmac_pltfr_probe+0x40/0x5d0
[ 0.779217] LR is at devm_ioremap_nocache+0x54/0x74
...
[ 0.951644] [<c0287938>] (stmmac_pltfr_probe) from [<c0234c4c>] (platform_drv_probe+0x44/0xa4)
[ 0.960250] [<c0234c4c>] (platform_drv_probe) from [<c023390c>] (driver_probe_device+0x10c/0x240)
[ 0.969113] [<c023390c>] (driver_probe_device) from [<c0233b10>] (__driver_attach+0x8c/0x90)
[ 0.977544] [<c0233b10>] (__driver_attach) from [<c02320fc>] (bus_for_each_dev+0x6c/0xa0)
The reason is that in stmmac_pltfr_probe(), the plat_dat on a CONFIG_OF
platform is NULL until devm_kzalloc() is called to allocate plat_dat.
Signed-off-by: Dinh Nguyen <dinguyen@opensource.altera.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 5b0da39..62c9e75 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -265,12 +265,6 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
plat_dat = dev_get_platdata(&pdev->dev);
- /* Set default value for multicast hash bins */
- plat_dat->multicast_filter_bins = HASH_TABLE_SIZE;
-
- /* Set default value for unicast filter entries */
- plat_dat->unicast_filter_entries = 1;
-
if (pdev->dev.of_node) {
if (!plat_dat)
plat_dat = devm_kzalloc(&pdev->dev,
@@ -288,6 +282,12 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
}
}
+ /* Set default value for multicast hash bins */
+ plat_dat->multicast_filter_bins = HASH_TABLE_SIZE;
+
+ /* Set default value for unicast filter entries */
+ plat_dat->unicast_filter_entries = 1;
+
/* Custom setup (if needed) */
if (plat_dat->setup) {
plat_dat->bsp_priv = plat_dat->setup(pdev);
--
2.0.3
^ permalink raw reply related
* Re: [PATCH] wireless/p54: Remove duplicated net2280 header
From: John W. Linville @ 2014-12-01 19:59 UTC (permalink / raw)
To: Ricardo Ribalda Delgado
Cc: Christian Lamparter, LKML, linux-wireless, netdev, David Miller
In-Reply-To: <CAPybu_1LBqp5JKBUr85HWfkcSJH5vy2zY9Z13Xvw7W1xyjKOzg@mail.gmail.com>
Did you check the wireless-next tree's git logs?
commit a831f20b6d6460640b83644d1c1df6e7e8ca9f68
Author: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Date: Mon Nov 24 11:19:51 2014 +0100
wireless/p54: Remove duplicated net2280 header
The usb gadget driver net2280 has exported a header file with the
register definition of the net2280 chip.
Remove the custom/duplicated header file in favor of that header file
in include/linux
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
On Mon, Dec 01, 2014 at 11:46:43AM +0100, Ricardo Ribalda Delgado wrote:
> David Miller has marked the patch as "Awaiting Upstream", which I
> think means that it should be merged through the wireless tree.
>
> Any comment from there?
>
> On Mon, Nov 24, 2014 at 11:19 AM, Ricardo Ribalda Delgado
> <ricardo.ribalda@gmail.com> wrote:
> > The usb gadget driver net2280 has exported a header file with the
> > register definition of the net2280 chip.
> >
> > Remove the custom/duplicated header file in favor of that header file
> > in include/linux
> >
> > Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> > ---
> > drivers/net/wireless/p54/net2280.h | 451 -------------------------------------
> > drivers/net/wireless/p54/p54usb.h | 13 +-
> > 2 files changed, 12 insertions(+), 452 deletions(-)
> > delete mode 100644 drivers/net/wireless/p54/net2280.h
> >
> > diff --git a/drivers/net/wireless/p54/net2280.h b/drivers/net/wireless/p54/net2280.h
> > deleted file mode 100644
> > index aedfaf2..0000000
> > --- a/drivers/net/wireless/p54/net2280.h
> > +++ /dev/null
> > @@ -1,451 +0,0 @@
> > -#ifndef NET2280_H
> > -#define NET2280_H
> > -/*
> > - * NetChip 2280 high/full speed USB device controller.
> > - * Unlike many such controllers, this one talks PCI.
> > - */
> > -
> > -/*
> > - * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
> > - * Copyright (C) 2003 David Brownell
> > - *
> > - * This program is free software; you can redistribute it and/or modify
> > - * it under the terms of the GNU General Public License as published by
> > - * the Free Software Foundation; either version 2 of the License, or
> > - * (at your option) any later version.
> > - *
> > - * This program is distributed in the hope that it will be useful,
> > - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > - * GNU General Public License for more details.
> > - *
> > - * You should have received a copy of the GNU General Public License
> > - * along with this program; if not, see <http://www.gnu.org/licenses/>.
> > - */
> > -
> > -/*-------------------------------------------------------------------------*/
> > -
> > -/* NET2280 MEMORY MAPPED REGISTERS
> > - *
> > - * The register layout came from the chip documentation, and the bit
> > - * number definitions were extracted from chip specification.
> > - *
> > - * Use the shift operator ('<<') to build bit masks, with readl/writel
> > - * to access the registers through PCI.
> > - */
> > -
> > -/* main registers, BAR0 + 0x0000 */
> > -struct net2280_regs {
> > - /* offset 0x0000 */
> > - __le32 devinit;
> > -#define LOCAL_CLOCK_FREQUENCY 8
> > -#define FORCE_PCI_RESET 7
> > -#define PCI_ID 6
> > -#define PCI_ENABLE 5
> > -#define FIFO_SOFT_RESET 4
> > -#define CFG_SOFT_RESET 3
> > -#define PCI_SOFT_RESET 2
> > -#define USB_SOFT_RESET 1
> > -#define M8051_RESET 0
> > - __le32 eectl;
> > -#define EEPROM_ADDRESS_WIDTH 23
> > -#define EEPROM_CHIP_SELECT_ACTIVE 22
> > -#define EEPROM_PRESENT 21
> > -#define EEPROM_VALID 20
> > -#define EEPROM_BUSY 19
> > -#define EEPROM_CHIP_SELECT_ENABLE 18
> > -#define EEPROM_BYTE_READ_START 17
> > -#define EEPROM_BYTE_WRITE_START 16
> > -#define EEPROM_READ_DATA 8
> > -#define EEPROM_WRITE_DATA 0
> > - __le32 eeclkfreq;
> > - u32 _unused0;
> > - /* offset 0x0010 */
> > -
> > - __le32 pciirqenb0; /* interrupt PCI master ... */
> > -#define SETUP_PACKET_INTERRUPT_ENABLE 7
> > -#define ENDPOINT_F_INTERRUPT_ENABLE 6
> > -#define ENDPOINT_E_INTERRUPT_ENABLE 5
> > -#define ENDPOINT_D_INTERRUPT_ENABLE 4
> > -#define ENDPOINT_C_INTERRUPT_ENABLE 3
> > -#define ENDPOINT_B_INTERRUPT_ENABLE 2
> > -#define ENDPOINT_A_INTERRUPT_ENABLE 1
> > -#define ENDPOINT_0_INTERRUPT_ENABLE 0
> > - __le32 pciirqenb1;
> > -#define PCI_INTERRUPT_ENABLE 31
> > -#define POWER_STATE_CHANGE_INTERRUPT_ENABLE 27
> > -#define PCI_ARBITER_TIMEOUT_INTERRUPT_ENABLE 26
> > -#define PCI_PARITY_ERROR_INTERRUPT_ENABLE 25
> > -#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE 20
> > -#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE 19
> > -#define PCI_TARGET_ABORT_ASSERTED_INTERRUPT_ENABLE 18
> > -#define PCI_RETRY_ABORT_INTERRUPT_ENABLE 17
> > -#define PCI_MASTER_CYCLE_DONE_INTERRUPT_ENABLE 16
> > -#define GPIO_INTERRUPT_ENABLE 13
> > -#define DMA_D_INTERRUPT_ENABLE 12
> > -#define DMA_C_INTERRUPT_ENABLE 11
> > -#define DMA_B_INTERRUPT_ENABLE 10
> > -#define DMA_A_INTERRUPT_ENABLE 9
> > -#define EEPROM_DONE_INTERRUPT_ENABLE 8
> > -#define VBUS_INTERRUPT_ENABLE 7
> > -#define CONTROL_STATUS_INTERRUPT_ENABLE 6
> > -#define ROOT_PORT_RESET_INTERRUPT_ENABLE 4
> > -#define SUSPEND_REQUEST_INTERRUPT_ENABLE 3
> > -#define SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE 2
> > -#define RESUME_INTERRUPT_ENABLE 1
> > -#define SOF_INTERRUPT_ENABLE 0
> > - __le32 cpu_irqenb0; /* ... or onboard 8051 */
> > -#define SETUP_PACKET_INTERRUPT_ENABLE 7
> > -#define ENDPOINT_F_INTERRUPT_ENABLE 6
> > -#define ENDPOINT_E_INTERRUPT_ENABLE 5
> > -#define ENDPOINT_D_INTERRUPT_ENABLE 4
> > -#define ENDPOINT_C_INTERRUPT_ENABLE 3
> > -#define ENDPOINT_B_INTERRUPT_ENABLE 2
> > -#define ENDPOINT_A_INTERRUPT_ENABLE 1
> > -#define ENDPOINT_0_INTERRUPT_ENABLE 0
> > - __le32 cpu_irqenb1;
> > -#define CPU_INTERRUPT_ENABLE 31
> > -#define POWER_STATE_CHANGE_INTERRUPT_ENABLE 27
> > -#define PCI_ARBITER_TIMEOUT_INTERRUPT_ENABLE 26
> > -#define PCI_PARITY_ERROR_INTERRUPT_ENABLE 25
> > -#define PCI_INTA_INTERRUPT_ENABLE 24
> > -#define PCI_PME_INTERRUPT_ENABLE 23
> > -#define PCI_SERR_INTERRUPT_ENABLE 22
> > -#define PCI_PERR_INTERRUPT_ENABLE 21
> > -#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE 20
> > -#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE 19
> > -#define PCI_RETRY_ABORT_INTERRUPT_ENABLE 17
> > -#define PCI_MASTER_CYCLE_DONE_INTERRUPT_ENABLE 16
> > -#define GPIO_INTERRUPT_ENABLE 13
> > -#define DMA_D_INTERRUPT_ENABLE 12
> > -#define DMA_C_INTERRUPT_ENABLE 11
> > -#define DMA_B_INTERRUPT_ENABLE 10
> > -#define DMA_A_INTERRUPT_ENABLE 9
> > -#define EEPROM_DONE_INTERRUPT_ENABLE 8
> > -#define VBUS_INTERRUPT_ENABLE 7
> > -#define CONTROL_STATUS_INTERRUPT_ENABLE 6
> > -#define ROOT_PORT_RESET_INTERRUPT_ENABLE 4
> > -#define SUSPEND_REQUEST_INTERRUPT_ENABLE 3
> > -#define SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE 2
> > -#define RESUME_INTERRUPT_ENABLE 1
> > -#define SOF_INTERRUPT_ENABLE 0
> > -
> > - /* offset 0x0020 */
> > - u32 _unused1;
> > - __le32 usbirqenb1;
> > -#define USB_INTERRUPT_ENABLE 31
> > -#define POWER_STATE_CHANGE_INTERRUPT_ENABLE 27
> > -#define PCI_ARBITER_TIMEOUT_INTERRUPT_ENABLE 26
> > -#define PCI_PARITY_ERROR_INTERRUPT_ENABLE 25
> > -#define PCI_INTA_INTERRUPT_ENABLE 24
> > -#define PCI_PME_INTERRUPT_ENABLE 23
> > -#define PCI_SERR_INTERRUPT_ENABLE 22
> > -#define PCI_PERR_INTERRUPT_ENABLE 21
> > -#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE 20
> > -#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE 19
> > -#define PCI_RETRY_ABORT_INTERRUPT_ENABLE 17
> > -#define PCI_MASTER_CYCLE_DONE_INTERRUPT_ENABLE 16
> > -#define GPIO_INTERRUPT_ENABLE 13
> > -#define DMA_D_INTERRUPT_ENABLE 12
> > -#define DMA_C_INTERRUPT_ENABLE 11
> > -#define DMA_B_INTERRUPT_ENABLE 10
> > -#define DMA_A_INTERRUPT_ENABLE 9
> > -#define EEPROM_DONE_INTERRUPT_ENABLE 8
> > -#define VBUS_INTERRUPT_ENABLE 7
> > -#define CONTROL_STATUS_INTERRUPT_ENABLE 6
> > -#define ROOT_PORT_RESET_INTERRUPT_ENABLE 4
> > -#define SUSPEND_REQUEST_INTERRUPT_ENABLE 3
> > -#define SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE 2
> > -#define RESUME_INTERRUPT_ENABLE 1
> > -#define SOF_INTERRUPT_ENABLE 0
> > - __le32 irqstat0;
> > -#define INTA_ASSERTED 12
> > -#define SETUP_PACKET_INTERRUPT 7
> > -#define ENDPOINT_F_INTERRUPT 6
> > -#define ENDPOINT_E_INTERRUPT 5
> > -#define ENDPOINT_D_INTERRUPT 4
> > -#define ENDPOINT_C_INTERRUPT 3
> > -#define ENDPOINT_B_INTERRUPT 2
> > -#define ENDPOINT_A_INTERRUPT 1
> > -#define ENDPOINT_0_INTERRUPT 0
> > - __le32 irqstat1;
> > -#define POWER_STATE_CHANGE_INTERRUPT 27
> > -#define PCI_ARBITER_TIMEOUT_INTERRUPT 26
> > -#define PCI_PARITY_ERROR_INTERRUPT 25
> > -#define PCI_INTA_INTERRUPT 24
> > -#define PCI_PME_INTERRUPT 23
> > -#define PCI_SERR_INTERRUPT 22
> > -#define PCI_PERR_INTERRUPT 21
> > -#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT 20
> > -#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT 19
> > -#define PCI_RETRY_ABORT_INTERRUPT 17
> > -#define PCI_MASTER_CYCLE_DONE_INTERRUPT 16
> > -#define GPIO_INTERRUPT 13
> > -#define DMA_D_INTERRUPT 12
> > -#define DMA_C_INTERRUPT 11
> > -#define DMA_B_INTERRUPT 10
> > -#define DMA_A_INTERRUPT 9
> > -#define EEPROM_DONE_INTERRUPT 8
> > -#define VBUS_INTERRUPT 7
> > -#define CONTROL_STATUS_INTERRUPT 6
> > -#define ROOT_PORT_RESET_INTERRUPT 4
> > -#define SUSPEND_REQUEST_INTERRUPT 3
> > -#define SUSPEND_REQUEST_CHANGE_INTERRUPT 2
> > -#define RESUME_INTERRUPT 1
> > -#define SOF_INTERRUPT 0
> > - /* offset 0x0030 */
> > - __le32 idxaddr;
> > - __le32 idxdata;
> > - __le32 fifoctl;
> > -#define PCI_BASE2_RANGE 16
> > -#define IGNORE_FIFO_AVAILABILITY 3
> > -#define PCI_BASE2_SELECT 2
> > -#define FIFO_CONFIGURATION_SELECT 0
> > - u32 _unused2;
> > - /* offset 0x0040 */
> > - __le32 memaddr;
> > -#define START 28
> > -#define DIRECTION 27
> > -#define FIFO_DIAGNOSTIC_SELECT 24
> > -#define MEMORY_ADDRESS 0
> > - __le32 memdata0;
> > - __le32 memdata1;
> > - u32 _unused3;
> > - /* offset 0x0050 */
> > - __le32 gpioctl;
> > -#define GPIO3_LED_SELECT 12
> > -#define GPIO3_INTERRUPT_ENABLE 11
> > -#define GPIO2_INTERRUPT_ENABLE 10
> > -#define GPIO1_INTERRUPT_ENABLE 9
> > -#define GPIO0_INTERRUPT_ENABLE 8
> > -#define GPIO3_OUTPUT_ENABLE 7
> > -#define GPIO2_OUTPUT_ENABLE 6
> > -#define GPIO1_OUTPUT_ENABLE 5
> > -#define GPIO0_OUTPUT_ENABLE 4
> > -#define GPIO3_DATA 3
> > -#define GPIO2_DATA 2
> > -#define GPIO1_DATA 1
> > -#define GPIO0_DATA 0
> > - __le32 gpiostat;
> > -#define GPIO3_INTERRUPT 3
> > -#define GPIO2_INTERRUPT 2
> > -#define GPIO1_INTERRUPT 1
> > -#define GPIO0_INTERRUPT 0
> > -} __packed;
> > -
> > -/* usb control, BAR0 + 0x0080 */
> > -struct net2280_usb_regs {
> > - /* offset 0x0080 */
> > - __le32 stdrsp;
> > -#define STALL_UNSUPPORTED_REQUESTS 31
> > -#define SET_TEST_MODE 16
> > -#define GET_OTHER_SPEED_CONFIGURATION 15
> > -#define GET_DEVICE_QUALIFIER 14
> > -#define SET_ADDRESS 13
> > -#define ENDPOINT_SET_CLEAR_HALT 12
> > -#define DEVICE_SET_CLEAR_DEVICE_REMOTE_WAKEUP 11
> > -#define GET_STRING_DESCRIPTOR_2 10
> > -#define GET_STRING_DESCRIPTOR_1 9
> > -#define GET_STRING_DESCRIPTOR_0 8
> > -#define GET_SET_INTERFACE 6
> > -#define GET_SET_CONFIGURATION 5
> > -#define GET_CONFIGURATION_DESCRIPTOR 4
> > -#define GET_DEVICE_DESCRIPTOR 3
> > -#define GET_ENDPOINT_STATUS 2
> > -#define GET_INTERFACE_STATUS 1
> > -#define GET_DEVICE_STATUS 0
> > - __le32 prodvendid;
> > -#define PRODUCT_ID 16
> > -#define VENDOR_ID 0
> > - __le32 relnum;
> > - __le32 usbctl;
> > -#define SERIAL_NUMBER_INDEX 16
> > -#define PRODUCT_ID_STRING_ENABLE 13
> > -#define VENDOR_ID_STRING_ENABLE 12
> > -#define USB_ROOT_PORT_WAKEUP_ENABLE 11
> > -#define VBUS_PIN 10
> > -#define TIMED_DISCONNECT 9
> > -#define SUSPEND_IMMEDIATELY 7
> > -#define SELF_POWERED_USB_DEVICE 6
> > -#define REMOTE_WAKEUP_SUPPORT 5
> > -#define PME_POLARITY 4
> > -#define USB_DETECT_ENABLE 3
> > -#define PME_WAKEUP_ENABLE 2
> > -#define DEVICE_REMOTE_WAKEUP_ENABLE 1
> > -#define SELF_POWERED_STATUS 0
> > - /* offset 0x0090 */
> > - __le32 usbstat;
> > -#define HIGH_SPEED 7
> > -#define FULL_SPEED 6
> > -#define GENERATE_RESUME 5
> > -#define GENERATE_DEVICE_REMOTE_WAKEUP 4
> > - __le32 xcvrdiag;
> > -#define FORCE_HIGH_SPEED_MODE 31
> > -#define FORCE_FULL_SPEED_MODE 30
> > -#define USB_TEST_MODE 24
> > -#define LINE_STATE 16
> > -#define TRANSCEIVER_OPERATION_MODE 2
> > -#define TRANSCEIVER_SELECT 1
> > -#define TERMINATION_SELECT 0
> > - __le32 setup0123;
> > - __le32 setup4567;
> > - /* offset 0x0090 */
> > - u32 _unused0;
> > - __le32 ouraddr;
> > -#define FORCE_IMMEDIATE 7
> > -#define OUR_USB_ADDRESS 0
> > - __le32 ourconfig;
> > -} __packed;
> > -
> > -/* pci control, BAR0 + 0x0100 */
> > -struct net2280_pci_regs {
> > - /* offset 0x0100 */
> > - __le32 pcimstctl;
> > -#define PCI_ARBITER_PARK_SELECT 13
> > -#define PCI_MULTI LEVEL_ARBITER 12
> > -#define PCI_RETRY_ABORT_ENABLE 11
> > -#define DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE 10
> > -#define DMA_READ_MULTIPLE_ENABLE 9
> > -#define DMA_READ_LINE_ENABLE 8
> > -#define PCI_MASTER_COMMAND_SELECT 6
> > -#define MEM_READ_OR_WRITE 0
> > -#define IO_READ_OR_WRITE 1
> > -#define CFG_READ_OR_WRITE 2
> > -#define PCI_MASTER_START 5
> > -#define PCI_MASTER_READ_WRITE 4
> > -#define PCI_MASTER_WRITE 0
> > -#define PCI_MASTER_READ 1
> > -#define PCI_MASTER_BYTE_WRITE_ENABLES 0
> > - __le32 pcimstaddr;
> > - __le32 pcimstdata;
> > - __le32 pcimststat;
> > -#define PCI_ARBITER_CLEAR 2
> > -#define PCI_EXTERNAL_ARBITER 1
> > -#define PCI_HOST_MODE 0
> > -} __packed;
> > -
> > -/* dma control, BAR0 + 0x0180 ... array of four structs like this,
> > - * for channels 0..3. see also struct net2280_dma: descriptor
> > - * that can be loaded into some of these registers.
> > - */
> > -struct net2280_dma_regs { /* [11.7] */
> > - /* offset 0x0180, 0x01a0, 0x01c0, 0x01e0, */
> > - __le32 dmactl;
> > -#define DMA_SCATTER_GATHER_DONE_INTERRUPT_ENABLE 25
> > -#define DMA_CLEAR_COUNT_ENABLE 21
> > -#define DESCRIPTOR_POLLING_RATE 19
> > -#define POLL_CONTINUOUS 0
> > -#define POLL_1_USEC 1
> > -#define POLL_100_USEC 2
> > -#define POLL_1_MSEC 3
> > -#define DMA_VALID_BIT_POLLING_ENABLE 18
> > -#define DMA_VALID_BIT_ENABLE 17
> > -#define DMA_SCATTER_GATHER_ENABLE 16
> > -#define DMA_OUT_AUTO_START_ENABLE 4
> > -#define DMA_PREEMPT_ENABLE 3
> > -#define DMA_FIFO_VALIDATE 2
> > -#define DMA_ENABLE 1
> > -#define DMA_ADDRESS_HOLD 0
> > - __le32 dmastat;
> > -#define DMA_SCATTER_GATHER_DONE_INTERRUPT 25
> > -#define DMA_TRANSACTION_DONE_INTERRUPT 24
> > -#define DMA_ABORT 1
> > -#define DMA_START 0
> > - u32 _unused0[2];
> > - /* offset 0x0190, 0x01b0, 0x01d0, 0x01f0, */
> > - __le32 dmacount;
> > -#define VALID_BIT 31
> > -#define DMA_DIRECTION 30
> > -#define DMA_DONE_INTERRUPT_ENABLE 29
> > -#define END_OF_CHAIN 28
> > -#define DMA_BYTE_COUNT_MASK ((1<<24)-1)
> > -#define DMA_BYTE_COUNT 0
> > - __le32 dmaaddr;
> > - __le32 dmadesc;
> > - u32 _unused1;
> > -} __packed;
> > -
> > -/* dedicated endpoint registers, BAR0 + 0x0200 */
> > -
> > -struct net2280_dep_regs { /* [11.8] */
> > - /* offset 0x0200, 0x0210, 0x220, 0x230, 0x240 */
> > - __le32 dep_cfg;
> > - /* offset 0x0204, 0x0214, 0x224, 0x234, 0x244 */
> > - __le32 dep_rsp;
> > - u32 _unused[2];
> > -} __packed;
> > -
> > -/* configurable endpoint registers, BAR0 + 0x0300 ... array of seven structs
> > - * like this, for ep0 then the configurable endpoints A..F
> > - * ep0 reserved for control; E and F have only 64 bytes of fifo
> > - */
> > -struct net2280_ep_regs { /* [11.9] */
> > - /* offset 0x0300, 0x0320, 0x0340, 0x0360, 0x0380, 0x03a0, 0x03c0 */
> > - __le32 ep_cfg;
> > -#define ENDPOINT_BYTE_COUNT 16
> > -#define ENDPOINT_ENABLE 10
> > -#define ENDPOINT_TYPE 8
> > -#define ENDPOINT_DIRECTION 7
> > -#define ENDPOINT_NUMBER 0
> > - __le32 ep_rsp;
> > -#define SET_NAK_OUT_PACKETS 15
> > -#define SET_EP_HIDE_STATUS_PHASE 14
> > -#define SET_EP_FORCE_CRC_ERROR 13
> > -#define SET_INTERRUPT_MODE 12
> > -#define SET_CONTROL_STATUS_PHASE_HANDSHAKE 11
> > -#define SET_NAK_OUT_PACKETS_MODE 10
> > -#define SET_ENDPOINT_TOGGLE 9
> > -#define SET_ENDPOINT_HALT 8
> > -#define CLEAR_NAK_OUT_PACKETS 7
> > -#define CLEAR_EP_HIDE_STATUS_PHASE 6
> > -#define CLEAR_EP_FORCE_CRC_ERROR 5
> > -#define CLEAR_INTERRUPT_MODE 4
> > -#define CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE 3
> > -#define CLEAR_NAK_OUT_PACKETS_MODE 2
> > -#define CLEAR_ENDPOINT_TOGGLE 1
> > -#define CLEAR_ENDPOINT_HALT 0
> > - __le32 ep_irqenb;
> > -#define SHORT_PACKET_OUT_DONE_INTERRUPT_ENABLE 6
> > -#define SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE 5
> > -#define DATA_PACKET_RECEIVED_INTERRUPT_ENABLE 3
> > -#define DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE 2
> > -#define DATA_OUT_PING_TOKEN_INTERRUPT_ENABLE 1
> > -#define DATA_IN_TOKEN_INTERRUPT_ENABLE 0
> > - __le32 ep_stat;
> > -#define FIFO_VALID_COUNT 24
> > -#define HIGH_BANDWIDTH_OUT_TRANSACTION_PID 22
> > -#define TIMEOUT 21
> > -#define USB_STALL_SENT 20
> > -#define USB_IN_NAK_SENT 19
> > -#define USB_IN_ACK_RCVD 18
> > -#define USB_OUT_PING_NAK_SENT 17
> > -#define USB_OUT_ACK_SENT 16
> > -#define FIFO_OVERFLOW 13
> > -#define FIFO_UNDERFLOW 12
> > -#define FIFO_FULL 11
> > -#define FIFO_EMPTY 10
> > -#define FIFO_FLUSH 9
> > -#define SHORT_PACKET_OUT_DONE_INTERRUPT 6
> > -#define SHORT_PACKET_TRANSFERRED_INTERRUPT 5
> > -#define NAK_OUT_PACKETS 4
> > -#define DATA_PACKET_RECEIVED_INTERRUPT 3
> > -#define DATA_PACKET_TRANSMITTED_INTERRUPT 2
> > -#define DATA_OUT_PING_TOKEN_INTERRUPT 1
> > -#define DATA_IN_TOKEN_INTERRUPT 0
> > - /* offset 0x0310, 0x0330, 0x0350, 0x0370, 0x0390, 0x03b0, 0x03d0 */
> > - __le32 ep_avail;
> > - __le32 ep_data;
> > - u32 _unused0[2];
> > -} __packed;
> > -
> > -struct net2280_reg_write {
> > - __le16 port;
> > - __le32 addr;
> > - __le32 val;
> > -} __packed;
> > -
> > -struct net2280_reg_read {
> > - __le16 port;
> > - __le32 addr;
> > -} __packed;
> > -#endif /* NET2280_H */
> > diff --git a/drivers/net/wireless/p54/p54usb.h b/drivers/net/wireless/p54/p54usb.h
> > index d273be7..a5f5f0f 100644
> > --- a/drivers/net/wireless/p54/p54usb.h
> > +++ b/drivers/net/wireless/p54/p54usb.h
> > @@ -16,7 +16,7 @@
> >
> > /* for isl3886 register definitions used on ver 1 devices */
> > #include "p54pci.h"
> > -#include "net2280.h"
> > +#include <linux/usb/net2280.h>
> >
> > /* pci */
> > #define NET2280_BASE 0x10000000
> > @@ -93,6 +93,17 @@ enum net2280_op_type {
> > NET2280_DEV_CFG_U16 = 0x0883
> > };
> >
> > +struct net2280_reg_write {
> > + __le16 port;
> > + __le32 addr;
> > + __le32 val;
> > +} __packed;
> > +
> > +struct net2280_reg_read {
> > + __le16 port;
> > + __le32 addr;
> > +} __packed;
> > +
> > #define P54U_FW_BLOCK 2048
> >
> > #define X2_SIGNATURE "x2 "
> > --
> > 2.1.3
> >
>
>
>
> --
> Ricardo Ribalda
>
--
John W. Linville Someday the world will need a hero, and you
linville@tuxdriver.com might be all we have. Be ready.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox