* [PATCH bpf-next v2 7/8] tools: bpftool: report device information for offloaded programs
From: Jakub Kicinski @ 2017-12-21 21:01 UTC (permalink / raw)
To: netdev, alexei.starovoitov, daniel; +Cc: ktkhai, oss-drivers, Jakub Kicinski
In-Reply-To: <20171221210120.30166-1-jakub.kicinski@netronome.com>
Print the just-exposed device information about device to which
program is bound.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
---
tools/bpf/bpftool/common.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++
tools/bpf/bpftool/main.h | 2 ++
tools/bpf/bpftool/prog.c | 3 +++
3 files changed, 57 insertions(+)
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index b62c94e3997a..6601c95a9258 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -44,7 +44,9 @@
#include <unistd.h>
#include <linux/limits.h>
#include <linux/magic.h>
+#include <net/if.h>
#include <sys/mount.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include <sys/vfs.h>
@@ -412,3 +414,53 @@ void delete_pinned_obj_table(struct pinned_obj_table *tab)
free(obj);
}
}
+
+static char *
+ifindex_to_name_ns(__u32 ifindex, __u32 ns_dev, __u32 ns_ino, char *buf)
+{
+ struct stat st;
+ int err;
+
+ err = stat("/proc/self/ns/net", &st);
+ if (err) {
+ p_err("Can't stat /proc/self: %s", strerror(errno));
+ return NULL;
+ }
+
+ if (st.st_dev != ns_dev || st.st_ino != ns_ino)
+ return NULL;
+
+ return if_indextoname(ifindex, buf);
+}
+
+void print_dev_plain(__u32 ifindex, __u64 ns_dev, __u64 ns_inode)
+{
+ char name[IF_NAMESIZE];
+
+ if (!ifindex)
+ return;
+
+ printf(" dev ");
+ if (ifindex_to_name_ns(ifindex, ns_dev, ns_inode, name))
+ printf("%s", name);
+ else
+ printf("ifindex %u ns_dev %llu ns_ino %llu",
+ ifindex, ns_dev, ns_inode);
+}
+
+void print_dev_json(__u32 ifindex, __u64 ns_dev, __u64 ns_inode)
+{
+ char name[IF_NAMESIZE];
+
+ if (!ifindex)
+ return;
+
+ jsonw_name(json_wtr, "dev");
+ jsonw_start_object(json_wtr);
+ jsonw_uint_field(json_wtr, "ifindex", ifindex);
+ jsonw_uint_field(json_wtr, "ns_dev", ns_dev);
+ jsonw_uint_field(json_wtr, "ns_inode", ns_inode);
+ if (ifindex_to_name_ns(ifindex, ns_dev, ns_inode, name))
+ jsonw_string_field(json_wtr, "ifname", name);
+ jsonw_end_object(json_wtr);
+}
diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h
index 8f6d3cac0347..65b526fe6e7e 100644
--- a/tools/bpf/bpftool/main.h
+++ b/tools/bpf/bpftool/main.h
@@ -96,6 +96,8 @@ struct pinned_obj {
int build_pinned_obj_table(struct pinned_obj_table *table,
enum bpf_obj_type type);
void delete_pinned_obj_table(struct pinned_obj_table *tab);
+void print_dev_plain(__u32 ifindex, __u64 ns_dev, __u64 ns_inode);
+void print_dev_json(__u32 ifindex, __u64 ns_dev, __u64 ns_inode);
struct cmd {
const char *cmd;
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 037484ceaeaf..4ccf6301f0fe 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -230,6 +230,8 @@ static void print_prog_json(struct bpf_prog_info *info, int fd)
info->tag[0], info->tag[1], info->tag[2], info->tag[3],
info->tag[4], info->tag[5], info->tag[6], info->tag[7]);
+ print_dev_json(info->ifindex, info->netns_dev, info->netns_ino);
+
if (info->load_time) {
char buf[32];
@@ -287,6 +289,7 @@ static void print_prog_plain(struct bpf_prog_info *info, int fd)
printf("tag ");
fprint_hex(stdout, info->tag, BPF_TAG_SIZE, "");
+ print_dev_plain(info->ifindex, info->netns_dev, info->netns_ino);
printf("\n");
if (info->load_time) {
--
2.15.1
^ permalink raw reply related
* [PATCH bpf-next v2 5/8] bpf: offload: free program id when device disappears
From: Jakub Kicinski @ 2017-12-21 21:01 UTC (permalink / raw)
To: netdev, alexei.starovoitov, daniel; +Cc: ktkhai, oss-drivers, Jakub Kicinski
In-Reply-To: <20171221210120.30166-1-jakub.kicinski@netronome.com>
Bound programs are quite useless after their device disappears.
They are simply waiting for reference count to go to zero,
don't list them in BPF_PROG_GET_NEXT_ID by freeing their ID
early.
Note that orphaned offload programs will return -ENODEV on
BPF_OBJ_GET_INFO_BY_FD so user will never see ID 0.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
include/linux/bpf.h | 2 ++
kernel/bpf/offload.c | 3 +++
kernel/bpf/syscall.c | 9 +++++++--
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 669549f7e3e8..9a916ab34299 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -357,6 +357,8 @@ void bpf_prog_put(struct bpf_prog *prog);
int __bpf_prog_charge(struct user_struct *user, u32 pages);
void __bpf_prog_uncharge(struct user_struct *user, u32 pages);
+void bpf_prog_free_id(struct bpf_prog *prog, bool do_idr_lock);
+
struct bpf_map *bpf_map_get_with_uref(u32 ufd);
struct bpf_map *__bpf_map_get(struct fd f);
struct bpf_map * __must_check bpf_map_inc(struct bpf_map *map, bool uref);
diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c
index 60be15b9d8f1..1e6064ea3609 100644
--- a/kernel/bpf/offload.c
+++ b/kernel/bpf/offload.c
@@ -135,6 +135,9 @@ static void __bpf_prog_offload_destroy(struct bpf_prog *prog)
if (offload->dev_state)
WARN_ON(__bpf_offload_ndo(prog, BPF_OFFLOAD_DESTROY, &data));
+ /* Make sure BPF_PROG_GET_NEXT_ID can't find this dead program */
+ bpf_prog_free_id(prog, true);
+
list_del_init(&offload->offloads);
kfree(offload);
prog->aux->offload = NULL;
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 1143db61584c..7d9f5b0f0e49 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -905,9 +905,13 @@ static int bpf_prog_alloc_id(struct bpf_prog *prog)
return id > 0 ? 0 : id;
}
-static void bpf_prog_free_id(struct bpf_prog *prog, bool do_idr_lock)
+void bpf_prog_free_id(struct bpf_prog *prog, bool do_idr_lock)
{
- /* cBPF to eBPF migrations are currently not in the idr store. */
+ /* cBPF to eBPF migrations are currently not in the idr store.
+ * Offloaded programs are removed from the store when their device
+ * disappears - even if someone grabs an fd to them they are unusable,
+ * simply waiting for refcnt to drop to be freed.
+ */
if (!prog->aux->id)
return;
@@ -917,6 +921,7 @@ static void bpf_prog_free_id(struct bpf_prog *prog, bool do_idr_lock)
__acquire(&prog_idr_lock);
idr_remove(&prog_idr, prog->aux->id);
+ prog->aux->id = 0;
if (do_idr_lock)
spin_unlock_bh(&prog_idr_lock);
--
2.15.1
^ permalink raw reply related
* [PATCH bpf-next v2 6/8] bpf: offload: report device information for offloaded programs
From: Jakub Kicinski @ 2017-12-21 21:01 UTC (permalink / raw)
To: netdev, alexei.starovoitov, daniel
Cc: ktkhai, oss-drivers, Jakub Kicinski, Eric W . Biederman
In-Reply-To: <20171221210120.30166-1-jakub.kicinski@netronome.com>
Report to the user ifindex and namespace information of offloaded
programs. If device has disappeared return -ENODEV. Specify the
namespace using dev/inode combination.
CC: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
---
v2:
- take RTNL lock to grab a coherent snapshot of device state
(ifindex vs name space) and avoid races with name space
moves (based on Eric's comment on Kirill's patch to
peernet2id_alloc()).
---
fs/nsfs.c | 2 +-
include/linux/bpf.h | 2 ++
include/linux/proc_ns.h | 1 +
include/uapi/linux/bpf.h | 3 +++
kernel/bpf/offload.c | 44 ++++++++++++++++++++++++++++++++++++++++++
kernel/bpf/syscall.c | 6 ++++++
tools/include/uapi/linux/bpf.h | 3 +++
7 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/fs/nsfs.c b/fs/nsfs.c
index 7c6f76d29f56..e50628675935 100644
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -51,7 +51,7 @@ static void nsfs_evict(struct inode *inode)
ns->ops->put(ns);
}
-static void *__ns_get_path(struct path *path, struct ns_common *ns)
+void *__ns_get_path(struct path *path, struct ns_common *ns)
{
struct vfsmount *mnt = nsfs_mnt;
struct dentry *dentry;
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 9a916ab34299..7810ae57b357 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -531,6 +531,8 @@ static inline struct bpf_prog *bpf_prog_get_type(u32 ufd,
int bpf_prog_offload_compile(struct bpf_prog *prog);
void bpf_prog_offload_destroy(struct bpf_prog *prog);
+int bpf_prog_offload_info_fill(struct bpf_prog_info *info,
+ struct bpf_prog *prog);
#if defined(CONFIG_NET) && defined(CONFIG_BPF_SYSCALL)
int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr);
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
index 2ff18c9840a7..1733359cf713 100644
--- a/include/linux/proc_ns.h
+++ b/include/linux/proc_ns.h
@@ -76,6 +76,7 @@ static inline int ns_alloc_inum(struct ns_common *ns)
extern struct file *proc_ns_fget(int fd);
#define get_proc_ns(inode) ((struct ns_common *)(inode)->i_private)
+extern void *__ns_get_path(struct path *path, struct ns_common *ns);
extern void *ns_get_path(struct path *path, struct task_struct *task,
const struct proc_ns_operations *ns_ops);
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index d01f1cb3cfc0..72b37fc3bc0c 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -921,6 +921,9 @@ struct bpf_prog_info {
__u32 nr_map_ids;
__aligned_u64 map_ids;
char name[BPF_OBJ_NAME_LEN];
+ __u32 ifindex;
+ __u64 netns_dev;
+ __u64 netns_ino;
} __attribute__((aligned(8)));
struct bpf_map_info {
diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c
index 1e6064ea3609..4d50000bd1e3 100644
--- a/kernel/bpf/offload.c
+++ b/kernel/bpf/offload.c
@@ -16,9 +16,11 @@
#include <linux/bpf.h>
#include <linux/bpf_verifier.h>
#include <linux/bug.h>
+#include <linux/kdev_t.h>
#include <linux/list.h>
#include <linux/netdevice.h>
#include <linux/printk.h>
+#include <linux/proc_ns.h>
#include <linux/rtnetlink.h>
#include <linux/rwsem.h>
@@ -181,6 +183,48 @@ int bpf_prog_offload_compile(struct bpf_prog *prog)
return bpf_prog_offload_translate(prog);
}
+int bpf_prog_offload_info_fill(struct bpf_prog_info *info,
+ struct bpf_prog *prog)
+{
+ struct bpf_dev_offload *offload;
+ struct inode *ns_inode;
+ struct path ns_path;
+ int ifindex, err;
+ struct net *net;
+
+again:
+ rtnl_lock();
+ down_read(&bpf_devs_lock);
+
+ offload = prog->aux->offload;
+ if (!offload) {
+ up_read(&bpf_devs_lock);
+ rtnl_unlock();
+ return -ENODEV;
+ }
+
+ ifindex = offload->netdev->ifindex;
+ net = dev_net(offload->netdev);
+ get_net(net); /* __ns_get_path() drops the reference */
+
+ up_read(&bpf_devs_lock);
+ rtnl_unlock();
+
+ err = PTR_ERR_OR_ZERO(__ns_get_path(&ns_path, &net->ns));
+ if (err) {
+ if (err == -EAGAIN)
+ goto again;
+ return err;
+ }
+ ns_inode = ns_path.dentry->d_inode;
+
+ info->ifindex = ifindex;
+ info->netns_dev = new_encode_dev(ns_inode->i_sb->s_dev);
+ info->netns_ino = ns_inode->i_ino;
+
+ return 0;
+}
+
const struct bpf_prog_ops bpf_offload_prog_ops = {
};
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 7d9f5b0f0e49..20444fd678d0 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1624,6 +1624,12 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
return -EFAULT;
}
+ if (bpf_prog_is_dev_bound(prog->aux)) {
+ err = bpf_prog_offload_info_fill(&info, prog);
+ if (err)
+ return err;
+ }
+
done:
if (copy_to_user(uinfo, &info, info_len) ||
put_user(info_len, &uattr->info.info_len))
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index db1b0923a308..4e8c60acfa32 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -921,6 +921,9 @@ struct bpf_prog_info {
__u32 nr_map_ids;
__aligned_u64 map_ids;
char name[BPF_OBJ_NAME_LEN];
+ __u32 ifindex;
+ __u64 netns_dev;
+ __u64 netns_ino;
} __attribute__((aligned(8)));
struct bpf_map_info {
--
2.15.1
^ permalink raw reply related
* [PATCH bpf-next v2 4/8] bpf: offload: free prog->aux->offload when device disappears
From: Jakub Kicinski @ 2017-12-21 21:01 UTC (permalink / raw)
To: netdev, alexei.starovoitov, daniel; +Cc: ktkhai, oss-drivers, Jakub Kicinski
In-Reply-To: <20171221210120.30166-1-jakub.kicinski@netronome.com>
All bpf offload operations should now be under bpf_devs_lock,
it's safe to free and clear the entire offload structure,
not only the netdev pointer.
__bpf_prog_offload_destroy() will no longer be called multiple
times.
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
kernel/bpf/offload.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c
index 2f2184408d31..60be15b9d8f1 100644
--- a/kernel/bpf/offload.c
+++ b/kernel/bpf/offload.c
@@ -75,12 +75,14 @@ int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr)
static int __bpf_offload_ndo(struct bpf_prog *prog, enum bpf_netdev_command cmd,
struct netdev_bpf *data)
{
- struct net_device *netdev = prog->aux->offload->netdev;
+ struct bpf_dev_offload *offload = prog->aux->offload;
+ struct net_device *netdev;
ASSERT_RTNL();
- if (!netdev)
+ if (!offload)
return -ENODEV;
+ netdev = offload->netdev;
if (!netdev->netdev_ops->ndo_bpf)
return -EOPNOTSUPP;
@@ -116,7 +118,7 @@ int bpf_prog_offload_verify_insn(struct bpf_verifier_env *env,
down_read(&bpf_devs_lock);
offload = env->prog->aux->offload;
- if (offload->netdev)
+ if (offload)
ret = offload->dev_ops->insn_hook(env, insn_idx, prev_insn_idx);
up_read(&bpf_devs_lock);
@@ -128,31 +130,24 @@ static void __bpf_prog_offload_destroy(struct bpf_prog *prog)
struct bpf_dev_offload *offload = prog->aux->offload;
struct netdev_bpf data = {};
- /* Caution - if netdev is destroyed before the program, this function
- * will be called twice.
- */
-
data.offload.prog = prog;
if (offload->dev_state)
WARN_ON(__bpf_offload_ndo(prog, BPF_OFFLOAD_DESTROY, &data));
- offload->dev_state = false;
list_del_init(&offload->offloads);
- offload->netdev = NULL;
+ kfree(offload);
+ prog->aux->offload = NULL;
}
void bpf_prog_offload_destroy(struct bpf_prog *prog)
{
- struct bpf_dev_offload *offload = prog->aux->offload;
-
rtnl_lock();
down_write(&bpf_devs_lock);
- __bpf_prog_offload_destroy(prog);
+ if (prog->aux->offload)
+ __bpf_prog_offload_destroy(prog);
up_write(&bpf_devs_lock);
rtnl_unlock();
-
- kfree(offload);
}
static int bpf_prog_offload_translate(struct bpf_prog *prog)
--
2.15.1
^ permalink raw reply related
* [PATCH bpf-next v2 3/8] bpf: offload: allow netdev to disappear while verifier is running
From: Jakub Kicinski @ 2017-12-21 21:01 UTC (permalink / raw)
To: netdev, alexei.starovoitov, daniel; +Cc: ktkhai, oss-drivers, Jakub Kicinski
In-Reply-To: <20171221210120.30166-1-jakub.kicinski@netronome.com>
To allow verifier instruction callbacks without any extra locking
NETDEV_UNREGISTER notification would wait on a waitqueue for verifier
to finish. This design decision was made when rtnl lock was providing
all the locking. Use the read/write lock instead and remove the
workqueue.
Verifier will now call into the offload code, so dev_ops are moved
to offload structure. Since verifier calls are all under
bpf_prog_is_dev_bound() we no longer need static inline implementations
to please builds with CONFIG_NET=n.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
drivers/net/ethernet/netronome/nfp/bpf/main.h | 2 +-
drivers/net/ethernet/netronome/nfp/bpf/verifier.c | 2 +-
drivers/net/netdevsim/bpf.c | 2 +-
include/linux/bpf.h | 9 +++++--
include/linux/bpf_verifier.h | 16 ++----------
include/linux/netdevice.h | 4 +--
kernel/bpf/offload.c | 30 ++++++++++++-----------
kernel/bpf/verifier.c | 20 ++++++---------
8 files changed, 37 insertions(+), 48 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/bpf/main.h b/drivers/net/ethernet/netronome/nfp/bpf/main.h
index aae1be9ed056..89a9b6393882 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/main.h
+++ b/drivers/net/ethernet/netronome/nfp/bpf/main.h
@@ -238,7 +238,7 @@ struct nfp_bpf_vnic {
int nfp_bpf_jit(struct nfp_prog *prog);
-extern const struct bpf_ext_analyzer_ops nfp_bpf_analyzer_ops;
+extern const struct bpf_prog_offload_ops nfp_bpf_analyzer_ops;
struct netdev_bpf;
struct nfp_app;
diff --git a/drivers/net/ethernet/netronome/nfp/bpf/verifier.c b/drivers/net/ethernet/netronome/nfp/bpf/verifier.c
index 9c2608445bd8..d8870c2f11f3 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/verifier.c
+++ b/drivers/net/ethernet/netronome/nfp/bpf/verifier.c
@@ -260,6 +260,6 @@ nfp_verify_insn(struct bpf_verifier_env *env, int insn_idx, int prev_insn_idx)
return 0;
}
-const struct bpf_ext_analyzer_ops nfp_bpf_analyzer_ops = {
+const struct bpf_prog_offload_ops nfp_bpf_analyzer_ops = {
.insn_hook = nfp_verify_insn,
};
diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c
index a243fa7ae02f..5134d5c1306c 100644
--- a/drivers/net/netdevsim/bpf.c
+++ b/drivers/net/netdevsim/bpf.c
@@ -66,7 +66,7 @@ nsim_bpf_verify_insn(struct bpf_verifier_env *env, int insn_idx, int prev_insn)
return 0;
}
-static const struct bpf_ext_analyzer_ops nsim_bpf_analyzer_ops = {
+static const struct bpf_prog_offload_ops nsim_bpf_analyzer_ops = {
.insn_hook = nsim_bpf_verify_insn,
};
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 838eee10e979..669549f7e3e8 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -17,6 +17,7 @@
#include <linux/numa.h>
#include <linux/wait.h>
+struct bpf_verifier_env;
struct perf_event;
struct bpf_prog;
struct bpf_map;
@@ -184,14 +185,18 @@ struct bpf_verifier_ops {
struct bpf_prog *prog, u32 *target_size);
};
+struct bpf_prog_offload_ops {
+ int (*insn_hook)(struct bpf_verifier_env *env,
+ int insn_idx, int prev_insn_idx);
+};
+
struct bpf_dev_offload {
struct bpf_prog *prog;
struct net_device *netdev;
void *dev_priv;
struct list_head offloads;
bool dev_state;
- bool verifier_running;
- wait_queue_head_t verifier_done;
+ const struct bpf_prog_offload_ops *dev_ops;
};
struct bpf_prog_aux {
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index aaac589e490c..02ede122d35b 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -166,12 +166,6 @@ static inline bool bpf_verifier_log_full(const struct bpf_verifer_log *log)
return log->len_used >= log->len_total - 1;
}
-struct bpf_verifier_env;
-struct bpf_ext_analyzer_ops {
- int (*insn_hook)(struct bpf_verifier_env *env,
- int insn_idx, int prev_insn_idx);
-};
-
#define BPF_MAX_SUBPROGS 256
/* single container for all structs
@@ -185,7 +179,6 @@ struct bpf_verifier_env {
bool strict_alignment; /* perform strict pointer alignment checks */
struct bpf_verifier_state *cur_state; /* current verifier state */
struct bpf_verifier_state_list **explored_states; /* search pruning optimization */
- const struct bpf_ext_analyzer_ops *dev_ops; /* device analyzer ops */
struct bpf_map *used_maps[MAX_USED_MAPS]; /* array of map's used by eBPF program */
u32 used_map_cnt; /* number of used maps */
u32 id_gen; /* used to generate unique reg IDs */
@@ -205,13 +198,8 @@ static inline struct bpf_reg_state *cur_regs(struct bpf_verifier_env *env)
return cur->frame[cur->curframe]->regs;
}
-#if defined(CONFIG_NET) && defined(CONFIG_BPF_SYSCALL)
int bpf_prog_offload_verifier_prep(struct bpf_verifier_env *env);
-#else
-static inline int bpf_prog_offload_verifier_prep(struct bpf_verifier_env *env)
-{
- return -EOPNOTSUPP;
-}
-#endif
+int bpf_prog_offload_verify_insn(struct bpf_verifier_env *env,
+ int insn_idx, int prev_insn_idx);
#endif /* _LINUX_BPF_VERIFIER_H */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index cc4ce7456e38..0a1a4a111546 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -804,7 +804,7 @@ enum bpf_netdev_command {
BPF_OFFLOAD_DESTROY,
};
-struct bpf_ext_analyzer_ops;
+struct bpf_prog_offload_ops;
struct netlink_ext_ack;
struct netdev_bpf {
@@ -826,7 +826,7 @@ struct netdev_bpf {
/* BPF_OFFLOAD_VERIFIER_PREP */
struct {
struct bpf_prog *prog;
- const struct bpf_ext_analyzer_ops *ops; /* callee set */
+ const struct bpf_prog_offload_ops *ops; /* callee set */
} verifier;
/* BPF_OFFLOAD_TRANSLATE, BPF_OFFLOAD_DESTROY */
struct {
diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c
index f049073a37e6..2f2184408d31 100644
--- a/kernel/bpf/offload.c
+++ b/kernel/bpf/offload.c
@@ -45,7 +45,6 @@ int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr)
return -ENOMEM;
offload->prog = prog;
- init_waitqueue_head(&offload->verifier_done);
rcu_read_lock();
offload->netdev = dev_get_by_index_rcu(net, attr->prog_ifindex);
@@ -102,15 +101,28 @@ int bpf_prog_offload_verifier_prep(struct bpf_verifier_env *env)
if (err)
goto exit_unlock;
- env->dev_ops = data.verifier.ops;
-
+ env->prog->aux->offload->dev_ops = data.verifier.ops;
env->prog->aux->offload->dev_state = true;
- env->prog->aux->offload->verifier_running = true;
exit_unlock:
rtnl_unlock();
return err;
}
+int bpf_prog_offload_verify_insn(struct bpf_verifier_env *env,
+ int insn_idx, int prev_insn_idx)
+{
+ struct bpf_dev_offload *offload;
+ int ret = -ENODEV;
+
+ down_read(&bpf_devs_lock);
+ offload = env->prog->aux->offload;
+ if (offload->netdev)
+ ret = offload->dev_ops->insn_hook(env, insn_idx, prev_insn_idx);
+ up_read(&bpf_devs_lock);
+
+ return ret;
+}
+
static void __bpf_prog_offload_destroy(struct bpf_prog *prog)
{
struct bpf_dev_offload *offload = prog->aux->offload;
@@ -122,9 +134,6 @@ static void __bpf_prog_offload_destroy(struct bpf_prog *prog)
data.offload.prog = prog;
- if (offload->verifier_running)
- wait_event(offload->verifier_done, !offload->verifier_running);
-
if (offload->dev_state)
WARN_ON(__bpf_offload_ndo(prog, BPF_OFFLOAD_DESTROY, &data));
@@ -137,9 +146,6 @@ void bpf_prog_offload_destroy(struct bpf_prog *prog)
{
struct bpf_dev_offload *offload = prog->aux->offload;
- offload->verifier_running = false;
- wake_up(&offload->verifier_done);
-
rtnl_lock();
down_write(&bpf_devs_lock);
__bpf_prog_offload_destroy(prog);
@@ -151,15 +157,11 @@ void bpf_prog_offload_destroy(struct bpf_prog *prog)
static int bpf_prog_offload_translate(struct bpf_prog *prog)
{
- struct bpf_dev_offload *offload = prog->aux->offload;
struct netdev_bpf data = {};
int ret;
data.offload.prog = prog;
- offload->verifier_running = false;
- wake_up(&offload->verifier_done);
-
rtnl_lock();
ret = __bpf_offload_ndo(prog, BPF_OFFLOAD_TRANSLATE, &data);
rtnl_unlock();
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 48b2901cf483..6b95efad5828 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -4341,15 +4341,6 @@ static int is_state_visited(struct bpf_verifier_env *env, int insn_idx)
return 0;
}
-static int ext_analyzer_insn_hook(struct bpf_verifier_env *env,
- int insn_idx, int prev_insn_idx)
-{
- if (env->dev_ops && env->dev_ops->insn_hook)
- return env->dev_ops->insn_hook(env, insn_idx, prev_insn_idx);
-
- return 0;
-}
-
static int do_check(struct bpf_verifier_env *env)
{
struct bpf_verifier_state *state;
@@ -4431,9 +4422,12 @@ static int do_check(struct bpf_verifier_env *env)
env->allow_ptr_leaks);
}
- err = ext_analyzer_insn_hook(env, insn_idx, prev_insn_idx);
- if (err)
- return err;
+ if (bpf_prog_is_dev_bound(env->prog->aux)) {
+ err = bpf_prog_offload_verify_insn(env, insn_idx,
+ prev_insn_idx);
+ if (err)
+ return err;
+ }
regs = cur_regs(env);
env->insn_aux_data[insn_idx].seen = true;
@@ -5341,7 +5335,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr)
if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))
env->strict_alignment = true;
- if (env->prog->aux->offload) {
+ if (bpf_prog_is_dev_bound(env->prog->aux)) {
ret = bpf_prog_offload_verifier_prep(env);
if (ret)
goto err_unlock;
--
2.15.1
^ permalink raw reply related
* [PATCH bpf-next v2 2/8] bpf: offload: don't use prog->aux->offload as boolean
From: Jakub Kicinski @ 2017-12-21 21:01 UTC (permalink / raw)
To: netdev, alexei.starovoitov, daniel; +Cc: ktkhai, oss-drivers, Jakub Kicinski
In-Reply-To: <20171221210120.30166-1-jakub.kicinski@netronome.com>
We currently use aux->offload to indicate that program is bound
to a specific device. This forces us to keep the offload structure
around even after the device is gone. Add a bool member to
struct bpf_prog_aux to indicate if offload was requested.
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
include/linux/bpf.h | 3 ++-
kernel/bpf/syscall.c | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index da54ef644fcd..838eee10e979 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -201,6 +201,7 @@ struct bpf_prog_aux {
u32 stack_depth;
u32 id;
u32 func_cnt;
+ bool offload_requested;
struct bpf_prog **func;
void *jit_data; /* JIT specific data. arch dependent */
struct latch_tree_node ksym_tnode;
@@ -529,7 +530,7 @@ int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr);
static inline bool bpf_prog_is_dev_bound(struct bpf_prog_aux *aux)
{
- return aux->offload;
+ return aux->offload_requested;
}
#else
static inline int bpf_prog_offload_init(struct bpf_prog *prog,
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index e2e1c78ce1dc..1143db61584c 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1151,6 +1151,8 @@ static int bpf_prog_load(union bpf_attr *attr)
if (!prog)
return -ENOMEM;
+ prog->aux->offload_requested = !!attr->prog_ifindex;
+
err = security_bpf_prog_alloc(prog->aux);
if (err)
goto free_prog_nouncharge;
@@ -1172,7 +1174,7 @@ static int bpf_prog_load(union bpf_attr *attr)
atomic_set(&prog->aux->refcnt, 1);
prog->gpl_compatible = is_gpl ? 1 : 0;
- if (attr->prog_ifindex) {
+ if (bpf_prog_is_dev_bound(prog->aux)) {
err = bpf_prog_offload_init(prog, attr);
if (err)
goto free_prog;
--
2.15.1
^ permalink raw reply related
* [PATCH bpf-next v2 1/8] bpf: offload: don't require rtnl for dev list manipulation
From: Jakub Kicinski @ 2017-12-21 21:01 UTC (permalink / raw)
To: netdev, alexei.starovoitov, daniel; +Cc: ktkhai, oss-drivers, Jakub Kicinski
In-Reply-To: <20171221210120.30166-1-jakub.kicinski@netronome.com>
We don't need the RTNL lock for all operations on offload state.
We only need to hold it around ndo calls. The device offload
initialization doesn't require it. The soon-to-come querying
of the offload info will only need it partially. We will also
be able to remove the waitqueue in following patches.
Use struct rw_semaphore because map offload will require sleeping
with the semaphore held for read.
Suggested-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
---
v2:
- use dev_get_by_index_rcu() instead of implicit lock dependencies;
- use DECLARE_RWSEM() instead of init_rwsem() (Kirill).
---
kernel/bpf/offload.c | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c
index 8455b89d1bbf..f049073a37e6 100644
--- a/kernel/bpf/offload.c
+++ b/kernel/bpf/offload.c
@@ -20,8 +20,12 @@
#include <linux/netdevice.h>
#include <linux/printk.h>
#include <linux/rtnetlink.h>
+#include <linux/rwsem.h>
-/* protected by RTNL */
+/* Protects bpf_prog_offload_devs and offload members of all progs.
+ * RTNL lock cannot be taken when holding this lock.
+ */
+static DECLARE_RWSEM(bpf_devs_lock);
static LIST_HEAD(bpf_prog_offload_devs);
int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr)
@@ -43,19 +47,30 @@ int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr)
offload->prog = prog;
init_waitqueue_head(&offload->verifier_done);
- rtnl_lock();
- offload->netdev = __dev_get_by_index(net, attr->prog_ifindex);
+ rcu_read_lock();
+ offload->netdev = dev_get_by_index_rcu(net, attr->prog_ifindex);
if (!offload->netdev) {
- rtnl_unlock();
- kfree(offload);
- return -EINVAL;
+ rcu_read_unlock();
+ goto err_free;
}
+ dev_hold(offload->netdev);
+ rcu_read_unlock();
+ down_write(&bpf_devs_lock);
+ if (offload->netdev->reg_state != NETREG_REGISTERED)
+ goto err_unlock;
prog->aux->offload = offload;
list_add_tail(&offload->offloads, &bpf_prog_offload_devs);
- rtnl_unlock();
+ dev_put(offload->netdev);
+ up_write(&bpf_devs_lock);
return 0;
+err_unlock:
+ up_write(&bpf_devs_lock);
+ dev_put(offload->netdev);
+err_free:
+ kfree(offload);
+ return -EINVAL;
}
static int __bpf_offload_ndo(struct bpf_prog *prog, enum bpf_netdev_command cmd,
@@ -126,7 +141,9 @@ void bpf_prog_offload_destroy(struct bpf_prog *prog)
wake_up(&offload->verifier_done);
rtnl_lock();
+ down_write(&bpf_devs_lock);
__bpf_prog_offload_destroy(prog);
+ up_write(&bpf_devs_lock);
rtnl_unlock();
kfree(offload);
@@ -181,11 +198,13 @@ static int bpf_offload_notification(struct notifier_block *notifier,
if (netdev->reg_state != NETREG_UNREGISTERING)
break;
+ down_write(&bpf_devs_lock);
list_for_each_entry_safe(offload, tmp, &bpf_prog_offload_devs,
offloads) {
if (offload->netdev == netdev)
__bpf_prog_offload_destroy(offload->prog);
}
+ up_write(&bpf_devs_lock);
break;
default:
break;
--
2.15.1
^ permalink raw reply related
* [PATCH bpf-next v2 0/8] bpf: offload: report device back to user space (take 2)
From: Jakub Kicinski @ 2017-12-21 21:01 UTC (permalink / raw)
To: netdev, alexei.starovoitov, daniel; +Cc: ktkhai, oss-drivers, Jakub Kicinski
Hi!
This series is a redo of reporting offload device information to
user space after the first attempt did not take into account name
spaces. As requested by Kirill offloads are now protected by an
r/w sem. This allows us to remove the workqueue and free the
offload state fully when device is removed (suggested by Alexei).
Net namespace is reported with a device/inode pair.
The accompanying bpftool support is placed in common code because
maps will have very similar info. Note that the UAPI information
can't be nicely encapsulated into a struct, because in case we
need to grow the device information the new fields will have to
be added at the end of struct bpf_prog_info, we can't grow
structures in the middle of bpf_prog_info.
v2:
- rework the locking in patch 1 (use RCU instead of locking
dependencies);
- grab RTNL for a short time in patch 6;
- minor update to the test in patch 8.
Jakub Kicinski (8):
bpf: offload: don't require rtnl for dev list manipulation
bpf: offload: don't use prog->aux->offload as boolean
bpf: offload: allow netdev to disappear while verifier is running
bpf: offload: free prog->aux->offload when device disappears
bpf: offload: free program id when device disappears
bpf: offload: report device information for offloaded programs
tools: bpftool: report device information for offloaded programs
selftests/bpf: test device info reporting for bound progs
drivers/net/ethernet/netronome/nfp/bpf/main.h | 2 +-
drivers/net/ethernet/netronome/nfp/bpf/verifier.c | 2 +-
drivers/net/netdevsim/bpf.c | 2 +-
fs/nsfs.c | 2 +-
include/linux/bpf.h | 16 ++-
include/linux/bpf_verifier.h | 16 +--
include/linux/netdevice.h | 4 +-
include/linux/proc_ns.h | 1 +
include/uapi/linux/bpf.h | 3 +
kernel/bpf/offload.c | 133 ++++++++++++++++------
kernel/bpf/syscall.c | 19 +++-
kernel/bpf/verifier.c | 20 ++--
tools/bpf/bpftool/common.c | 52 +++++++++
tools/bpf/bpftool/main.h | 2 +
tools/bpf/bpftool/prog.c | 3 +
tools/include/uapi/linux/bpf.h | 3 +
tools/testing/selftests/bpf/test_offload.py | 112 ++++++++++++++++--
17 files changed, 308 insertions(+), 84 deletions(-)
--
2.15.1
^ permalink raw reply
* Re: [PATCH] net: Revert "net_sched: no need to free qdisc in RCU callback"
From: Cong Wang @ 2017-12-21 20:59 UTC (permalink / raw)
To: Jiri Pirko
Cc: John Fastabend, David Miller, Jakub Kicinski,
Linux Kernel Network Developers, Eric Dumazet
In-Reply-To: <20171221083908.GA1930@nanopsycho>
On Thu, Dec 21, 2017 at 12:39 AM, Jiri Pirko <jiri@resnulli.us> wrote:
>
> Why just moving qdisc_free to rcu is not enough? It would resolve this
> issue and also avoid using synchronize net. Something like:
If you mean Jakub's issue, apparently not:
https://www.kernel.org/pub/linux/kernel/people/paulmck/Answers/RCU/RCUCBordering.html
Jiri, you have to use a rcu barrier to wait for a rcu callback, not
queuing another rcu callback, the ordering is simply NOT guaranteed.
What's more importantly, you already have one rcu barrier in the
same function. Why keep believing you don't need it?
^ permalink raw reply
* Re: [Patch net] net_sched: fix a missing rcu barrier in mini_qdisc_pair_swap()
From: Cong Wang @ 2017-12-21 20:54 UTC (permalink / raw)
To: Jiri Pirko; +Cc: Linux Kernel Network Developers, Jiri Pirko, John Fastabend
In-Reply-To: <CAM_iQpVfYUsJ6D5fpE+Ng8wGxK6uoN3PRntYO_Y0j+7YRKdSqg@mail.gmail.com>
On Thu, Dec 21, 2017 at 11:01 AM, Cong Wang <xiyou.wangcong@gmail.com> wrote:
> On Thu, Dec 21, 2017 at 1:03 AM, Jiri Pirko <jiri@resnulli.us> wrote:
>>
>>
>> But again, we don't we just free qdisc in call_rcu and avoid the
>> barrier?
>
>
> Non-sense again. Why qdisc code should be adjusted for your
> miniq code? It is your own responsibility to take care of this shit.
> Don't spread it out of minq.
Also, in case you believe call_rcu to free qdisc is queued after
the call_rcu in miniq, you are wrong again:
https://www.kernel.org/pub/linux/kernel/people/paulmck/Answers/RCU/RCUCBordering.html
The rcu callbacks don't guarantee FIFO ordering.
^ permalink raw reply
* [PATCH RFC 18/18] r8168: use link speed information as maintained by phylib
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
Let's use the speed information as maintained by phylib instead of
reading it directly from a register.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8168.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index 765c60bc1..6c57af825 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -618,16 +618,6 @@ enum rtl_register_content {
INTT_2 = 0x0002, // 8168
INTT_3 = 0x0003, // 8168
- /* rtl8168_PHYstatus */
- TBI_Enable = 0x80,
- TxFlowCtrl = 0x40,
- RxFlowCtrl = 0x20,
- _1000bpsF = 0x10,
- _100bps = 0x08,
- _10bps = 0x04,
- LinkStatus = 0x02,
- FullDup = 0x01,
-
/* ResetCounterCommand */
CounterReset = 0x1,
@@ -1544,20 +1534,20 @@ static void rtl8168_irq_mask_and_ack(struct rtl8168_private *tp)
static void rtl_link_chg_patch(struct rtl8168_private *tp)
{
- void __iomem *ioaddr = tp->mmio_addr;
struct net_device *dev = tp->dev;
+ struct phy_device *phydev = dev->phydev;
if (!netif_running(dev))
return;
if (tp->mac_version == RTL_GIGA_MAC_VER_34 ||
tp->mac_version == RTL_GIGA_MAC_VER_38) {
- if (RTL_R8(PHYstatus) & _1000bpsF) {
+ if (phydev->speed == SPEED_1000) {
rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x00000011,
ERIAR_EXGMAC);
rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005,
ERIAR_EXGMAC);
- } else if (RTL_R8(PHYstatus) & _100bps) {
+ } else if (phydev->speed == SPEED_100) {
rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x0000001f,
ERIAR_EXGMAC);
rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005,
@@ -1575,7 +1565,7 @@ static void rtl_link_chg_patch(struct rtl8168_private *tp)
ERIAR_EXGMAC);
} else if (tp->mac_version == RTL_GIGA_MAC_VER_35 ||
tp->mac_version == RTL_GIGA_MAC_VER_36) {
- if (RTL_R8(PHYstatus) & _1000bpsF) {
+ if (phydev->speed == SPEED_1000) {
rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x00000011,
ERIAR_EXGMAC);
rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005,
@@ -1587,7 +1577,7 @@ static void rtl_link_chg_patch(struct rtl8168_private *tp)
ERIAR_EXGMAC);
}
} else if (tp->mac_version == RTL_GIGA_MAC_VER_37) {
- if (RTL_R8(PHYstatus) & _10bps) {
+ if (phydev->speed == SPEED_10) {
rtl_eri_write(tp, 0x1d0, ERIAR_MASK_0011, 0x4d02,
ERIAR_EXGMAC);
rtl_eri_write(tp, 0x1dc, ERIAR_MASK_0011, 0x0060,
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 17/18] r8168: remove use of struct mii_if_info
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
After switching to phylib we don't need most elements of
struct mii_if_info any longer.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8168.c | 37 +++++++-----------------------------
1 file changed, 7 insertions(+), 30 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index 64c87509d..765c60bc1 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -816,7 +816,7 @@ struct rtl8168_private {
unsigned features;
- struct mii_if_info mii;
+ bool supports_gmii;
struct mii_bus *mii_bus;
dma_addr_t counters_phys_addr;
struct rtl8168_counters *counters;
@@ -1188,21 +1188,6 @@ static void rtl_w0w1_phy(struct rtl8168_private *tp, int reg_addr, int p, int m)
rtl_writephy(tp, reg_addr, (val & ~m) | p);
}
-static void rtl_mdio_write(struct net_device *dev, int phy_id, int location,
- int val)
-{
- struct rtl8168_private *tp = netdev_priv(dev);
-
- rtl_writephy(tp, location, val);
-}
-
-static int rtl_mdio_read(struct net_device *dev, int phy_id, int location)
-{
- struct rtl8168_private *tp = netdev_priv(dev);
-
- return rtl_readphy(tp, location);
-}
-
DECLARE_RTL_COND(rtl_ephyar_cond)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -2447,15 +2432,15 @@ static void rtl8168_get_mac_version(struct rtl8168_private *tp,
"unknown MAC, using family default\n");
tp->mac_version = default_version;
} else if (tp->mac_version == RTL_GIGA_MAC_VER_42) {
- tp->mac_version = tp->mii.supports_gmii ?
+ tp->mac_version = tp->supports_gmii ?
RTL_GIGA_MAC_VER_42 :
RTL_GIGA_MAC_VER_43;
} else if (tp->mac_version == RTL_GIGA_MAC_VER_45) {
- tp->mac_version = tp->mii.supports_gmii ?
+ tp->mac_version = tp->supports_gmii ?
RTL_GIGA_MAC_VER_45 :
RTL_GIGA_MAC_VER_47;
} else if (tp->mac_version == RTL_GIGA_MAC_VER_46) {
- tp->mac_version = tp->mii.supports_gmii ?
+ tp->mac_version = tp->supports_gmii ?
RTL_GIGA_MAC_VER_46 :
RTL_GIGA_MAC_VER_48;
}
@@ -7691,7 +7676,7 @@ static int r8168_phy_connect(struct rtl8168_private *tp)
phy_interface_t phy_mode;
int ret;
- phy_mode = tp->mii.supports_gmii ? PHY_INTERFACE_MODE_GMII :
+ phy_mode = tp->supports_gmii ? PHY_INTERFACE_MODE_GMII :
PHY_INTERFACE_MODE_MII;
phydev = phy_find_first(tp->mii_bus);
@@ -7705,7 +7690,7 @@ static int r8168_phy_connect(struct rtl8168_private *tp)
phy_attached_info(phydev);
- if (!tp->mii.supports_gmii && (phydev->supported &
+ if (!tp->supports_gmii && (phydev->supported &
(SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full))) {
netif_info(tp, probe, tp->dev, "Restrict PHY to 100Mbit because MAC doesn't support 1GBit");
phy_set_max_speed(phydev, SPEED_100);
@@ -7784,7 +7769,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data;
const unsigned int region = cfg->region;
struct rtl8168_private *tp;
- struct mii_if_info *mii;
struct net_device *dev;
void __iomem *ioaddr;
int chipset, i;
@@ -7805,14 +7789,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->dev = dev;
tp->pci_dev = pdev;
tp->msg_enable = netif_msg_init(debug.msg_enable, R8168_MSG_DEFAULT);
-
- mii = &tp->mii;
- mii->dev = dev;
- mii->mdio_read = rtl_mdio_read;
- mii->mdio_write = rtl_mdio_write;
- mii->phy_id_mask = 0x1f;
- mii->reg_num_mask = 0x1f;
- mii->supports_gmii = !!(cfg->features & RTL_FEATURE_GMII);
+ tp->supports_gmii = !!(cfg->features & RTL_FEATURE_GMII);
/* disable ASPM completely as that cause random device stop working
* problems as well as full system hangs for some PCIe devices users */
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 16/18] r8168: use phy_read/write in rtl_readphy/writephy helpers
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
Instead of accessing mdio_ops directly use phy_read/write in these
helpers.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8168.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index 91191d178..64c87509d 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -1167,12 +1167,12 @@ static int r8168dp_2_mdio_read(struct rtl8168_private *tp, int reg)
static void rtl_writephy(struct rtl8168_private *tp, int location, u32 val)
{
- tp->mdio_ops.write(tp, location, val);
+ phy_write(tp->dev->phydev, location, val);
}
static int rtl_readphy(struct rtl8168_private *tp, int location)
{
- return tp->mdio_ops.read(tp, location);
+ return phy_read(tp->dev->phydev, location);
}
static void rtl_patchphy(struct rtl8168_private *tp, int reg_addr, int value)
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 15/18] r8168: remove rtl_phy_work and rtl8168_phy_timer
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
Remove further code which is replaced by phylib.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8168.c | 60 ------------------------------------
1 file changed, 60 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index f88fc0fa0..91191d178 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -752,7 +752,6 @@ enum rtl_flag {
RTL_FLAG_TASK_ENABLED,
RTL_FLAG_TASK_SLOW_PENDING,
RTL_FLAG_TASK_RESET_PENDING,
- RTL_FLAG_TASK_PHY_PENDING,
RTL_FLAG_MAX
};
@@ -781,7 +780,6 @@ struct rtl8168_private {
dma_addr_t RxPhyAddr;
void *Rx_databuff[NUM_RX_DESC]; /* Rx data buffers */
struct ring_info tx_skb[NUM_TX_DESC]; /* Tx data buffers */
- struct timer_list timer;
u16 cp_cmd;
u16 event_slow;
@@ -1559,24 +1557,6 @@ static void rtl8168_irq_mask_and_ack(struct rtl8168_private *tp)
RTL_R8(ChipCmd);
}
-static unsigned int rtl8168_xmii_reset_pending(struct rtl8168_private *tp)
-{
- return rtl_readphy(tp, MII_BMCR) & BMCR_RESET;
-}
-
-static unsigned int rtl8168_xmii_link_ok(void __iomem *ioaddr)
-{
- return RTL_R8(PHYstatus) & LinkStatus;
-}
-
-static void rtl8168_xmii_reset_enable(struct rtl8168_private *tp)
-{
- unsigned int val;
-
- val = rtl_readphy(tp, MII_BMCR) | BMCR_RESET;
- rtl_writephy(tp, MII_BMCR, val & 0xffff);
-}
-
static void rtl_link_chg_patch(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4131,47 +4111,12 @@ static void rtl_hw_phy_config(struct net_device *dev)
}
}
-static void rtl_phy_work(struct rtl8168_private *tp)
-{
- struct timer_list *timer = &tp->timer;
- void __iomem *ioaddr = tp->mmio_addr;
- unsigned long timeout = RTL8168_PHY_TIMEOUT;
-
- assert(tp->mac_version > RTL_GIGA_MAC_VER_01);
-
- if (rtl8168_xmii_reset_pending(tp)) {
- /*
- * A busy loop could burn quite a few cycles on nowadays CPU.
- * Let's delay the execution of the timer for a few ticks.
- */
- timeout = HZ/10;
- goto out_mod_timer;
- }
-
- if (rtl8168_xmii_link_ok(ioaddr))
- return;
-
- netif_dbg(tp, link, tp->dev, "PHY reset until link up\n");
-
- rtl8168_xmii_reset_enable(tp);
-
-out_mod_timer:
- mod_timer(timer, jiffies + timeout);
-}
-
static void rtl_schedule_task(struct rtl8168_private *tp, enum rtl_flag flag)
{
if (!test_and_set_bit(flag, tp->wk.flags))
schedule_work(&tp->wk.work);
}
-static void rtl8168_phy_timer(struct timer_list *t)
-{
- struct rtl8168_private *tp = from_timer(tp, t, timer);
-
- rtl_schedule_task(tp, RTL_FLAG_TASK_PHY_PENDING);
-}
-
static void rtl8168_init_phy(struct net_device *dev, struct rtl8168_private *tp)
{
rtl_hw_phy_config(dev);
@@ -7120,7 +7065,6 @@ static void rtl_task(struct work_struct *work)
/* XXX - keep rtl_slow_event_work() as first element. */
{ RTL_FLAG_TASK_SLOW_PENDING, rtl_slow_event_work },
{ RTL_FLAG_TASK_RESET_PENDING, rtl_reset_work },
- { RTL_FLAG_TASK_PHY_PENDING, rtl_phy_work }
};
struct rtl8168_private *tp =
container_of(work, struct rtl8168_private, wk.work);
@@ -7184,8 +7128,6 @@ static void rtl8168_down(struct net_device *dev)
phy_stop(dev->phydev);
- del_timer_sync(&tp->timer);
-
napi_disable(&tp->napi);
netif_stop_queue(dev);
@@ -8076,8 +8018,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->opts1_mask = ~(RxBOVF | RxFOVF);
- timer_setup(&tp->timer, rtl8168_phy_timer, 0);
-
tp->rtl_fw = RTL_FIRMWARE_UNKNOWN;
tp->counters = dmam_alloc_coherent (&pdev->dev, sizeof(*tp->counters),
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 14/18] r8168: remove rtl8168_set_speed
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
All these PHY basics are handled by phylib, so let's remove this code.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8168.c | 92 ------------------------------------
1 file changed, 92 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index 6b398915f..f88fc0fa0 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -1843,91 +1843,6 @@ static int rtl8168_get_regs_len(struct net_device *dev)
return R8168_REGS_SIZE;
}
-static int rtl8168_set_speed_xmii(struct net_device *dev,
- u8 autoneg, u16 speed, u8 duplex, u32 adv)
-{
- struct rtl8168_private *tp = netdev_priv(dev);
- int giga_ctrl, bmcr;
- int rc = -EINVAL;
-
- rtl_writephy(tp, 0x1f, 0x0000);
-
- if (autoneg == AUTONEG_ENABLE) {
- int auto_nego;
-
- auto_nego = rtl_readphy(tp, MII_ADVERTISE);
- auto_nego &= ~(ADVERTISE_10HALF | ADVERTISE_10FULL |
- ADVERTISE_100HALF | ADVERTISE_100FULL);
-
- if (adv & ADVERTISED_10baseT_Half)
- auto_nego |= ADVERTISE_10HALF;
- if (adv & ADVERTISED_10baseT_Full)
- auto_nego |= ADVERTISE_10FULL;
- if (adv & ADVERTISED_100baseT_Half)
- auto_nego |= ADVERTISE_100HALF;
- if (adv & ADVERTISED_100baseT_Full)
- auto_nego |= ADVERTISE_100FULL;
-
- auto_nego |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
-
- giga_ctrl = rtl_readphy(tp, MII_CTRL1000);
- giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
-
- /* The 8100e/8101e/8102e do Fast Ethernet only. */
- if (tp->mii.supports_gmii) {
- if (adv & ADVERTISED_1000baseT_Half)
- giga_ctrl |= ADVERTISE_1000HALF;
- if (adv & ADVERTISED_1000baseT_Full)
- giga_ctrl |= ADVERTISE_1000FULL;
- } else if (adv & (ADVERTISED_1000baseT_Half |
- ADVERTISED_1000baseT_Full)) {
- netif_info(tp, link, dev,
- "PHY does not support 1000Mbps\n");
- goto out;
- }
-
- bmcr = BMCR_ANENABLE | BMCR_ANRESTART;
-
- rtl_writephy(tp, MII_ADVERTISE, auto_nego);
- rtl_writephy(tp, MII_CTRL1000, giga_ctrl);
- } else {
- if (speed == SPEED_10)
- bmcr = 0;
- else if (speed == SPEED_100)
- bmcr = BMCR_SPEED100;
- else
- goto out;
-
- if (duplex == DUPLEX_FULL)
- bmcr |= BMCR_FULLDPLX;
- }
-
- rtl_writephy(tp, MII_BMCR, bmcr);
-
- rc = 0;
-out:
- return rc;
-}
-
-static int rtl8168_set_speed(struct net_device *dev,
- u8 autoneg, u16 speed, u8 duplex, u32 advertising)
-{
- struct rtl8168_private *tp = netdev_priv(dev);
- int ret;
-
- ret = rtl8168_set_speed_xmii(dev, autoneg, speed, duplex, advertising);
- if (ret < 0)
- goto out;
-
- if (netif_running(dev) && (autoneg == AUTONEG_ENABLE) &&
- (advertising & ADVERTISED_1000baseT_Full) &&
- !pci_is_pcie(tp->pci_dev)) {
- mod_timer(&tp->timer, jiffies + RTL8168_PHY_TIMEOUT);
- }
-out:
- return ret;
-}
-
static netdev_features_t rtl8168_fix_features(struct net_device *dev,
netdev_features_t features)
{
@@ -4264,13 +4179,6 @@ static void rtl8168_init_phy(struct net_device *dev, struct rtl8168_private *tp)
pci_write_config_byte(tp->pci_dev, PCI_LATENCY_TIMER, 0x40);
genphy_soft_reset(dev->phydev);
-
- rtl8168_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
- ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
- ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
- (tp->mii.supports_gmii ?
- ADVERTISED_1000baseT_Half |
- ADVERTISED_1000baseT_Full : 0));
}
static void rtl_rar_set(struct rtl8168_private *tp, u8 *addr)
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 13/18] r8168: replace speed_down with genphy_restart_aneg
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
Dealing with link partner abilities is handled by phylib, so let's
just trigger autonegotiation here.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8168.c | 26 +-------------------------
1 file changed, 1 insertion(+), 25 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index d33f93a31..6b398915f 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -4360,30 +4360,6 @@ static void rtl_init_mdio_ops(struct rtl8168_private *tp)
}
}
-static void rtl_speed_down(struct rtl8168_private *tp)
-{
- u32 adv;
- int lpa;
-
- rtl_writephy(tp, 0x1f, 0x0000);
- lpa = rtl_readphy(tp, MII_LPA);
-
- if (lpa & (LPA_10HALF | LPA_10FULL))
- adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full;
- else if (lpa & (LPA_100HALF | LPA_100FULL))
- adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
- ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full;
- else
- adv = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
- ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
- (tp->mii.supports_gmii ?
- ADVERTISED_1000baseT_Half |
- ADVERTISED_1000baseT_Full : 0);
-
- rtl8168_set_speed(tp->dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
- adv);
-}
-
static void rtl_wol_suspend_quirk(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4424,7 +4400,7 @@ static bool rtl_wol_pll_power_down(struct rtl8168_private *tp)
if (!(__rtl8168_get_wol(tp) & WAKE_ANY))
return false;
- rtl_speed_down(tp);
+ genphy_restart_aneg(tp->dev->phydev);
rtl_wol_suspend_quirk(tp);
return true;
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 12/18] r8168: switch to phy_mii_ioctl
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
Use phy_mii_ioctl for handling the ioctl's.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8168.c | 25 +++----------------------
1 file changed, 3 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index 33f61e100..d33f93a31 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -4316,31 +4316,12 @@ static int rtl_set_mac_address(struct net_device *dev, void *p)
return 0;
}
-static int rtl_xmii_ioctl(struct rtl8168_private *tp,
- struct mii_ioctl_data *data, int cmd)
-{
- switch (cmd) {
- case SIOCGMIIPHY:
- data->phy_id = 32; /* Internal PHY */
- return 0;
-
- case SIOCGMIIREG:
- data->val_out = rtl_readphy(tp, data->reg_num & 0x1f);
- return 0;
-
- case SIOCSMIIREG:
- rtl_writephy(tp, data->reg_num & 0x1f, data->val_in);
- return 0;
- }
- return -EOPNOTSUPP;
-}
-
static int rtl8168_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
- struct rtl8168_private *tp = netdev_priv(dev);
- struct mii_ioctl_data *data = if_mii(ifr);
+ if (!netif_running(dev))
+ return -ENODEV;
- return netif_running(dev) ? rtl_xmii_ioctl(tp, data, cmd) : -ENODEV;
+ return phy_mii_ioctl(dev->phydev, ifr, cmd);
}
static void rtl_init_mdio_ops(struct rtl8168_private *tp)
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 11/18] r8168: switch to phy_ethtool_nway_reset
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
Switch to phy_ethtool_nway_reset.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/Kconfig | 1 -
drivers/net/ethernet/realtek/r8168.c | 9 +--------
2 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/realtek/Kconfig b/drivers/net/ethernet/realtek/Kconfig
index 97b24103e..a31aa84be 100644
--- a/drivers/net/ethernet/realtek/Kconfig
+++ b/drivers/net/ethernet/realtek/Kconfig
@@ -100,7 +100,6 @@ config R8168
select FW_LOADER
select CRC32
select PHYLIB
- select MII
---help---
Say Y here if you have a Realtek 8168 PCI Gigabit Ethernet adapter.
This driver supports the PCIE models.
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index e698f13c2..33f61e100 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -2194,13 +2194,6 @@ static void rtl8168_get_strings(struct net_device *dev, u32 stringset, u8 *data)
}
}
-static int rtl8168_nway_reset(struct net_device *dev)
-{
- struct rtl8168_private *tp = netdev_priv(dev);
-
- return mii_nway_restart(&tp->mii);
-}
-
/*
* Interrupt coalescing
*
@@ -2433,7 +2426,7 @@ static const struct ethtool_ops rtl8168_ethtool_ops = {
.get_sset_count = rtl8168_get_sset_count,
.get_ethtool_stats = rtl8168_get_ethtool_stats,
.get_ts_info = ethtool_op_get_ts_info,
- .nway_reset = rtl8168_nway_reset,
+ .nway_reset = phy_ethtool_nway_reset,
.get_link_ksettings = phy_ethtool_get_link_ksettings,
.set_link_ksettings = phy_ethtool_set_link_ksettings,
};
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 10/18] r8168: switch to phy_ethtool_get/set_link_ksettings
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
Use phy_ethtool_get/set_link_ksettings instead of open coding these
ethtool ops.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8168.c | 50 +++---------------------------------
1 file changed, 3 insertions(+), 47 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index 62d0e0169..e698f13c2 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -2004,50 +2004,6 @@ static void rtl8168_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), swab16(opts2 & 0xffff));
}
-static int rtl8168_get_link_ksettings_xmii(struct net_device *dev,
- struct ethtool_link_ksettings *cmd)
-{
- struct rtl8168_private *tp = netdev_priv(dev);
-
- mii_ethtool_get_link_ksettings(&tp->mii, cmd);
-
- return 0;
-}
-
-static int rtl8168_get_link_ksettings(struct net_device *dev,
- struct ethtool_link_ksettings *cmd)
-{
- struct rtl8168_private *tp = netdev_priv(dev);
- int rc;
-
- rtl_lock_work(tp);
- rc = rtl8168_get_link_ksettings_xmii(dev, cmd);
- rtl_unlock_work(tp);
-
- return rc;
-}
-
-static int rtl8168_set_link_ksettings(struct net_device *dev,
- const struct ethtool_link_ksettings *cmd)
-{
- struct rtl8168_private *tp = netdev_priv(dev);
- int rc;
- u32 advertising;
-
- if (!ethtool_convert_link_mode_to_legacy_u32(&advertising,
- cmd->link_modes.advertising))
- return -EINVAL;
-
- del_timer_sync(&tp->timer);
-
- rtl_lock_work(tp);
- rc = rtl8168_set_speed(dev, cmd->base.autoneg, cmd->base.speed,
- cmd->base.duplex, advertising);
- rtl_unlock_work(tp);
-
- return rc;
-}
-
static void rtl8168_get_regs(struct net_device *dev, struct ethtool_regs *regs,
void *p)
{
@@ -2317,7 +2273,7 @@ static const struct rtl_coalesce_info *rtl_coalesce_info(struct net_device *dev)
const struct rtl_coalesce_info *ci;
int rc;
- rc = rtl8168_get_link_ksettings(dev, &ecmd);
+ rc = phy_ethtool_get_link_ksettings(dev, &ecmd);
if (rc < 0)
return ERR_PTR(rc);
@@ -2478,8 +2434,8 @@ static const struct ethtool_ops rtl8168_ethtool_ops = {
.get_ethtool_stats = rtl8168_get_ethtool_stats,
.get_ts_info = ethtool_op_get_ts_info,
.nway_reset = rtl8168_nway_reset,
- .get_link_ksettings = rtl8168_get_link_ksettings,
- .set_link_ksettings = rtl8168_set_link_ksettings,
+ .get_link_ksettings = phy_ethtool_get_link_ksettings,
+ .set_link_ksettings = phy_ethtool_set_link_ksettings,
};
static void rtl8168_get_mac_version(struct rtl8168_private *tp,
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 09/18] r8168: use genphy_soft_reset instead of open coding the soft reset
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
Use genphy_soft_reset instead of open coding the soft reset.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8168.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index be6c45b11..62d0e0169 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -4308,25 +4308,13 @@ static void rtl8168_phy_timer(struct timer_list *t)
rtl_schedule_task(tp, RTL_FLAG_TASK_PHY_PENDING);
}
-DECLARE_RTL_COND(rtl_phy_reset_cond)
-{
- return rtl8168_xmii_reset_pending(tp);
-}
-
-static void rtl8168_phy_reset(struct net_device *dev,
- struct rtl8168_private *tp)
-{
- rtl8168_xmii_reset_enable(tp);
- rtl_msleep_loop_wait_low(tp, &rtl_phy_reset_cond, 1, 100);
-}
-
static void rtl8168_init_phy(struct net_device *dev, struct rtl8168_private *tp)
{
rtl_hw_phy_config(dev);
pci_write_config_byte(tp->pci_dev, PCI_LATENCY_TIMER, 0x40);
- rtl8168_phy_reset(dev, tp);
+ genphy_soft_reset(dev->phydev);
rtl8168_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 08/18] r8168: add basic phylib support
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
All PHY's of the supported chips are MII-compatible, therefore let
phylib do the work.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/Kconfig | 1 +
drivers/net/ethernet/realtek/r8168.c | 152 +++++++++++++++++++++++++++--------
2 files changed, 120 insertions(+), 33 deletions(-)
diff --git a/drivers/net/ethernet/realtek/Kconfig b/drivers/net/ethernet/realtek/Kconfig
index 011b524c5..97b24103e 100644
--- a/drivers/net/ethernet/realtek/Kconfig
+++ b/drivers/net/ethernet/realtek/Kconfig
@@ -99,6 +99,7 @@ config R8168
depends on PCI
select FW_LOADER
select CRC32
+ select PHYLIB
select MII
---help---
Say Y here if you have a Realtek 8168 PCI Gigabit Ethernet adapter.
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index b0c4b5ea8..be6c45b11 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -16,6 +16,7 @@
#include <linux/delay.h>
#include <linux/ethtool.h>
#include <linux/mii.h>
+#include <linux/phy.h>
#include <linux/if_vlan.h>
#include <linux/crc32.h>
#include <linux/in.h>
@@ -818,6 +819,7 @@ struct rtl8168_private {
unsigned features;
struct mii_if_info mii;
+ struct mii_bus *mii_bus;
dma_addr_t counters_phys_addr;
struct rtl8168_counters *counters;
struct rtl8168_tc_offsets tc_offset;
@@ -1632,33 +1634,6 @@ static void rtl_link_chg_patch(struct rtl8168_private *tp)
}
}
-static void __rtl8168_check_link_status(struct net_device *dev,
- struct rtl8168_private *tp,
- void __iomem *ioaddr, bool pm)
-{
- if (rtl8168_xmii_link_ok(ioaddr)) {
- rtl_link_chg_patch(tp);
- /* This is to cancel a scheduled suspend if there's one. */
- if (pm)
- pm_request_resume(&tp->pci_dev->dev);
- netif_carrier_on(dev);
- if (net_ratelimit())
- netif_info(tp, ifup, dev, "link up\n");
- } else {
- netif_carrier_off(dev);
- netif_info(tp, ifdown, dev, "link down\n");
- if (pm)
- pm_schedule_suspend(&tp->pci_dev->dev, 5000);
- }
-}
-
-static void rtl8168_check_link_status(struct net_device *dev,
- struct rtl8168_private *tp,
- void __iomem *ioaddr)
-{
- __rtl8168_check_link_status(dev, tp, ioaddr, false);
-}
-
#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST)
static u32 __rtl8168_get_wol(struct rtl8168_private *tp)
@@ -6694,8 +6669,8 @@ static void rtl_reset_work(struct rtl8168_private *tp)
napi_enable(&tp->napi);
rtl_hw_start(dev);
+ phy_start(dev->phydev);
netif_wake_queue(dev);
- rtl8168_check_link_status(dev, tp, tp->mmio_addr);
}
static void rtl8168_tx_timeout(struct net_device *dev)
@@ -7329,7 +7304,7 @@ static void rtl_slow_event_work(struct rtl8168_private *tp)
rtl8168_pcierr_interrupt(dev);
if (status & LinkChg)
- __rtl8168_check_link_status(dev, tp, tp->mmio_addr, true);
+ phy_mac_interrupt(dev->phydev, netif_carrier_ok(dev));
rtl_irq_enable_all(tp);
}
@@ -7405,6 +7380,8 @@ static void rtl8168_down(struct net_device *dev)
{
struct rtl8168_private *tp = netdev_priv(dev);
+ phy_stop(dev->phydev);
+
del_timer_sync(&tp->timer);
napi_disable(&tp->napi);
@@ -7466,7 +7443,6 @@ static void rtl8168_netpoll(struct net_device *dev)
static int rtl_open(struct net_device *dev)
{
struct rtl8168_private *tp = netdev_priv(dev);
- void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
int retval = -ENOMEM;
@@ -7519,14 +7495,14 @@ static int rtl_open(struct net_device *dev)
if (!rtl8168_init_counter_offsets(dev))
netif_warn(tp, hw, dev, "counter reset/update failed\n");
+ phy_start(dev->phydev);
+
netif_start_queue(dev);
rtl_unlock_work(tp);
tp->saved_wolopts = 0;
pm_runtime_put_noidle(&pdev->dev);
-
- rtl8168_check_link_status(dev, tp, ioaddr);
out:
return retval;
@@ -7605,6 +7581,8 @@ static void rtl8168_net_suspend(struct net_device *dev)
if (!netif_running(dev))
return;
+ phy_stop(dev->phydev);
+
netif_device_detach(dev);
netif_stop_queue(dev);
@@ -7796,7 +7774,10 @@ static void rtl_remove_one(struct pci_dev *pdev)
netif_napi_del(&tp->napi);
+ phy_disconnect(dev->phydev);
+
unregister_netdev(dev);
+ mdiobus_unregister(tp->mii_bus);
rtl_release_firmware(tp);
@@ -7899,6 +7880,97 @@ DECLARE_RTL_COND(rtl_rxtx_empty_cond)
return (RTL_R8(MCU) & RXTX_EMPTY) == RXTX_EMPTY;
}
+static int r8168_mdio_read_reg(struct mii_bus *mii_bus, int phyaddr, int phyreg)
+{
+ struct rtl8168_private *tp = mii_bus->priv;
+
+ return tp->mdio_ops.read(tp, phyreg);
+}
+
+static int r8168_mdio_write_reg(struct mii_bus *mii_bus, int phyaddr,
+ int phyreg, u16 val)
+{
+ struct rtl8168_private *tp = mii_bus->priv;
+
+ tp->mdio_ops.write(tp, phyreg, val);
+
+ return 0;
+}
+
+static int r8168_mdio_register(struct rtl8168_private *tp)
+{
+ struct pci_dev *pdev = tp->pci_dev;
+ struct mii_bus *new_bus;
+ int ret;
+
+ new_bus = devm_mdiobus_alloc(&pdev->dev);
+ if (!new_bus)
+ return -ENOMEM;
+
+ new_bus->name = "r8168";
+ new_bus->priv = tp;
+ new_bus->phy_mask = ~1;
+ new_bus->parent = &pdev->dev;
+ new_bus->irq[0] = PHY_IGNORE_INTERRUPT;
+ snprintf(new_bus->id, MII_BUS_ID_SIZE, "%s-%02x:%02x.%x",
+ new_bus->name, pdev->bus->number,
+ PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
+
+ new_bus->read = r8168_mdio_read_reg;
+ new_bus->write = r8168_mdio_write_reg;
+
+ ret = mdiobus_register(new_bus);
+ if (!ret)
+ tp->mii_bus = new_bus;
+
+ return ret;
+}
+
+static void r8168_phylink_handler(struct net_device *ndev)
+{
+ struct rtl8168_private *tp = netdev_priv(ndev);
+
+ if (netif_carrier_ok(ndev)) {
+ rtl_link_chg_patch(tp);
+ pm_request_resume(&tp->pci_dev->dev);
+ } else {
+ pm_schedule_suspend(&tp->pci_dev->dev, 5000);
+ }
+
+ if (net_ratelimit())
+ phy_print_status(ndev->phydev);
+}
+
+static int r8168_phy_connect(struct rtl8168_private *tp)
+{
+ struct phy_device *phydev;
+ phy_interface_t phy_mode;
+ int ret;
+
+ phy_mode = tp->mii.supports_gmii ? PHY_INTERFACE_MODE_GMII :
+ PHY_INTERFACE_MODE_MII;
+
+ phydev = phy_find_first(tp->mii_bus);
+ if (!phydev)
+ return -ENODEV;
+
+ ret = phy_connect_direct(tp->dev, phydev, r8168_phylink_handler,
+ phy_mode);
+ if (ret)
+ return ret;
+
+ phy_attached_info(phydev);
+
+ if (!tp->mii.supports_gmii && (phydev->supported &
+ (SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full))) {
+ netif_info(tp, probe, tp->dev, "Restrict PHY to 100Mbit because MAC doesn't support 1GBit");
+ phy_set_max_speed(phydev, SPEED_100);
+ ret = genphy_restart_aneg(phydev);
+ }
+
+ return ret;
+}
+
static void rtl_hw_init_8168g(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -8212,10 +8284,18 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!tp->counters)
return -ENOMEM;
- rc = register_netdev(dev);
+ rc = r8168_mdio_register(tp);
if (rc < 0)
return rc;
+ rc = register_netdev(dev);
+ if (rc < 0)
+ goto err_mdio_unregister;
+
+ rc = r8168_phy_connect(tp);
+ if (rc < 0)
+ goto err_netdev_unregister;
+
pci_set_drvdata(pdev, dev);
netif_info(tp, probe, dev, "%s at 0x%p, %pM, XID %08x IRQ %d\n",
@@ -8244,6 +8324,12 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
netif_carrier_off(dev);
return 0;
+
+err_netdev_unregister:
+ unregister_netdev(dev);
+err_mdio_unregister:
+ mdiobus_unregister(tp->mii_bus);
+ return rc;
}
static struct pci_driver rtl8168_pci_driver = {
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 07/18] r8168: replace 8169 with 8168 in all relevant symbols
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
After separation from the r8169 driver, replace 8169 with 8168 in all
relevant symbols.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8168.c | 1066 +++++++++++++++++-----------------
1 file changed, 533 insertions(+), 533 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index 0ba0ac5ec..b0c4b5ea8 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -1,5 +1,5 @@
/*
- * r8169.c: RealTek 8169/8168/8101 ethernet driver.
+ * r8168.c: RealTek 8168/8101 ethernet driver.
*
* Copyright (c) 2002 ShuChen <shuchen@realtek.com.tw>
* Copyright (c) 2003 - 2007 Francois Romieu <romieu@fr.zoreil.com>
@@ -33,7 +33,7 @@
#include <asm/io.h>
#include <asm/irq.h>
-#define RTL8169_VERSION "2.3LK-NAPI"
+#define RTL8168_VERSION "2.3LK-NAPI"
#define MODULENAME "r8168"
#define PFX MODULENAME ": "
@@ -57,7 +57,7 @@
#define FIRMWARE_8107E_1 "rtl_nic/rtl8107e-1.fw"
#define FIRMWARE_8107E_2 "rtl_nic/rtl8107e-2.fw"
-#ifdef RTL8169_DEBUG
+#ifdef RTL8168_DEBUG
#define assert(expr) \
if (!(expr)) { \
printk( "Assertion failed! %s,%s,%s,line=%d\n", \
@@ -68,9 +68,9 @@
#else
#define assert(expr) do {} while (0)
#define dprintk(fmt, args...) do {} while (0)
-#endif /* RTL8169_DEBUG */
+#endif /* RTL8168_DEBUG */
-#define R8169_MSG_DEFAULT \
+#define R8168_MSG_DEFAULT \
(NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN)
#define TX_SLOTS_AVAIL(tp) \
@@ -88,15 +88,15 @@ static const int multicast_filter_limit = 32;
#define TX_DMA_BURST 7 /* Maximum PCI burst, '7' is unlimited */
#define InterFrameGap 0x03 /* 3 means InterFrameGap = the shortest one */
-#define R8169_REGS_SIZE 256
-#define R8169_NAPI_WEIGHT 64
+#define R8168_REGS_SIZE 256
+#define R8168_NAPI_WEIGHT 64
#define NUM_TX_DESC 64 /* Number of Tx descriptor registers */
#define NUM_RX_DESC 256U /* Number of Rx descriptor registers */
-#define R8169_TX_RING_BYTES (NUM_TX_DESC * sizeof(struct TxDesc))
-#define R8169_RX_RING_BYTES (NUM_RX_DESC * sizeof(struct RxDesc))
+#define R8168_TX_RING_BYTES (NUM_TX_DESC * sizeof(struct TxDesc))
+#define R8168_RX_RING_BYTES (NUM_RX_DESC * sizeof(struct RxDesc))
-#define RTL8169_TX_TIMEOUT (6*HZ)
-#define RTL8169_PHY_TIMEOUT (10*HZ)
+#define RTL8168_TX_TIMEOUT (6*HZ)
+#define RTL8168_PHY_TIMEOUT (10*HZ)
/* write/read MMIO register */
#define RTL_W8(reg, val8) writeb ((val8), ioaddr + (reg))
@@ -617,7 +617,7 @@ enum rtl_register_content {
INTT_2 = 0x0002, // 8168
INTT_3 = 0x0003, // 8168
- /* rtl8169_PHYstatus */
+ /* rtl8168_PHYstatus */
TBI_Enable = 0x80,
TxFlowCtrl = 0x40,
RxFlowCtrl = 0x20,
@@ -724,7 +724,7 @@ enum features {
RTL_FEATURE_GMII = (1 << 2),
};
-struct rtl8169_counters {
+struct rtl8168_counters {
__le64 tx_packets;
__le64 rx_packets;
__le64 tx_errors;
@@ -740,7 +740,7 @@ struct rtl8169_counters {
__le16 tx_underun;
};
-struct rtl8169_tc_offsets {
+struct rtl8168_tc_offsets {
bool inited;
__le64 tx_errors;
__le32 tx_multi_collision;
@@ -755,13 +755,13 @@ enum rtl_flag {
RTL_FLAG_MAX
};
-struct rtl8169_stats {
+struct rtl8168_stats {
u64 packets;
u64 bytes;
struct u64_stats_sync syncp;
};
-struct rtl8169_private {
+struct rtl8168_private {
void __iomem *mmio_addr; /* memory map physical address */
struct pci_dev *pci_dev;
struct net_device *dev;
@@ -772,8 +772,8 @@ struct rtl8169_private {
u32 cur_rx; /* Index into the Rx descriptor buffer of next Rx pkt. */
u32 cur_tx; /* Index into the Tx descriptor buffer of next Rx pkt. */
u32 dirty_tx;
- struct rtl8169_stats rx_stats;
- struct rtl8169_stats tx_stats;
+ struct rtl8168_stats rx_stats;
+ struct rtl8168_stats tx_stats;
struct TxDesc *TxDescArray; /* 256-aligned Tx descriptor ring */
struct RxDesc *RxDescArray; /* 256-aligned Rx descriptor ring */
dma_addr_t TxPhyAddr;
@@ -787,27 +787,27 @@ struct rtl8169_private {
const struct rtl_coalesce_info *coalesce_info;
struct mdio_ops {
- void (*write)(struct rtl8169_private *, int, int);
- int (*read)(struct rtl8169_private *, int);
+ void (*write)(struct rtl8168_private *, int, int);
+ int (*read)(struct rtl8168_private *, int);
} mdio_ops;
struct pll_power_ops {
- void (*down)(struct rtl8169_private *);
- void (*up)(struct rtl8169_private *);
+ void (*down)(struct rtl8168_private *);
+ void (*up)(struct rtl8168_private *);
} pll_power_ops;
struct jumbo_ops {
- void (*enable)(struct rtl8169_private *);
- void (*disable)(struct rtl8169_private *);
+ void (*enable)(struct rtl8168_private *);
+ void (*disable)(struct rtl8168_private *);
} jumbo_ops;
struct csi_ops {
- void (*write)(struct rtl8169_private *, int, int);
- u32 (*read)(struct rtl8169_private *, int);
+ void (*write)(struct rtl8168_private *, int, int);
+ u32 (*read)(struct rtl8168_private *, int);
} csi_ops;
void (*hw_start)(struct net_device *);
- bool (*tso_csum)(struct rtl8169_private *, struct sk_buff *, u32 *);
+ bool (*tso_csum)(struct rtl8168_private *, struct sk_buff *, u32 *);
struct {
DECLARE_BITMAP(flags, RTL_FLAG_MAX);
@@ -819,8 +819,8 @@ struct rtl8169_private {
struct mii_if_info mii;
dma_addr_t counters_phys_addr;
- struct rtl8169_counters *counters;
- struct rtl8169_tc_offsets tc_offset;
+ struct rtl8168_counters *counters;
+ struct rtl8168_tc_offsets tc_offset;
u32 saved_wolopts;
u32 opts1_mask;
@@ -841,14 +841,14 @@ struct rtl8169_private {
u32 ocp_base;
};
-MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>");
-MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver");
+MODULE_AUTHOR("Realtek and the Linux r8168 crew <netdev@vger.kernel.org>");
+MODULE_DESCRIPTION("RealTek RTL-8168 Gigabit Ethernet driver");
module_param(use_dac, int, 0);
MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot.");
module_param_named(debug, debug.msg_enable, int, 0);
MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)");
MODULE_LICENSE("GPL");
-MODULE_VERSION(RTL8169_VERSION);
+MODULE_VERSION(RTL8168_VERSION);
MODULE_FIRMWARE(FIRMWARE_8168D_1);
MODULE_FIRMWARE(FIRMWARE_8168D_2);
MODULE_FIRMWARE(FIRMWARE_8168E_1);
@@ -869,12 +869,12 @@ MODULE_FIRMWARE(FIRMWARE_8168H_2);
MODULE_FIRMWARE(FIRMWARE_8107E_1);
MODULE_FIRMWARE(FIRMWARE_8107E_2);
-static void rtl_lock_work(struct rtl8169_private *tp)
+static void rtl_lock_work(struct rtl8168_private *tp)
{
mutex_lock(&tp->wk.mutex);
}
-static void rtl_unlock_work(struct rtl8169_private *tp)
+static void rtl_unlock_work(struct rtl8168_private *tp)
{
mutex_unlock(&tp->wk.mutex);
}
@@ -886,7 +886,7 @@ static void rtl_tx_performance_tweak(struct pci_dev *pdev, u16 force)
}
struct rtl_cond {
- bool (*check)(struct rtl8169_private *);
+ bool (*check)(struct rtl8168_private *);
const char *msg;
};
@@ -895,7 +895,7 @@ static void rtl_udelay(unsigned int d)
udelay(d);
}
-static bool rtl_loop_wait(struct rtl8169_private *tp, const struct rtl_cond *c,
+static bool rtl_loop_wait(struct rtl8168_private *tp, const struct rtl_cond *c,
void (*delay)(unsigned int), unsigned int d, int n,
bool high)
{
@@ -911,28 +911,28 @@ static bool rtl_loop_wait(struct rtl8169_private *tp, const struct rtl_cond *c,
return false;
}
-static bool rtl_udelay_loop_wait_high(struct rtl8169_private *tp,
+static bool rtl_udelay_loop_wait_high(struct rtl8168_private *tp,
const struct rtl_cond *c,
unsigned int d, int n)
{
return rtl_loop_wait(tp, c, rtl_udelay, d, n, true);
}
-static bool rtl_udelay_loop_wait_low(struct rtl8169_private *tp,
+static bool rtl_udelay_loop_wait_low(struct rtl8168_private *tp,
const struct rtl_cond *c,
unsigned int d, int n)
{
return rtl_loop_wait(tp, c, rtl_udelay, d, n, false);
}
-static bool rtl_msleep_loop_wait_high(struct rtl8169_private *tp,
+static bool rtl_msleep_loop_wait_high(struct rtl8168_private *tp,
const struct rtl_cond *c,
unsigned int d, int n)
{
return rtl_loop_wait(tp, c, msleep, d, n, true);
}
-static bool rtl_msleep_loop_wait_low(struct rtl8169_private *tp,
+static bool rtl_msleep_loop_wait_low(struct rtl8168_private *tp,
const struct rtl_cond *c,
unsigned int d, int n)
{
@@ -940,16 +940,16 @@ static bool rtl_msleep_loop_wait_low(struct rtl8169_private *tp,
}
#define DECLARE_RTL_COND(name) \
-static bool name ## _check(struct rtl8169_private *); \
+static bool name ## _check(struct rtl8168_private *); \
\
static const struct rtl_cond name = { \
.check = name ## _check, \
.msg = #name \
}; \
\
-static bool name ## _check(struct rtl8169_private *tp)
+static bool name ## _check(struct rtl8168_private *tp)
-static bool rtl_ocp_reg_failure(struct rtl8169_private *tp, u32 reg)
+static bool rtl_ocp_reg_failure(struct rtl8168_private *tp, u32 reg)
{
if (reg & 0xffff0001) {
netif_err(tp, drv, tp->dev, "Invalid ocp reg %x!\n", reg);
@@ -965,7 +965,7 @@ DECLARE_RTL_COND(rtl_ocp_gphy_cond)
return RTL_R32(GPHY_OCP) & OCPAR_FLAG;
}
-static void r8168_phy_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data)
+static void r8168_phy_ocp_write(struct rtl8168_private *tp, u32 reg, u32 data)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -977,7 +977,7 @@ static void r8168_phy_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data)
rtl_udelay_loop_wait_low(tp, &rtl_ocp_gphy_cond, 25, 10);
}
-static u16 r8168_phy_ocp_read(struct rtl8169_private *tp, u32 reg)
+static u16 r8168_phy_ocp_read(struct rtl8168_private *tp, u32 reg)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -990,7 +990,7 @@ static u16 r8168_phy_ocp_read(struct rtl8169_private *tp, u32 reg)
(RTL_R32(GPHY_OCP) & 0xffff) : ~0;
}
-static void r8168_mac_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data)
+static void r8168_mac_ocp_write(struct rtl8168_private *tp, u32 reg, u32 data)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1000,7 +1000,7 @@ static void r8168_mac_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data)
RTL_W32(OCPDR, OCPAR_FLAG | (reg << 15) | data);
}
-static u16 r8168_mac_ocp_read(struct rtl8169_private *tp, u32 reg)
+static u16 r8168_mac_ocp_read(struct rtl8168_private *tp, u32 reg)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1014,7 +1014,7 @@ static u16 r8168_mac_ocp_read(struct rtl8169_private *tp, u32 reg)
#define OCP_STD_PHY_BASE 0xa400
-static void r8168g_mdio_write(struct rtl8169_private *tp, int reg, int value)
+static void r8168g_mdio_write(struct rtl8168_private *tp, int reg, int value)
{
if (reg == 0x1f) {
tp->ocp_base = value ? value << 4 : OCP_STD_PHY_BASE;
@@ -1027,7 +1027,7 @@ static void r8168g_mdio_write(struct rtl8169_private *tp, int reg, int value)
r8168_phy_ocp_write(tp, tp->ocp_base + reg * 2, value);
}
-static int r8168g_mdio_read(struct rtl8169_private *tp, int reg)
+static int r8168g_mdio_read(struct rtl8168_private *tp, int reg)
{
if (tp->ocp_base != OCP_STD_PHY_BASE)
reg -= 0x10;
@@ -1035,7 +1035,7 @@ static int r8168g_mdio_read(struct rtl8169_private *tp, int reg)
return r8168_phy_ocp_read(tp, tp->ocp_base + reg * 2);
}
-static void mac_mcu_write(struct rtl8169_private *tp, int reg, int value)
+static void mac_mcu_write(struct rtl8168_private *tp, int reg, int value)
{
if (reg == 0x1f) {
tp->ocp_base = value << 4;
@@ -1045,7 +1045,7 @@ static void mac_mcu_write(struct rtl8169_private *tp, int reg, int value)
r8168_mac_ocp_write(tp, tp->ocp_base + reg, value);
}
-static int mac_mcu_read(struct rtl8169_private *tp, int reg)
+static int mac_mcu_read(struct rtl8168_private *tp, int reg)
{
return r8168_mac_ocp_read(tp, tp->ocp_base + reg);
}
@@ -1057,7 +1057,7 @@ DECLARE_RTL_COND(rtl_phyar_cond)
return RTL_R32(PHYAR) & 0x80000000;
}
-static void r8169_mdio_write(struct rtl8169_private *tp, int reg, int value)
+static void r8168_mdio_write(struct rtl8168_private *tp, int reg, int value)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1071,7 +1071,7 @@ static void r8169_mdio_write(struct rtl8169_private *tp, int reg, int value)
udelay(20);
}
-static int r8169_mdio_read(struct rtl8169_private *tp, int reg)
+static int r8168_mdio_read(struct rtl8168_private *tp, int reg)
{
void __iomem *ioaddr = tp->mmio_addr;
int value;
@@ -1097,7 +1097,7 @@ DECLARE_RTL_COND(rtl_ocpar_cond)
return RTL_R32(OCPAR) & OCPAR_FLAG;
}
-static void r8168dp_1_mdio_access(struct rtl8169_private *tp, int reg, u32 data)
+static void r8168dp_1_mdio_access(struct rtl8168_private *tp, int reg, u32 data)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1108,13 +1108,13 @@ static void r8168dp_1_mdio_access(struct rtl8169_private *tp, int reg, u32 data)
rtl_udelay_loop_wait_low(tp, &rtl_ocpar_cond, 1000, 100);
}
-static void r8168dp_1_mdio_write(struct rtl8169_private *tp, int reg, int value)
+static void r8168dp_1_mdio_write(struct rtl8168_private *tp, int reg, int value)
{
r8168dp_1_mdio_access(tp, reg,
OCPDR_WRITE_CMD | (value & OCPDR_DATA_MASK));
}
-static int r8168dp_1_mdio_read(struct rtl8169_private *tp, int reg)
+static int r8168dp_1_mdio_read(struct rtl8168_private *tp, int reg)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1140,47 +1140,47 @@ static void r8168dp_2_mdio_stop(void __iomem *ioaddr)
RTL_W32(0xd0, RTL_R32(0xd0) | R8168DP_1_MDIO_ACCESS_BIT);
}
-static void r8168dp_2_mdio_write(struct rtl8169_private *tp, int reg, int value)
+static void r8168dp_2_mdio_write(struct rtl8168_private *tp, int reg, int value)
{
void __iomem *ioaddr = tp->mmio_addr;
r8168dp_2_mdio_start(ioaddr);
- r8169_mdio_write(tp, reg, value);
+ r8168_mdio_write(tp, reg, value);
r8168dp_2_mdio_stop(ioaddr);
}
-static int r8168dp_2_mdio_read(struct rtl8169_private *tp, int reg)
+static int r8168dp_2_mdio_read(struct rtl8168_private *tp, int reg)
{
void __iomem *ioaddr = tp->mmio_addr;
int value;
r8168dp_2_mdio_start(ioaddr);
- value = r8169_mdio_read(tp, reg);
+ value = r8168_mdio_read(tp, reg);
r8168dp_2_mdio_stop(ioaddr);
return value;
}
-static void rtl_writephy(struct rtl8169_private *tp, int location, u32 val)
+static void rtl_writephy(struct rtl8168_private *tp, int location, u32 val)
{
tp->mdio_ops.write(tp, location, val);
}
-static int rtl_readphy(struct rtl8169_private *tp, int location)
+static int rtl_readphy(struct rtl8168_private *tp, int location)
{
return tp->mdio_ops.read(tp, location);
}
-static void rtl_patchphy(struct rtl8169_private *tp, int reg_addr, int value)
+static void rtl_patchphy(struct rtl8168_private *tp, int reg_addr, int value)
{
rtl_writephy(tp, reg_addr, rtl_readphy(tp, reg_addr) | value);
}
-static void rtl_w0w1_phy(struct rtl8169_private *tp, int reg_addr, int p, int m)
+static void rtl_w0w1_phy(struct rtl8168_private *tp, int reg_addr, int p, int m)
{
int val;
@@ -1191,14 +1191,14 @@ static void rtl_w0w1_phy(struct rtl8169_private *tp, int reg_addr, int p, int m)
static void rtl_mdio_write(struct net_device *dev, int phy_id, int location,
int val)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
rtl_writephy(tp, location, val);
}
static int rtl_mdio_read(struct net_device *dev, int phy_id, int location)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
return rtl_readphy(tp, location);
}
@@ -1210,7 +1210,7 @@ DECLARE_RTL_COND(rtl_ephyar_cond)
return RTL_R32(EPHYAR) & EPHYAR_FLAG;
}
-static void rtl_ephy_write(struct rtl8169_private *tp, int reg_addr, int value)
+static void rtl_ephy_write(struct rtl8168_private *tp, int reg_addr, int value)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1222,7 +1222,7 @@ static void rtl_ephy_write(struct rtl8169_private *tp, int reg_addr, int value)
udelay(10);
}
-static u16 rtl_ephy_read(struct rtl8169_private *tp, int reg_addr)
+static u16 rtl_ephy_read(struct rtl8168_private *tp, int reg_addr)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1239,7 +1239,7 @@ DECLARE_RTL_COND(rtl_eriar_cond)
return RTL_R32(ERIAR) & ERIAR_FLAG;
}
-static void rtl_eri_write(struct rtl8169_private *tp, int addr, u32 mask,
+static void rtl_eri_write(struct rtl8168_private *tp, int addr, u32 mask,
u32 val, int type)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1251,7 +1251,7 @@ static void rtl_eri_write(struct rtl8169_private *tp, int addr, u32 mask,
rtl_udelay_loop_wait_low(tp, &rtl_eriar_cond, 100, 100);
}
-static u32 rtl_eri_read(struct rtl8169_private *tp, int addr, int type)
+static u32 rtl_eri_read(struct rtl8168_private *tp, int addr, int type)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1261,7 +1261,7 @@ static u32 rtl_eri_read(struct rtl8169_private *tp, int addr, int type)
RTL_R32(ERIDR) : ~0;
}
-static void rtl_w0w1_eri(struct rtl8169_private *tp, int addr, u32 mask, u32 p,
+static void rtl_w0w1_eri(struct rtl8168_private *tp, int addr, u32 mask, u32 p,
u32 m, int type)
{
u32 val;
@@ -1270,7 +1270,7 @@ static void rtl_w0w1_eri(struct rtl8169_private *tp, int addr, u32 mask, u32 p,
rtl_eri_write(tp, addr, mask, (val & ~m) | p, type);
}
-static u32 r8168dp_ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg)
+static u32 r8168dp_ocp_read(struct rtl8168_private *tp, u8 mask, u16 reg)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1279,12 +1279,12 @@ static u32 r8168dp_ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg)
RTL_R32(OCPDR) : ~0;
}
-static u32 r8168ep_ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg)
+static u32 r8168ep_ocp_read(struct rtl8168_private *tp, u8 mask, u16 reg)
{
return rtl_eri_read(tp, reg, ERIAR_OOB);
}
-static u32 ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg)
+static u32 ocp_read(struct rtl8168_private *tp, u8 mask, u16 reg)
{
switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_27:
@@ -1301,7 +1301,7 @@ static u32 ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg)
}
}
-static void r8168dp_ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg,
+static void r8168dp_ocp_write(struct rtl8168_private *tp, u8 mask, u16 reg,
u32 data)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1311,14 +1311,14 @@ static void r8168dp_ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg,
rtl_udelay_loop_wait_low(tp, &rtl_ocpar_cond, 100, 20);
}
-static void r8168ep_ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg,
+static void r8168ep_ocp_write(struct rtl8168_private *tp, u8 mask, u16 reg,
u32 data)
{
rtl_eri_write(tp, reg, ((u32)mask & 0x0f) << ERIAR_MASK_SHIFT,
data, ERIAR_OOB);
}
-static void ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg, u32 data)
+static void ocp_write(struct rtl8168_private *tp, u8 mask, u16 reg, u32 data)
{
switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_27:
@@ -1337,7 +1337,7 @@ static void ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg, u32 data)
}
}
-static void rtl8168_oob_notify(struct rtl8169_private *tp, u8 cmd)
+static void rtl8168_oob_notify(struct rtl8168_private *tp, u8 cmd)
{
rtl_eri_write(tp, 0xe8, ERIAR_MASK_0001, cmd, ERIAR_EXGMAC);
@@ -1348,7 +1348,7 @@ static void rtl8168_oob_notify(struct rtl8169_private *tp, u8 cmd)
#define OOB_CMD_DRIVER_START 0x05
#define OOB_CMD_DRIVER_STOP 0x06
-static u16 rtl8168_get_ocp_reg(struct rtl8169_private *tp)
+static u16 rtl8168_get_ocp_reg(struct rtl8168_private *tp)
{
return (tp->mac_version == RTL_GIGA_MAC_VER_31) ? 0xb8 : 0x10;
}
@@ -1374,7 +1374,7 @@ DECLARE_RTL_COND(rtl_ocp_tx_cond)
return RTL_R8(IBISR0) & 0x02;
}
-static void rtl8168ep_stop_cmac(struct rtl8169_private *tp)
+static void rtl8168ep_stop_cmac(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1384,20 +1384,20 @@ static void rtl8168ep_stop_cmac(struct rtl8169_private *tp)
RTL_W8(IBCR0, RTL_R8(IBCR0) & ~0x01);
}
-static void rtl8168dp_driver_start(struct rtl8169_private *tp)
+static void rtl8168dp_driver_start(struct rtl8168_private *tp)
{
rtl8168_oob_notify(tp, OOB_CMD_DRIVER_START);
rtl_msleep_loop_wait_high(tp, &rtl_ocp_read_cond, 10, 10);
}
-static void rtl8168ep_driver_start(struct rtl8169_private *tp)
+static void rtl8168ep_driver_start(struct rtl8168_private *tp)
{
ocp_write(tp, 0x01, 0x180, OOB_CMD_DRIVER_START);
ocp_write(tp, 0x01, 0x30, ocp_read(tp, 0x01, 0x30) | 0x01);
rtl_msleep_loop_wait_high(tp, &rtl_ep_ocp_read_cond, 10, 10);
}
-static void rtl8168_driver_start(struct rtl8169_private *tp)
+static void rtl8168_driver_start(struct rtl8168_private *tp)
{
switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_27:
@@ -1416,13 +1416,13 @@ static void rtl8168_driver_start(struct rtl8169_private *tp)
}
}
-static void rtl8168dp_driver_stop(struct rtl8169_private *tp)
+static void rtl8168dp_driver_stop(struct rtl8168_private *tp)
{
rtl8168_oob_notify(tp, OOB_CMD_DRIVER_STOP);
rtl_msleep_loop_wait_low(tp, &rtl_ocp_read_cond, 10, 10);
}
-static void rtl8168ep_driver_stop(struct rtl8169_private *tp)
+static void rtl8168ep_driver_stop(struct rtl8168_private *tp)
{
rtl8168ep_stop_cmac(tp);
ocp_write(tp, 0x01, 0x180, OOB_CMD_DRIVER_STOP);
@@ -1430,7 +1430,7 @@ static void rtl8168ep_driver_stop(struct rtl8169_private *tp)
rtl_msleep_loop_wait_low(tp, &rtl_ep_ocp_read_cond, 10, 10);
}
-static void rtl8168_driver_stop(struct rtl8169_private *tp)
+static void rtl8168_driver_stop(struct rtl8168_private *tp)
{
switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_27:
@@ -1449,19 +1449,19 @@ static void rtl8168_driver_stop(struct rtl8169_private *tp)
}
}
-static int r8168dp_check_dash(struct rtl8169_private *tp)
+static int r8168dp_check_dash(struct rtl8168_private *tp)
{
u16 reg = rtl8168_get_ocp_reg(tp);
return (ocp_read(tp, 0x0f, reg) & 0x00008000) ? 1 : 0;
}
-static int r8168ep_check_dash(struct rtl8169_private *tp)
+static int r8168ep_check_dash(struct rtl8168_private *tp)
{
return (ocp_read(tp, 0x0f, 0x128) & 0x00000001) ? 1 : 0;
}
-static int r8168_check_dash(struct rtl8169_private *tp)
+static int r8168_check_dash(struct rtl8168_private *tp)
{
switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_27:
@@ -1483,7 +1483,7 @@ struct exgmac_reg {
u32 val;
};
-static void rtl_write_exgmac_batch(struct rtl8169_private *tp,
+static void rtl_write_exgmac_batch(struct rtl8168_private *tp,
const struct exgmac_reg *r, int len)
{
while (len-- > 0) {
@@ -1499,7 +1499,7 @@ DECLARE_RTL_COND(rtl_efusear_cond)
return RTL_R32(EFUSEAR) & EFUSEAR_FLAG;
}
-static u8 rtl8168d_efuse_read(struct rtl8169_private *tp, int reg_addr)
+static u8 rtl8168d_efuse_read(struct rtl8168_private *tp, int reg_addr)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1509,14 +1509,14 @@ static u8 rtl8168d_efuse_read(struct rtl8169_private *tp, int reg_addr)
RTL_R32(EFUSEAR) & EFUSEAR_DATA_MASK : ~0;
}
-static u16 rtl_get_events(struct rtl8169_private *tp)
+static u16 rtl_get_events(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
return RTL_R16(IntrStatus);
}
-static void rtl_ack_events(struct rtl8169_private *tp, u16 bits)
+static void rtl_ack_events(struct rtl8168_private *tp, u16 bits)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1524,7 +1524,7 @@ static void rtl_ack_events(struct rtl8169_private *tp, u16 bits)
mmiowb();
}
-static void rtl_irq_disable(struct rtl8169_private *tp)
+static void rtl_irq_disable(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1532,7 +1532,7 @@ static void rtl_irq_disable(struct rtl8169_private *tp)
mmiowb();
}
-static void rtl_irq_enable(struct rtl8169_private *tp, u16 bits)
+static void rtl_irq_enable(struct rtl8168_private *tp, u16 bits)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1543,12 +1543,12 @@ static void rtl_irq_enable(struct rtl8169_private *tp, u16 bits)
#define RTL_EVENT_NAPI_TX (TxOK | TxErr)
#define RTL_EVENT_NAPI (RTL_EVENT_NAPI_RX | RTL_EVENT_NAPI_TX)
-static void rtl_irq_enable_all(struct rtl8169_private *tp)
+static void rtl_irq_enable_all(struct rtl8168_private *tp)
{
rtl_irq_enable(tp, RTL_EVENT_NAPI | tp->event_slow);
}
-static void rtl8169_irq_mask_and_ack(struct rtl8169_private *tp)
+static void rtl8168_irq_mask_and_ack(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -1557,17 +1557,17 @@ static void rtl8169_irq_mask_and_ack(struct rtl8169_private *tp)
RTL_R8(ChipCmd);
}
-static unsigned int rtl8169_xmii_reset_pending(struct rtl8169_private *tp)
+static unsigned int rtl8168_xmii_reset_pending(struct rtl8168_private *tp)
{
return rtl_readphy(tp, MII_BMCR) & BMCR_RESET;
}
-static unsigned int rtl8169_xmii_link_ok(void __iomem *ioaddr)
+static unsigned int rtl8168_xmii_link_ok(void __iomem *ioaddr)
{
return RTL_R8(PHYstatus) & LinkStatus;
}
-static void rtl8169_xmii_reset_enable(struct rtl8169_private *tp)
+static void rtl8168_xmii_reset_enable(struct rtl8168_private *tp)
{
unsigned int val;
@@ -1575,7 +1575,7 @@ static void rtl8169_xmii_reset_enable(struct rtl8169_private *tp)
rtl_writephy(tp, MII_BMCR, val & 0xffff);
}
-static void rtl_link_chg_patch(struct rtl8169_private *tp)
+static void rtl_link_chg_patch(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct net_device *dev = tp->dev;
@@ -1632,11 +1632,11 @@ static void rtl_link_chg_patch(struct rtl8169_private *tp)
}
}
-static void __rtl8169_check_link_status(struct net_device *dev,
- struct rtl8169_private *tp,
+static void __rtl8168_check_link_status(struct net_device *dev,
+ struct rtl8168_private *tp,
void __iomem *ioaddr, bool pm)
{
- if (rtl8169_xmii_link_ok(ioaddr)) {
+ if (rtl8168_xmii_link_ok(ioaddr)) {
rtl_link_chg_patch(tp);
/* This is to cancel a scheduled suspend if there's one. */
if (pm)
@@ -1652,16 +1652,16 @@ static void __rtl8169_check_link_status(struct net_device *dev,
}
}
-static void rtl8169_check_link_status(struct net_device *dev,
- struct rtl8169_private *tp,
+static void rtl8168_check_link_status(struct net_device *dev,
+ struct rtl8168_private *tp,
void __iomem *ioaddr)
{
- __rtl8169_check_link_status(dev, tp, ioaddr, false);
+ __rtl8168_check_link_status(dev, tp, ioaddr, false);
}
#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST)
-static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
+static u32 __rtl8168_get_wol(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
u8 options;
@@ -1712,9 +1712,9 @@ static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
return wolopts;
}
-static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+static void rtl8168_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
struct device *d = &tp->pci_dev->dev;
pm_runtime_get_noresume(d);
@@ -1723,7 +1723,7 @@ static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
wol->supported = WAKE_ANY;
if (pm_runtime_active(d))
- wol->wolopts = __rtl8169_get_wol(tp);
+ wol->wolopts = __rtl8168_get_wol(tp);
else
wol->wolopts = tp->saved_wolopts;
@@ -1732,7 +1732,7 @@ static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
pm_runtime_put_noidle(d);
}
-static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
+static void __rtl8168_set_wol(struct rtl8168_private *tp, u32 wolopts)
{
void __iomem *ioaddr = tp->mmio_addr;
unsigned int i, tmp;
@@ -1816,9 +1816,9 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
RTL_W8(Cfg9346, Cfg9346_Lock);
}
-static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+static int rtl8168_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
struct device *d = &tp->pci_dev->dev;
pm_runtime_get_noresume(d);
@@ -1830,7 +1830,7 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
else
tp->features &= ~RTL_FEATURE_WOL;
if (pm_runtime_active(d))
- __rtl8169_set_wol(tp, wol->wolopts);
+ __rtl8168_set_wol(tp, wol->wolopts);
else
tp->saved_wolopts = wol->wolopts;
@@ -1843,19 +1843,19 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
return 0;
}
-static const char *rtl_lookup_firmware_name(struct rtl8169_private *tp)
+static const char *rtl_lookup_firmware_name(struct rtl8168_private *tp)
{
return rtl_chip_infos[tp->mac_version].fw_name;
}
-static void rtl8169_get_drvinfo(struct net_device *dev,
+static void rtl8168_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
struct rtl_fw *rtl_fw = tp->rtl_fw;
strlcpy(info->driver, MODULENAME, sizeof(info->driver));
- strlcpy(info->version, RTL8169_VERSION, sizeof(info->version));
+ strlcpy(info->version, RTL8168_VERSION, sizeof(info->version));
strlcpy(info->bus_info, pci_name(tp->pci_dev), sizeof(info->bus_info));
BUILD_BUG_ON(sizeof(info->fw_version) < sizeof(rtl_fw->version));
if (!IS_ERR_OR_NULL(rtl_fw))
@@ -1863,15 +1863,15 @@ static void rtl8169_get_drvinfo(struct net_device *dev,
sizeof(info->fw_version));
}
-static int rtl8169_get_regs_len(struct net_device *dev)
+static int rtl8168_get_regs_len(struct net_device *dev)
{
- return R8169_REGS_SIZE;
+ return R8168_REGS_SIZE;
}
-static int rtl8169_set_speed_xmii(struct net_device *dev,
+static int rtl8168_set_speed_xmii(struct net_device *dev,
u8 autoneg, u16 speed, u8 duplex, u32 adv)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
int giga_ctrl, bmcr;
int rc = -EINVAL;
@@ -1934,29 +1934,29 @@ static int rtl8169_set_speed_xmii(struct net_device *dev,
return rc;
}
-static int rtl8169_set_speed(struct net_device *dev,
+static int rtl8168_set_speed(struct net_device *dev,
u8 autoneg, u16 speed, u8 duplex, u32 advertising)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
int ret;
- ret = rtl8169_set_speed_xmii(dev, autoneg, speed, duplex, advertising);
+ ret = rtl8168_set_speed_xmii(dev, autoneg, speed, duplex, advertising);
if (ret < 0)
goto out;
if (netif_running(dev) && (autoneg == AUTONEG_ENABLE) &&
(advertising & ADVERTISED_1000baseT_Full) &&
!pci_is_pcie(tp->pci_dev)) {
- mod_timer(&tp->timer, jiffies + RTL8169_PHY_TIMEOUT);
+ mod_timer(&tp->timer, jiffies + RTL8168_PHY_TIMEOUT);
}
out:
return ret;
}
-static netdev_features_t rtl8169_fix_features(struct net_device *dev,
+static netdev_features_t rtl8168_fix_features(struct net_device *dev,
netdev_features_t features)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
if (dev->mtu > TD_MSS_MAX)
features &= ~NETIF_F_ALL_TSO;
@@ -1968,10 +1968,10 @@ static netdev_features_t rtl8169_fix_features(struct net_device *dev,
return features;
}
-static void __rtl8169_set_features(struct net_device *dev,
+static void __rtl8168_set_features(struct net_device *dev,
netdev_features_t features)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
u32 rx_config;
@@ -1999,29 +1999,29 @@ static void __rtl8169_set_features(struct net_device *dev,
RTL_R16(CPlusCmd);
}
-static int rtl8169_set_features(struct net_device *dev,
+static int rtl8168_set_features(struct net_device *dev,
netdev_features_t features)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
features &= NETIF_F_RXALL | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX;
rtl_lock_work(tp);
if (features ^ dev->features)
- __rtl8169_set_features(dev, features);
+ __rtl8168_set_features(dev, features);
rtl_unlock_work(tp);
return 0;
}
-static inline u32 rtl8169_tx_vlan_tag(struct sk_buff *skb)
+static inline u32 rtl8168_tx_vlan_tag(struct sk_buff *skb)
{
return (skb_vlan_tag_present(skb)) ?
TxVlanTag | swab16(skb_vlan_tag_get(skb)) : 0x00;
}
-static void rtl8169_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
+static void rtl8168_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
{
u32 opts2 = le32_to_cpu(desc->opts2);
@@ -2029,33 +2029,33 @@ static void rtl8169_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), swab16(opts2 & 0xffff));
}
-static int rtl8169_get_link_ksettings_xmii(struct net_device *dev,
+static int rtl8168_get_link_ksettings_xmii(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
mii_ethtool_get_link_ksettings(&tp->mii, cmd);
return 0;
}
-static int rtl8169_get_link_ksettings(struct net_device *dev,
+static int rtl8168_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
int rc;
rtl_lock_work(tp);
- rc = rtl8169_get_link_ksettings_xmii(dev, cmd);
+ rc = rtl8168_get_link_ksettings_xmii(dev, cmd);
rtl_unlock_work(tp);
return rc;
}
-static int rtl8169_set_link_ksettings(struct net_device *dev,
+static int rtl8168_set_link_ksettings(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
int rc;
u32 advertising;
@@ -2066,42 +2066,42 @@ static int rtl8169_set_link_ksettings(struct net_device *dev,
del_timer_sync(&tp->timer);
rtl_lock_work(tp);
- rc = rtl8169_set_speed(dev, cmd->base.autoneg, cmd->base.speed,
+ rc = rtl8168_set_speed(dev, cmd->base.autoneg, cmd->base.speed,
cmd->base.duplex, advertising);
rtl_unlock_work(tp);
return rc;
}
-static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs,
+static void rtl8168_get_regs(struct net_device *dev, struct ethtool_regs *regs,
void *p)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
u32 __iomem *data = tp->mmio_addr;
u32 *dw = p;
int i;
rtl_lock_work(tp);
- for (i = 0; i < R8169_REGS_SIZE; i += 4)
+ for (i = 0; i < R8168_REGS_SIZE; i += 4)
memcpy_fromio(dw++, data++, 4);
rtl_unlock_work(tp);
}
-static u32 rtl8169_get_msglevel(struct net_device *dev)
+static u32 rtl8168_get_msglevel(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
return tp->msg_enable;
}
-static void rtl8169_set_msglevel(struct net_device *dev, u32 value)
+static void rtl8168_set_msglevel(struct net_device *dev, u32 value)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
tp->msg_enable = value;
}
-static const char rtl8169_gstrings[][ETH_GSTRING_LEN] = {
+static const char rtl8168_gstrings[][ETH_GSTRING_LEN] = {
"tx_packets",
"rx_packets",
"tx_errors",
@@ -2117,11 +2117,11 @@ static const char rtl8169_gstrings[][ETH_GSTRING_LEN] = {
"tx_underrun",
};
-static int rtl8169_get_sset_count(struct net_device *dev, int sset)
+static int rtl8168_get_sset_count(struct net_device *dev, int sset)
{
switch (sset) {
case ETH_SS_STATS:
- return ARRAY_SIZE(rtl8169_gstrings);
+ return ARRAY_SIZE(rtl8168_gstrings);
default:
return -EOPNOTSUPP;
}
@@ -2134,9 +2134,9 @@ DECLARE_RTL_COND(rtl_counters_cond)
return RTL_R32(CounterAddrLow) & (CounterReset | CounterDump);
}
-static bool rtl8169_do_counters(struct net_device *dev, u32 counter_cmd)
+static bool rtl8168_do_counters(struct net_device *dev, u32 counter_cmd)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
dma_addr_t paddr = tp->counters_phys_addr;
u32 cmd;
@@ -2155,9 +2155,9 @@ static bool rtl8169_do_counters(struct net_device *dev, u32 counter_cmd)
return ret;
}
-static bool rtl8169_reset_counters(struct net_device *dev)
+static bool rtl8168_reset_counters(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
/*
* Versions prior to RTL_GIGA_MAC_VER_19 don't support resetting the
@@ -2166,12 +2166,12 @@ static bool rtl8169_reset_counters(struct net_device *dev)
if (tp->mac_version < RTL_GIGA_MAC_VER_19)
return true;
- return rtl8169_do_counters(dev, CounterReset);
+ return rtl8168_do_counters(dev, CounterReset);
}
-static bool rtl8169_update_counters(struct net_device *dev)
+static bool rtl8168_update_counters(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
/*
@@ -2181,17 +2181,17 @@ static bool rtl8169_update_counters(struct net_device *dev)
if ((RTL_R8(ChipCmd) & CmdRxEnb) == 0)
return true;
- return rtl8169_do_counters(dev, CounterDump);
+ return rtl8168_do_counters(dev, CounterDump);
}
-static bool rtl8169_init_counter_offsets(struct net_device *dev)
+static bool rtl8168_init_counter_offsets(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
- struct rtl8169_counters *counters = tp->counters;
+ struct rtl8168_private *tp = netdev_priv(dev);
+ struct rtl8168_counters *counters = tp->counters;
bool ret = false;
/*
- * rtl8169_init_counter_offsets is called from rtl_open. On chip
+ * rtl8168_init_counter_offsets is called from rtl_open. On chip
* versions prior to RTL_GIGA_MAC_VER_19 the tally counters are only
* reset by a power cycle, while the counter values collected by the
* driver are reset at every driver unload/load cycle.
@@ -2200,8 +2200,8 @@ static bool rtl8169_init_counter_offsets(struct net_device *dev)
* values, we collect the initial values at first open(*) and use them
* as offsets to normalize the values returned by @get_stats64.
*
- * (*) We can't call rtl8169_init_counter_offsets from rtl_init_one
- * for the reason stated in rtl8169_update_counters; CmdRxEnb is only
+ * (*) We can't call rtl8168_init_counter_offsets from rtl_init_one
+ * for the reason stated in rtl8168_update_counters; CmdRxEnb is only
* set at open time by rtl_hw_start.
*/
@@ -2209,10 +2209,10 @@ static bool rtl8169_init_counter_offsets(struct net_device *dev)
return true;
/* If both, reset and update fail, propagate to caller. */
- if (rtl8169_reset_counters(dev))
+ if (rtl8168_reset_counters(dev))
ret = true;
- if (rtl8169_update_counters(dev))
+ if (rtl8168_update_counters(dev))
ret = true;
tp->tc_offset.tx_errors = counters->tx_errors;
@@ -2223,19 +2223,19 @@ static bool rtl8169_init_counter_offsets(struct net_device *dev)
return ret;
}
-static void rtl8169_get_ethtool_stats(struct net_device *dev,
+static void rtl8168_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats, u64 *data)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
struct device *d = &tp->pci_dev->dev;
- struct rtl8169_counters *counters = tp->counters;
+ struct rtl8168_counters *counters = tp->counters;
ASSERT_RTNL();
pm_runtime_get_noresume(d);
if (pm_runtime_active(d))
- rtl8169_update_counters(dev);
+ rtl8168_update_counters(dev);
pm_runtime_put_noidle(d);
@@ -2254,18 +2254,18 @@ static void rtl8169_get_ethtool_stats(struct net_device *dev,
data[12] = le16_to_cpu(counters->tx_underun);
}
-static void rtl8169_get_strings(struct net_device *dev, u32 stringset, u8 *data)
+static void rtl8168_get_strings(struct net_device *dev, u32 stringset, u8 *data)
{
switch(stringset) {
case ETH_SS_STATS:
- memcpy(data, *rtl8169_gstrings, sizeof(rtl8169_gstrings));
+ memcpy(data, *rtl8168_gstrings, sizeof(rtl8168_gstrings));
break;
}
}
-static int rtl8169_nway_reset(struct net_device *dev)
+static int rtl8168_nway_reset(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
return mii_nway_restart(&tp->mii);
}
@@ -2337,12 +2337,12 @@ static const struct rtl_coalesce_info rtl_coalesce_info_8168_8136[] = {
/* get rx/tx scale vector corresponding to current speed */
static const struct rtl_coalesce_info *rtl_coalesce_info(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
struct ethtool_link_ksettings ecmd;
const struct rtl_coalesce_info *ci;
int rc;
- rc = rtl8169_get_link_ksettings(dev, &ecmd);
+ rc = rtl8168_get_link_ksettings(dev, &ecmd);
if (rc < 0)
return ERR_PTR(rc);
@@ -2357,7 +2357,7 @@ static const struct rtl_coalesce_info *rtl_coalesce_info(struct net_device *dev)
static int rtl_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
const struct rtl_coalesce_info *ci;
const struct rtl_coalesce_scale *scale;
@@ -2427,7 +2427,7 @@ static const struct rtl_coalesce_scale *rtl_coalesce_choose_scale(
static int rtl_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
const struct rtl_coalesce_scale *scale;
struct {
@@ -2487,27 +2487,27 @@ static int rtl_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
return 0;
}
-static const struct ethtool_ops rtl8169_ethtool_ops = {
- .get_drvinfo = rtl8169_get_drvinfo,
- .get_regs_len = rtl8169_get_regs_len,
+static const struct ethtool_ops rtl8168_ethtool_ops = {
+ .get_drvinfo = rtl8168_get_drvinfo,
+ .get_regs_len = rtl8168_get_regs_len,
.get_link = ethtool_op_get_link,
.get_coalesce = rtl_get_coalesce,
.set_coalesce = rtl_set_coalesce,
- .get_msglevel = rtl8169_get_msglevel,
- .set_msglevel = rtl8169_set_msglevel,
- .get_regs = rtl8169_get_regs,
- .get_wol = rtl8169_get_wol,
- .set_wol = rtl8169_set_wol,
- .get_strings = rtl8169_get_strings,
- .get_sset_count = rtl8169_get_sset_count,
- .get_ethtool_stats = rtl8169_get_ethtool_stats,
+ .get_msglevel = rtl8168_get_msglevel,
+ .set_msglevel = rtl8168_set_msglevel,
+ .get_regs = rtl8168_get_regs,
+ .get_wol = rtl8168_get_wol,
+ .set_wol = rtl8168_set_wol,
+ .get_strings = rtl8168_get_strings,
+ .get_sset_count = rtl8168_get_sset_count,
+ .get_ethtool_stats = rtl8168_get_ethtool_stats,
.get_ts_info = ethtool_op_get_ts_info,
- .nway_reset = rtl8169_nway_reset,
- .get_link_ksettings = rtl8169_get_link_ksettings,
- .set_link_ksettings = rtl8169_set_link_ksettings,
+ .nway_reset = rtl8168_nway_reset,
+ .get_link_ksettings = rtl8168_get_link_ksettings,
+ .set_link_ksettings = rtl8168_set_link_ksettings,
};
-static void rtl8169_get_mac_version(struct rtl8169_private *tp,
+static void rtl8168_get_mac_version(struct rtl8168_private *tp,
struct net_device *dev, u8 default_version)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -2642,7 +2642,7 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp,
}
}
-static void rtl8169_print_mac_version(struct rtl8169_private *tp)
+static void rtl8168_print_mac_version(struct rtl8168_private *tp)
{
dprintk("mac_version = 0x%02x\n", tp->mac_version);
}
@@ -2652,7 +2652,7 @@ struct phy_reg {
u16 val;
};
-static void rtl_writephy_batch(struct rtl8169_private *tp,
+static void rtl_writephy_batch(struct rtl8168_private *tp,
const struct phy_reg *regs, int len)
{
while (len-- > 0) {
@@ -2685,7 +2685,7 @@ struct fw_info {
#define FW_OPCODE_SIZE sizeof(typeof(*((struct rtl_fw_phy_action *)0)->code))
-static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
+static bool rtl_fw_format_ok(struct rtl8168_private *tp, struct rtl_fw *rtl_fw)
{
const struct firmware *fw = rtl_fw->fw;
struct fw_info *fw_info = (struct fw_info *)fw->data;
@@ -2736,7 +2736,7 @@ static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
return rc;
}
-static bool rtl_fw_data_ok(struct rtl8169_private *tp, struct net_device *dev,
+static bool rtl_fw_data_ok(struct rtl8168_private *tp, struct net_device *dev,
struct rtl_fw_phy_action *pa)
{
bool rc = false;
@@ -2792,7 +2792,7 @@ static bool rtl_fw_data_ok(struct rtl8169_private *tp, struct net_device *dev,
return rc;
}
-static int rtl_check_firmware(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
+static int rtl_check_firmware(struct rtl8168_private *tp, struct rtl_fw *rtl_fw)
{
struct net_device *dev = tp->dev;
int rc = -EINVAL;
@@ -2808,7 +2808,7 @@ static int rtl_check_firmware(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
return rc;
}
-static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
+static void rtl_phy_write_fw(struct rtl8168_private *tp, struct rtl_fw *rtl_fw)
{
struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
struct mdio_ops org, *ops = &tp->mdio_ops;
@@ -2897,7 +2897,7 @@ static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
ops->read = org.read;
}
-static void rtl_release_firmware(struct rtl8169_private *tp)
+static void rtl_release_firmware(struct rtl8168_private *tp)
{
if (!IS_ERR_OR_NULL(tp->rtl_fw)) {
release_firmware(tp->rtl_fw->fw);
@@ -2906,7 +2906,7 @@ static void rtl_release_firmware(struct rtl8169_private *tp)
tp->rtl_fw = RTL_FIRMWARE_UNKNOWN;
}
-static void rtl_apply_firmware(struct rtl8169_private *tp)
+static void rtl_apply_firmware(struct rtl8168_private *tp)
{
struct rtl_fw *rtl_fw = tp->rtl_fw;
@@ -2915,7 +2915,7 @@ static void rtl_apply_firmware(struct rtl8169_private *tp)
rtl_phy_write_fw(tp, rtl_fw);
}
-static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 reg, u16 val)
+static void rtl_apply_firmware_cond(struct rtl8168_private *tp, u8 reg, u16 val)
{
if (rtl_readphy(tp, reg) != val)
netif_warn(tp, hw, tp->dev, "chipset not ready for firmware\n");
@@ -2923,7 +2923,7 @@ static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 reg, u16 val)
rtl_apply_firmware(tp);
}
-static void rtl8168bb_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168bb_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
{ 0x10, 0xf41b },
@@ -2936,7 +2936,7 @@ static void rtl8168bb_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
}
-static void rtl8168bef_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168bef_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
{ 0x1f, 0x0001 },
@@ -2947,7 +2947,7 @@ static void rtl8168bef_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
}
-static void rtl8168cp_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168cp_1_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
{ 0x1f, 0x0000 },
@@ -2960,7 +2960,7 @@ static void rtl8168cp_1_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
}
-static void rtl8168cp_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168cp_2_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
{ 0x1f, 0x0001 },
@@ -2975,7 +2975,7 @@ static void rtl8168cp_2_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
}
-static void rtl8168c_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168c_1_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
{ 0x1f, 0x0001 },
@@ -3004,7 +3004,7 @@ static void rtl8168c_1_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8168c_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168c_2_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
{ 0x1f, 0x0001 },
@@ -3032,7 +3032,7 @@ static void rtl8168c_2_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8168c_3_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168c_3_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
{ 0x1f, 0x0001 },
@@ -3054,12 +3054,12 @@ static void rtl8168c_3_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8168c_4_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168c_4_hw_phy_config(struct rtl8168_private *tp)
{
rtl8168c_3_hw_phy_config(tp);
}
-static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168d_1_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init_0[] = {
/* Channel Estimation */
@@ -3170,7 +3170,7 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168d_2_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init_0[] = {
/* Channel Estimation */
@@ -3272,7 +3272,7 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8168d_3_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168d_3_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
{ 0x1f, 0x0002 },
@@ -3333,7 +3333,7 @@ static void rtl8168d_3_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
}
-static void rtl8168d_4_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168d_4_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
{ 0x1f, 0x0001 },
@@ -3349,7 +3349,7 @@ static void rtl8168d_4_hw_phy_config(struct rtl8169_private *tp)
rtl_patchphy(tp, 0x0d, 1 << 5);
}
-static void rtl8168e_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168e_1_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
/* Enable Delay cap */
@@ -3422,7 +3422,7 @@ static void rtl8168e_1_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x0d, 0x0000);
}
-static void rtl_rar_exgmac_set(struct rtl8169_private *tp, u8 *addr)
+static void rtl_rar_exgmac_set(struct rtl8168_private *tp, u8 *addr)
{
const u16 w[] = {
addr[0] | (addr[1] << 8),
@@ -3439,7 +3439,7 @@ static void rtl_rar_exgmac_set(struct rtl8169_private *tp, u8 *addr)
rtl_write_exgmac_batch(tp, e, ARRAY_SIZE(e));
}
-static void rtl8168e_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168e_2_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
/* Enable Delay cap */
@@ -3531,7 +3531,7 @@ static void rtl8168e_2_hw_phy_config(struct rtl8169_private *tp)
rtl_rar_exgmac_set(tp, tp->dev->dev_addr);
}
-static void rtl8168f_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168f_hw_phy_config(struct rtl8168_private *tp)
{
/* For 4-corner performance improve */
rtl_writephy(tp, 0x1f, 0x0005);
@@ -3553,7 +3553,7 @@ static void rtl8168f_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8168f_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168f_1_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
/* Channel estimation fine tune */
@@ -3603,14 +3603,14 @@ static void rtl8168f_1_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8168f_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168f_2_hw_phy_config(struct rtl8168_private *tp)
{
rtl_apply_firmware(tp);
rtl8168f_hw_phy_config(tp);
}
-static void rtl8411_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8411_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
/* Channel estimation fine tune */
@@ -3707,7 +3707,7 @@ static void rtl8411_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8168g_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168g_1_hw_phy_config(struct rtl8168_private *tp)
{
rtl_apply_firmware(tp);
@@ -3773,12 +3773,12 @@ static void rtl8168g_1_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8168g_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168g_2_hw_phy_config(struct rtl8168_private *tp)
{
rtl_apply_firmware(tp);
}
-static void rtl8168h_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168h_1_hw_phy_config(struct rtl8168_private *tp)
{
u16 dout_tapbin;
u32 data;
@@ -3888,7 +3888,7 @@ static void rtl8168h_1_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8168h_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168h_2_hw_phy_config(struct rtl8168_private *tp)
{
u16 ioffset_p3, ioffset_p2, ioffset_p1, ioffset_p0;
u16 rlen;
@@ -3961,7 +3961,7 @@ static void rtl8168h_2_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8168ep_1_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168ep_1_hw_phy_config(struct rtl8168_private *tp)
{
/* Enable PHY auto speed down */
rtl_writephy(tp, 0x1f, 0x0a44);
@@ -4003,7 +4003,7 @@ static void rtl8168ep_1_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8168ep_2_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8168ep_2_hw_phy_config(struct rtl8168_private *tp)
{
/* patch 10M & ALDPS */
rtl_writephy(tp, 0x1f, 0x0bcc);
@@ -4094,7 +4094,7 @@ static void rtl8168ep_2_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8102e_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8102e_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
{ 0x1f, 0x0003 },
@@ -4111,7 +4111,7 @@ static void rtl8102e_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
}
-static void rtl8105e_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8105e_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
{ 0x1f, 0x0005 },
@@ -4137,7 +4137,7 @@ static void rtl8105e_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
}
-static void rtl8402_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8402_hw_phy_config(struct rtl8168_private *tp)
{
/* Disable ALDPS before setting firmware */
rtl_writephy(tp, 0x1f, 0x0000);
@@ -4154,7 +4154,7 @@ static void rtl8402_hw_phy_config(struct rtl8169_private *tp)
rtl_writephy(tp, 0x1f, 0x0000);
}
-static void rtl8106e_hw_phy_config(struct rtl8169_private *tp)
+static void rtl8106e_hw_phy_config(struct rtl8168_private *tp)
{
static const struct phy_reg phy_reg_init[] = {
{ 0x1f, 0x0004 },
@@ -4178,9 +4178,9 @@ static void rtl8106e_hw_phy_config(struct rtl8169_private *tp)
static void rtl_hw_phy_config(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
- rtl8169_print_mac_version(tp);
+ rtl8168_print_mac_version(tp);
switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_07:
@@ -4292,15 +4292,15 @@ static void rtl_hw_phy_config(struct net_device *dev)
}
}
-static void rtl_phy_work(struct rtl8169_private *tp)
+static void rtl_phy_work(struct rtl8168_private *tp)
{
struct timer_list *timer = &tp->timer;
void __iomem *ioaddr = tp->mmio_addr;
- unsigned long timeout = RTL8169_PHY_TIMEOUT;
+ unsigned long timeout = RTL8168_PHY_TIMEOUT;
assert(tp->mac_version > RTL_GIGA_MAC_VER_01);
- if (rtl8169_xmii_reset_pending(tp)) {
+ if (rtl8168_xmii_reset_pending(tp)) {
/*
* A busy loop could burn quite a few cycles on nowadays CPU.
* Let's delay the execution of the timer for a few ticks.
@@ -4309,51 +4309,51 @@ static void rtl_phy_work(struct rtl8169_private *tp)
goto out_mod_timer;
}
- if (rtl8169_xmii_link_ok(ioaddr))
+ if (rtl8168_xmii_link_ok(ioaddr))
return;
netif_dbg(tp, link, tp->dev, "PHY reset until link up\n");
- rtl8169_xmii_reset_enable(tp);
+ rtl8168_xmii_reset_enable(tp);
out_mod_timer:
mod_timer(timer, jiffies + timeout);
}
-static void rtl_schedule_task(struct rtl8169_private *tp, enum rtl_flag flag)
+static void rtl_schedule_task(struct rtl8168_private *tp, enum rtl_flag flag)
{
if (!test_and_set_bit(flag, tp->wk.flags))
schedule_work(&tp->wk.work);
}
-static void rtl8169_phy_timer(struct timer_list *t)
+static void rtl8168_phy_timer(struct timer_list *t)
{
- struct rtl8169_private *tp = from_timer(tp, t, timer);
+ struct rtl8168_private *tp = from_timer(tp, t, timer);
rtl_schedule_task(tp, RTL_FLAG_TASK_PHY_PENDING);
}
DECLARE_RTL_COND(rtl_phy_reset_cond)
{
- return rtl8169_xmii_reset_pending(tp);
+ return rtl8168_xmii_reset_pending(tp);
}
-static void rtl8169_phy_reset(struct net_device *dev,
- struct rtl8169_private *tp)
+static void rtl8168_phy_reset(struct net_device *dev,
+ struct rtl8168_private *tp)
{
- rtl8169_xmii_reset_enable(tp);
+ rtl8168_xmii_reset_enable(tp);
rtl_msleep_loop_wait_low(tp, &rtl_phy_reset_cond, 1, 100);
}
-static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
+static void rtl8168_init_phy(struct net_device *dev, struct rtl8168_private *tp)
{
rtl_hw_phy_config(dev);
pci_write_config_byte(tp->pci_dev, PCI_LATENCY_TIMER, 0x40);
- rtl8169_phy_reset(dev, tp);
+ rtl8168_phy_reset(dev, tp);
- rtl8169_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
+ rtl8168_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
(tp->mii.supports_gmii ?
@@ -4361,7 +4361,7 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
ADVERTISED_1000baseT_Full : 0));
}
-static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
+static void rtl_rar_set(struct rtl8168_private *tp, u8 *addr)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4385,7 +4385,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
static int rtl_set_mac_address(struct net_device *dev, void *p)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
struct device *d = &tp->pci_dev->dev;
struct sockaddr *addr = p;
@@ -4404,7 +4404,7 @@ static int rtl_set_mac_address(struct net_device *dev, void *p)
return 0;
}
-static int rtl_xmii_ioctl(struct rtl8169_private *tp,
+static int rtl_xmii_ioctl(struct rtl8168_private *tp,
struct mii_ioctl_data *data, int cmd)
{
switch (cmd) {
@@ -4423,15 +4423,15 @@ static int rtl_xmii_ioctl(struct rtl8169_private *tp,
return -EOPNOTSUPP;
}
-static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+static int rtl8168_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
struct mii_ioctl_data *data = if_mii(ifr);
return netif_running(dev) ? rtl_xmii_ioctl(tp, data, cmd) : -ENODEV;
}
-static void rtl_init_mdio_ops(struct rtl8169_private *tp)
+static void rtl_init_mdio_ops(struct rtl8168_private *tp)
{
struct mdio_ops *ops = &tp->mdio_ops;
@@ -4461,13 +4461,13 @@ static void rtl_init_mdio_ops(struct rtl8169_private *tp)
ops->read = r8168g_mdio_read;
break;
default:
- ops->write = r8169_mdio_write;
- ops->read = r8169_mdio_read;
+ ops->write = r8168_mdio_write;
+ ops->read = r8168_mdio_read;
break;
}
}
-static void rtl_speed_down(struct rtl8169_private *tp)
+static void rtl_speed_down(struct rtl8168_private *tp)
{
u32 adv;
int lpa;
@@ -4487,11 +4487,11 @@ static void rtl_speed_down(struct rtl8169_private *tp)
ADVERTISED_1000baseT_Half |
ADVERTISED_1000baseT_Full : 0);
- rtl8169_set_speed(tp->dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
+ rtl8168_set_speed(tp->dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL,
adv);
}
-static void rtl_wol_suspend_quirk(struct rtl8169_private *tp)
+static void rtl_wol_suspend_quirk(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4526,9 +4526,9 @@ static void rtl_wol_suspend_quirk(struct rtl8169_private *tp)
}
}
-static bool rtl_wol_pll_power_down(struct rtl8169_private *tp)
+static bool rtl_wol_pll_power_down(struct rtl8168_private *tp)
{
- if (!(__rtl8169_get_wol(tp) & WAKE_ANY))
+ if (!(__rtl8168_get_wol(tp) & WAKE_ANY))
return false;
rtl_speed_down(tp);
@@ -4537,19 +4537,19 @@ static bool rtl_wol_pll_power_down(struct rtl8169_private *tp)
return true;
}
-static void r810x_phy_power_down(struct rtl8169_private *tp)
+static void r810x_phy_power_down(struct rtl8168_private *tp)
{
rtl_writephy(tp, 0x1f, 0x0000);
rtl_writephy(tp, MII_BMCR, BMCR_PDOWN);
}
-static void r810x_phy_power_up(struct rtl8169_private *tp)
+static void r810x_phy_power_up(struct rtl8168_private *tp)
{
rtl_writephy(tp, 0x1f, 0x0000);
rtl_writephy(tp, MII_BMCR, BMCR_ANENABLE);
}
-static void r810x_pll_power_down(struct rtl8169_private *tp)
+static void r810x_pll_power_down(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4572,7 +4572,7 @@ static void r810x_pll_power_down(struct rtl8169_private *tp)
}
}
-static void r810x_pll_power_up(struct rtl8169_private *tp)
+static void r810x_pll_power_up(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4596,7 +4596,7 @@ static void r810x_pll_power_up(struct rtl8169_private *tp)
}
}
-static void r8168_phy_power_up(struct rtl8169_private *tp)
+static void r8168_phy_power_up(struct rtl8168_private *tp)
{
rtl_writephy(tp, 0x1f, 0x0000);
switch (tp->mac_version) {
@@ -4623,7 +4623,7 @@ static void r8168_phy_power_up(struct rtl8169_private *tp)
rtl_writephy(tp, MII_BMCR, BMCR_ANENABLE);
}
-static void r8168_phy_power_down(struct rtl8169_private *tp)
+static void r8168_phy_power_down(struct rtl8168_private *tp)
{
rtl_writephy(tp, 0x1f, 0x0000);
switch (tp->mac_version) {
@@ -4656,7 +4656,7 @@ static void r8168_phy_power_down(struct rtl8169_private *tp)
}
}
-static void r8168_pll_power_down(struct rtl8169_private *tp)
+static void r8168_pll_power_down(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4710,7 +4710,7 @@ static void r8168_pll_power_down(struct rtl8169_private *tp)
}
}
-static void r8168_pll_power_up(struct rtl8169_private *tp)
+static void r8168_pll_power_up(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4743,24 +4743,24 @@ static void r8168_pll_power_up(struct rtl8169_private *tp)
r8168_phy_power_up(tp);
}
-static void rtl_generic_op(struct rtl8169_private *tp,
- void (*op)(struct rtl8169_private *))
+static void rtl_generic_op(struct rtl8168_private *tp,
+ void (*op)(struct rtl8168_private *))
{
if (op)
op(tp);
}
-static void rtl_pll_power_down(struct rtl8169_private *tp)
+static void rtl_pll_power_down(struct rtl8168_private *tp)
{
rtl_generic_op(tp, tp->pll_power_ops.down);
}
-static void rtl_pll_power_up(struct rtl8169_private *tp)
+static void rtl_pll_power_up(struct rtl8168_private *tp)
{
rtl_generic_op(tp, tp->pll_power_ops.up);
}
-static void rtl_init_pll_power_ops(struct rtl8169_private *tp)
+static void rtl_init_pll_power_ops(struct rtl8168_private *tp)
{
struct pll_power_ops *ops = &tp->pll_power_ops;
@@ -4822,7 +4822,7 @@ static void rtl_init_pll_power_ops(struct rtl8169_private *tp)
}
}
-static void rtl_init_rxcfg(struct rtl8169_private *tp)
+static void rtl_init_rxcfg(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4868,12 +4868,12 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)
}
}
-static void rtl8169_init_ring_indexes(struct rtl8169_private *tp)
+static void rtl8168_init_ring_indexes(struct rtl8168_private *tp)
{
tp->dirty_tx = tp->cur_tx = tp->cur_rx = 0;
}
-static void rtl_hw_jumbo_enable(struct rtl8169_private *tp)
+static void rtl_hw_jumbo_enable(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4882,7 +4882,7 @@ static void rtl_hw_jumbo_enable(struct rtl8169_private *tp)
RTL_W8(Cfg9346, Cfg9346_Lock);
}
-static void rtl_hw_jumbo_disable(struct rtl8169_private *tp)
+static void rtl_hw_jumbo_disable(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4891,7 +4891,7 @@ static void rtl_hw_jumbo_disable(struct rtl8169_private *tp)
RTL_W8(Cfg9346, Cfg9346_Lock);
}
-static void r8168c_hw_jumbo_enable(struct rtl8169_private *tp)
+static void r8168c_hw_jumbo_enable(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4900,7 +4900,7 @@ static void r8168c_hw_jumbo_enable(struct rtl8169_private *tp)
rtl_tx_performance_tweak(tp->pci_dev, PCI_EXP_DEVCTL_READRQ_512B);
}
-static void r8168c_hw_jumbo_disable(struct rtl8169_private *tp)
+static void r8168c_hw_jumbo_disable(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4909,21 +4909,21 @@ static void r8168c_hw_jumbo_disable(struct rtl8169_private *tp)
rtl_tx_performance_tweak(tp->pci_dev, 0x5 << MAX_READ_REQUEST_SHIFT);
}
-static void r8168dp_hw_jumbo_enable(struct rtl8169_private *tp)
+static void r8168dp_hw_jumbo_enable(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
RTL_W8(Config3, RTL_R8(Config3) | Jumbo_En0);
}
-static void r8168dp_hw_jumbo_disable(struct rtl8169_private *tp)
+static void r8168dp_hw_jumbo_disable(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
RTL_W8(Config3, RTL_R8(Config3) & ~Jumbo_En0);
}
-static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp)
+static void r8168e_hw_jumbo_enable(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4933,7 +4933,7 @@ static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp)
rtl_tx_performance_tweak(tp->pci_dev, PCI_EXP_DEVCTL_READRQ_512B);
}
-static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp)
+static void r8168e_hw_jumbo_disable(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4943,19 +4943,19 @@ static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp)
rtl_tx_performance_tweak(tp->pci_dev, 0x5 << MAX_READ_REQUEST_SHIFT);
}
-static void r8168b_0_hw_jumbo_enable(struct rtl8169_private *tp)
+static void r8168b_0_hw_jumbo_enable(struct rtl8168_private *tp)
{
rtl_tx_performance_tweak(tp->pci_dev,
PCI_EXP_DEVCTL_READRQ_512B | PCI_EXP_DEVCTL_NOSNOOP_EN);
}
-static void r8168b_0_hw_jumbo_disable(struct rtl8169_private *tp)
+static void r8168b_0_hw_jumbo_disable(struct rtl8168_private *tp)
{
rtl_tx_performance_tweak(tp->pci_dev,
(0x5 << MAX_READ_REQUEST_SHIFT) | PCI_EXP_DEVCTL_NOSNOOP_EN);
}
-static void r8168b_1_hw_jumbo_enable(struct rtl8169_private *tp)
+static void r8168b_1_hw_jumbo_enable(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4964,7 +4964,7 @@ static void r8168b_1_hw_jumbo_enable(struct rtl8169_private *tp)
RTL_W8(Config4, RTL_R8(Config4) | (1 << 0));
}
-static void r8168b_1_hw_jumbo_disable(struct rtl8169_private *tp)
+static void r8168b_1_hw_jumbo_disable(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -4973,7 +4973,7 @@ static void r8168b_1_hw_jumbo_disable(struct rtl8169_private *tp)
RTL_W8(Config4, RTL_R8(Config4) & ~(1 << 0));
}
-static void rtl_init_jumbo_ops(struct rtl8169_private *tp)
+static void rtl_init_jumbo_ops(struct rtl8168_private *tp)
{
struct jumbo_ops *ops = &tp->jumbo_ops;
@@ -5042,7 +5042,7 @@ DECLARE_RTL_COND(rtl_chipcmd_cond)
return RTL_R8(ChipCmd) & CmdReset;
}
-static void rtl_hw_reset(struct rtl8169_private *tp)
+static void rtl_hw_reset(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -5051,7 +5051,7 @@ static void rtl_hw_reset(struct rtl8169_private *tp)
rtl_udelay_loop_wait_low(tp, &rtl_chipcmd_cond, 100, 100);
}
-static void rtl_request_uncached_firmware(struct rtl8169_private *tp)
+static void rtl_request_uncached_firmware(struct rtl8168_private *tp)
{
struct rtl_fw *rtl_fw;
const char *name;
@@ -5089,13 +5089,13 @@ static void rtl_request_uncached_firmware(struct rtl8169_private *tp)
goto out;
}
-static void rtl_request_firmware(struct rtl8169_private *tp)
+static void rtl_request_firmware(struct rtl8168_private *tp)
{
if (IS_ERR(tp->rtl_fw))
rtl_request_uncached_firmware(tp);
}
-static void rtl_rx_close(struct rtl8169_private *tp)
+static void rtl_rx_close(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -5116,12 +5116,12 @@ DECLARE_RTL_COND(rtl_txcfg_empty_cond)
return RTL_R32(TxConfig) & TXCFG_EMPTY;
}
-static void rtl8169_hw_reset(struct rtl8169_private *tp)
+static void rtl8168_hw_reset(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
/* Disable interrupts */
- rtl8169_irq_mask_and_ack(tp);
+ rtl8168_irq_mask_and_ack(tp);
rtl_rx_close(tp);
@@ -5156,7 +5156,7 @@ static void rtl8169_hw_reset(struct rtl8169_private *tp)
rtl_hw_reset(tp);
}
-static void rtl_set_rx_tx_config_registers(struct rtl8169_private *tp)
+static void rtl_set_rx_tx_config_registers(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -5167,14 +5167,14 @@ static void rtl_set_rx_tx_config_registers(struct rtl8169_private *tp)
static void rtl_hw_start(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
tp->hw_start(dev);
rtl_irq_enable_all(tp);
}
-static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp,
+static void rtl_set_rx_tx_desc_registers(struct rtl8168_private *tp,
void __iomem *ioaddr)
{
/*
@@ -5205,7 +5205,7 @@ static void rtl_set_rx_max_size(void __iomem *ioaddr, unsigned int rx_buf_sz)
static void rtl_set_rx_mode(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
u32 mc_filter[2]; /* Multicast hash filter */
int rx_mode;
@@ -5255,7 +5255,7 @@ static void rtl_set_rx_mode(struct net_device *dev)
static void rtl_hw_start_8169(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
RTL_W8(Cfg9346, Cfg9346_Unlock);
@@ -5291,18 +5291,18 @@ static void rtl_hw_start_8169(struct net_device *dev)
RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xf000);
}
-static void rtl_csi_write(struct rtl8169_private *tp, int addr, int value)
+static void rtl_csi_write(struct rtl8168_private *tp, int addr, int value)
{
if (tp->csi_ops.write)
tp->csi_ops.write(tp, addr, value);
}
-static u32 rtl_csi_read(struct rtl8169_private *tp, int addr)
+static u32 rtl_csi_read(struct rtl8168_private *tp, int addr)
{
return tp->csi_ops.read ? tp->csi_ops.read(tp, addr) : ~0;
}
-static void rtl_csi_access_enable(struct rtl8169_private *tp, u32 bits)
+static void rtl_csi_access_enable(struct rtl8168_private *tp, u32 bits)
{
u32 csi;
@@ -5310,12 +5310,12 @@ static void rtl_csi_access_enable(struct rtl8169_private *tp, u32 bits)
rtl_csi_write(tp, 0x070c, csi | bits);
}
-static void rtl_csi_access_enable_1(struct rtl8169_private *tp)
+static void rtl_csi_access_enable_1(struct rtl8168_private *tp)
{
rtl_csi_access_enable(tp, 0x17000000);
}
-static void rtl_csi_access_enable_2(struct rtl8169_private *tp)
+static void rtl_csi_access_enable_2(struct rtl8168_private *tp)
{
rtl_csi_access_enable(tp, 0x27000000);
}
@@ -5327,7 +5327,7 @@ DECLARE_RTL_COND(rtl_csiar_cond)
return RTL_R32(CSIAR) & CSIAR_FLAG;
}
-static void r8169_csi_write(struct rtl8169_private *tp, int addr, int value)
+static void r8168_csi_write(struct rtl8168_private *tp, int addr, int value)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -5338,7 +5338,7 @@ static void r8169_csi_write(struct rtl8169_private *tp, int addr, int value)
rtl_udelay_loop_wait_low(tp, &rtl_csiar_cond, 10, 100);
}
-static u32 r8169_csi_read(struct rtl8169_private *tp, int addr)
+static u32 r8168_csi_read(struct rtl8168_private *tp, int addr)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -5349,7 +5349,7 @@ static u32 r8169_csi_read(struct rtl8169_private *tp, int addr)
RTL_R32(CSIDR) : ~0;
}
-static void r8402_csi_write(struct rtl8169_private *tp, int addr, int value)
+static void r8402_csi_write(struct rtl8168_private *tp, int addr, int value)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -5361,7 +5361,7 @@ static void r8402_csi_write(struct rtl8169_private *tp, int addr, int value)
rtl_udelay_loop_wait_low(tp, &rtl_csiar_cond, 10, 100);
}
-static u32 r8402_csi_read(struct rtl8169_private *tp, int addr)
+static u32 r8402_csi_read(struct rtl8168_private *tp, int addr)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -5372,7 +5372,7 @@ static u32 r8402_csi_read(struct rtl8169_private *tp, int addr)
RTL_R32(CSIDR) : ~0;
}
-static void r8411_csi_write(struct rtl8169_private *tp, int addr, int value)
+static void r8411_csi_write(struct rtl8168_private *tp, int addr, int value)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -5384,7 +5384,7 @@ static void r8411_csi_write(struct rtl8169_private *tp, int addr, int value)
rtl_udelay_loop_wait_low(tp, &rtl_csiar_cond, 10, 100);
}
-static u32 r8411_csi_read(struct rtl8169_private *tp, int addr)
+static u32 r8411_csi_read(struct rtl8168_private *tp, int addr)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -5395,7 +5395,7 @@ static u32 r8411_csi_read(struct rtl8169_private *tp, int addr)
RTL_R32(CSIDR) : ~0;
}
-static void rtl_init_csi_ops(struct rtl8169_private *tp)
+static void rtl_init_csi_ops(struct rtl8168_private *tp)
{
struct csi_ops *ops = &tp->csi_ops;
@@ -5424,8 +5424,8 @@ static void rtl_init_csi_ops(struct rtl8169_private *tp)
break;
default:
- ops->write = r8169_csi_write;
- ops->read = r8169_csi_read;
+ ops->write = r8168_csi_write;
+ ops->read = r8168_csi_read;
break;
}
}
@@ -5436,7 +5436,7 @@ struct ephy_info {
u16 bits;
};
-static void rtl_ephy_init(struct rtl8169_private *tp, const struct ephy_info *e,
+static void rtl_ephy_init(struct rtl8168_private *tp, const struct ephy_info *e,
int len)
{
u16 w;
@@ -5460,7 +5460,7 @@ static void rtl_enable_clock_request(struct pci_dev *pdev)
PCI_EXP_LNKCTL_CLKREQ_EN);
}
-static void rtl_pcie_state_l2l3_enable(struct rtl8169_private *tp, bool enable)
+static void rtl_pcie_state_l2l3_enable(struct rtl8168_private *tp, bool enable)
{
void __iomem *ioaddr = tp->mmio_addr;
u8 data;
@@ -5486,7 +5486,7 @@ static void rtl_pcie_state_l2l3_enable(struct rtl8169_private *tp, bool enable)
PktCntrDisable | \
Mac_dbgo_sel)
-static void rtl_hw_start_8168bb(struct rtl8169_private *tp)
+static void rtl_hw_start_8168bb(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -5501,7 +5501,7 @@ static void rtl_hw_start_8168bb(struct rtl8169_private *tp)
}
}
-static void rtl_hw_start_8168bef(struct rtl8169_private *tp)
+static void rtl_hw_start_8168bef(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -5512,7 +5512,7 @@ static void rtl_hw_start_8168bef(struct rtl8169_private *tp)
RTL_W8(Config4, RTL_R8(Config4) & ~(1 << 0));
}
-static void __rtl_hw_start_8168cp(struct rtl8169_private *tp)
+static void __rtl_hw_start_8168cp(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -5529,7 +5529,7 @@ static void __rtl_hw_start_8168cp(struct rtl8169_private *tp)
RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK);
}
-static void rtl_hw_start_8168cp_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168cp_1(struct rtl8168_private *tp)
{
static const struct ephy_info e_info_8168cp[] = {
{ 0x01, 0, 0x0001 },
@@ -5546,7 +5546,7 @@ static void rtl_hw_start_8168cp_1(struct rtl8169_private *tp)
__rtl_hw_start_8168cp(tp);
}
-static void rtl_hw_start_8168cp_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8168cp_2(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -5561,7 +5561,7 @@ static void rtl_hw_start_8168cp_2(struct rtl8169_private *tp)
RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK);
}
-static void rtl_hw_start_8168cp_3(struct rtl8169_private *tp)
+static void rtl_hw_start_8168cp_3(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -5581,7 +5581,7 @@ static void rtl_hw_start_8168cp_3(struct rtl8169_private *tp)
RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK);
}
-static void rtl_hw_start_8168c_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168c_1(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
static const struct ephy_info e_info_8168c_1[] = {
@@ -5599,7 +5599,7 @@ static void rtl_hw_start_8168c_1(struct rtl8169_private *tp)
__rtl_hw_start_8168cp(tp);
}
-static void rtl_hw_start_8168c_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8168c_2(struct rtl8168_private *tp)
{
static const struct ephy_info e_info_8168c_2[] = {
{ 0x01, 0, 0x0001 },
@@ -5613,19 +5613,19 @@ static void rtl_hw_start_8168c_2(struct rtl8169_private *tp)
__rtl_hw_start_8168cp(tp);
}
-static void rtl_hw_start_8168c_3(struct rtl8169_private *tp)
+static void rtl_hw_start_8168c_3(struct rtl8168_private *tp)
{
rtl_hw_start_8168c_2(tp);
}
-static void rtl_hw_start_8168c_4(struct rtl8169_private *tp)
+static void rtl_hw_start_8168c_4(struct rtl8168_private *tp)
{
rtl_csi_access_enable_2(tp);
__rtl_hw_start_8168cp(tp);
}
-static void rtl_hw_start_8168d(struct rtl8169_private *tp)
+static void rtl_hw_start_8168d(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -5642,7 +5642,7 @@ static void rtl_hw_start_8168d(struct rtl8169_private *tp)
RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK);
}
-static void rtl_hw_start_8168dp(struct rtl8169_private *tp)
+static void rtl_hw_start_8168dp(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -5657,7 +5657,7 @@ static void rtl_hw_start_8168dp(struct rtl8169_private *tp)
rtl_disable_clock_request(pdev);
}
-static void rtl_hw_start_8168d_4(struct rtl8169_private *tp)
+static void rtl_hw_start_8168d_4(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -5678,7 +5678,7 @@ static void rtl_hw_start_8168d_4(struct rtl8169_private *tp)
rtl_enable_clock_request(pdev);
}
-static void rtl_hw_start_8168e_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168e_1(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -5716,7 +5716,7 @@ static void rtl_hw_start_8168e_1(struct rtl8169_private *tp)
RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en);
}
-static void rtl_hw_start_8168e_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8168e_2(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -5756,7 +5756,7 @@ static void rtl_hw_start_8168e_2(struct rtl8169_private *tp)
RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en);
}
-static void rtl_hw_start_8168f(struct rtl8169_private *tp)
+static void rtl_hw_start_8168f(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -5787,7 +5787,7 @@ static void rtl_hw_start_8168f(struct rtl8169_private *tp)
RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en);
}
-static void rtl_hw_start_8168f_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168f_1(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
static const struct ephy_info e_info_8168f_1[] = {
@@ -5807,7 +5807,7 @@ static void rtl_hw_start_8168f_1(struct rtl8169_private *tp)
RTL_W8(EEE_LED, RTL_R8(EEE_LED) & ~0x07);
}
-static void rtl_hw_start_8411(struct rtl8169_private *tp)
+static void rtl_hw_start_8411(struct rtl8168_private *tp)
{
static const struct ephy_info e_info_8168f_1[] = {
{ 0x06, 0x00c0, 0x0020 },
@@ -5824,7 +5824,7 @@ static void rtl_hw_start_8411(struct rtl8169_private *tp)
rtl_w0w1_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0c00, 0x0000, ERIAR_EXGMAC);
}
-static void rtl_hw_start_8168g(struct rtl8169_private *tp)
+static void rtl_hw_start_8168g(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -5859,7 +5859,7 @@ static void rtl_hw_start_8168g(struct rtl8169_private *tp)
rtl_pcie_state_l2l3_enable(tp, false);
}
-static void rtl_hw_start_8168g_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168g_1(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
static const struct ephy_info e_info_8168g_1[] = {
@@ -5877,7 +5877,7 @@ static void rtl_hw_start_8168g_1(struct rtl8169_private *tp)
rtl_ephy_init(tp, e_info_8168g_1, ARRAY_SIZE(e_info_8168g_1));
}
-static void rtl_hw_start_8168g_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8168g_2(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
static const struct ephy_info e_info_8168g_2[] = {
@@ -5895,7 +5895,7 @@ static void rtl_hw_start_8168g_2(struct rtl8169_private *tp)
rtl_ephy_init(tp, e_info_8168g_2, ARRAY_SIZE(e_info_8168g_2));
}
-static void rtl_hw_start_8411_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8411_2(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
static const struct ephy_info e_info_8411_2[] = {
@@ -5914,7 +5914,7 @@ static void rtl_hw_start_8411_2(struct rtl8169_private *tp)
rtl_ephy_init(tp, e_info_8411_2, ARRAY_SIZE(e_info_8411_2));
}
-static void rtl_hw_start_8168h_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168h_1(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -6012,7 +6012,7 @@ static void rtl_hw_start_8168h_1(struct rtl8169_private *tp)
r8168_mac_ocp_write(tp, 0xc09e, 0x0000);
}
-static void rtl_hw_start_8168ep(struct rtl8169_private *tp)
+static void rtl_hw_start_8168ep(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -6053,7 +6053,7 @@ static void rtl_hw_start_8168ep(struct rtl8169_private *tp)
rtl_pcie_state_l2l3_enable(tp, false);
}
-static void rtl_hw_start_8168ep_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8168ep_1(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
static const struct ephy_info e_info_8168ep_1[] = {
@@ -6072,7 +6072,7 @@ static void rtl_hw_start_8168ep_1(struct rtl8169_private *tp)
rtl_hw_start_8168ep(tp);
}
-static void rtl_hw_start_8168ep_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8168ep_2(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
static const struct ephy_info e_info_8168ep_2[] = {
@@ -6092,7 +6092,7 @@ static void rtl_hw_start_8168ep_2(struct rtl8169_private *tp)
RTL_W8(MISC_1, RTL_R8(MISC_1) & ~PFM_D3COLD_EN);
}
-static void rtl_hw_start_8168ep_3(struct rtl8169_private *tp)
+static void rtl_hw_start_8168ep_3(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
u32 data;
@@ -6129,7 +6129,7 @@ static void rtl_hw_start_8168ep_3(struct rtl8169_private *tp)
static void rtl_hw_start_8168(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
RTL_W8(Cfg9346, Cfg9346_Unlock);
@@ -6280,7 +6280,7 @@ static void rtl_hw_start_8168(struct net_device *dev)
PktCntrDisable | \
Mac_dbgo_sel)
-static void rtl_hw_start_8102e_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8102e_1(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -6313,7 +6313,7 @@ static void rtl_hw_start_8102e_1(struct rtl8169_private *tp)
rtl_ephy_init(tp, e_info_8102e_1, ARRAY_SIZE(e_info_8102e_1));
}
-static void rtl_hw_start_8102e_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8102e_2(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -6326,14 +6326,14 @@ static void rtl_hw_start_8102e_2(struct rtl8169_private *tp)
RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en);
}
-static void rtl_hw_start_8102e_3(struct rtl8169_private *tp)
+static void rtl_hw_start_8102e_3(struct rtl8168_private *tp)
{
rtl_hw_start_8102e_2(tp);
rtl_ephy_write(tp, 0x03, 0xc2f9);
}
-static void rtl_hw_start_8105e_1(struct rtl8169_private *tp)
+static void rtl_hw_start_8105e_1(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
static const struct ephy_info e_info_8105e_1[] = {
@@ -6361,13 +6361,13 @@ static void rtl_hw_start_8105e_1(struct rtl8169_private *tp)
rtl_pcie_state_l2l3_enable(tp, false);
}
-static void rtl_hw_start_8105e_2(struct rtl8169_private *tp)
+static void rtl_hw_start_8105e_2(struct rtl8168_private *tp)
{
rtl_hw_start_8105e_1(tp);
rtl_ephy_write(tp, 0x1e, rtl_ephy_read(tp, 0x1e) | 0x8000);
}
-static void rtl_hw_start_8402(struct rtl8169_private *tp)
+static void rtl_hw_start_8402(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
static const struct ephy_info e_info_8402[] = {
@@ -6398,7 +6398,7 @@ static void rtl_hw_start_8402(struct rtl8169_private *tp)
rtl_pcie_state_l2l3_enable(tp, false);
}
-static void rtl_hw_start_8106(struct rtl8169_private *tp)
+static void rtl_hw_start_8106(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -6414,7 +6414,7 @@ static void rtl_hw_start_8106(struct rtl8169_private *tp)
static void rtl_hw_start_8101(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
@@ -6488,9 +6488,9 @@ static void rtl_hw_start_8101(struct net_device *dev)
RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xf000);
}
-static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
+static int rtl8168_change_mtu(struct net_device *dev, int new_mtu)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
if (new_mtu > ETH_DATA_LEN)
rtl_hw_jumbo_enable(tp);
@@ -6503,13 +6503,13 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
return 0;
}
-static inline void rtl8169_make_unusable_by_asic(struct RxDesc *desc)
+static inline void rtl8168_make_unusable_by_asic(struct RxDesc *desc)
{
desc->addr = cpu_to_le64(0x0badbadbadbadbadull);
desc->opts1 &= ~cpu_to_le32(DescOwn | RsvdMask);
}
-static void rtl8169_free_rx_databuff(struct rtl8169_private *tp,
+static void rtl8168_free_rx_databuff(struct rtl8168_private *tp,
void **data_buff, struct RxDesc *desc)
{
dma_unmap_single(&tp->pci_dev->dev, le64_to_cpu(desc->addr), rx_buf_sz,
@@ -6517,10 +6517,10 @@ static void rtl8169_free_rx_databuff(struct rtl8169_private *tp,
kfree(*data_buff);
*data_buff = NULL;
- rtl8169_make_unusable_by_asic(desc);
+ rtl8168_make_unusable_by_asic(desc);
}
-static inline void rtl8169_mark_to_asic(struct RxDesc *desc, u32 rx_buf_sz)
+static inline void rtl8168_mark_to_asic(struct RxDesc *desc, u32 rx_buf_sz)
{
u32 eor = le32_to_cpu(desc->opts1) & RingEnd;
@@ -6530,19 +6530,19 @@ static inline void rtl8169_mark_to_asic(struct RxDesc *desc, u32 rx_buf_sz)
desc->opts1 = cpu_to_le32(DescOwn | eor | rx_buf_sz);
}
-static inline void rtl8169_map_to_asic(struct RxDesc *desc, dma_addr_t mapping,
+static inline void rtl8168_map_to_asic(struct RxDesc *desc, dma_addr_t mapping,
u32 rx_buf_sz)
{
desc->addr = cpu_to_le64(mapping);
- rtl8169_mark_to_asic(desc, rx_buf_sz);
+ rtl8168_mark_to_asic(desc, rx_buf_sz);
}
-static inline void *rtl8169_align(void *data)
+static inline void *rtl8168_align(void *data)
{
return (void *)ALIGN((long)data, 16);
}
-static struct sk_buff *rtl8169_alloc_rx_data(struct rtl8169_private *tp,
+static struct sk_buff *rtl8168_alloc_rx_data(struct rtl8168_private *tp,
struct RxDesc *desc)
{
void *data;
@@ -6555,14 +6555,14 @@ static struct sk_buff *rtl8169_alloc_rx_data(struct rtl8169_private *tp,
if (!data)
return NULL;
- if (rtl8169_align(data) != data) {
+ if (rtl8168_align(data) != data) {
kfree(data);
data = kmalloc_node(rx_buf_sz + 15, GFP_KERNEL, node);
if (!data)
return NULL;
}
- mapping = dma_map_single(d, rtl8169_align(data), rx_buf_sz,
+ mapping = dma_map_single(d, rtl8168_align(data), rx_buf_sz,
DMA_FROM_DEVICE);
if (unlikely(dma_mapping_error(d, mapping))) {
if (net_ratelimit())
@@ -6570,7 +6570,7 @@ static struct sk_buff *rtl8169_alloc_rx_data(struct rtl8169_private *tp,
goto err_out;
}
- rtl8169_map_to_asic(desc, mapping, rx_buf_sz);
+ rtl8168_map_to_asic(desc, mapping, rx_buf_sz);
return data;
err_out:
@@ -6578,24 +6578,24 @@ static struct sk_buff *rtl8169_alloc_rx_data(struct rtl8169_private *tp,
return NULL;
}
-static void rtl8169_rx_clear(struct rtl8169_private *tp)
+static void rtl8168_rx_clear(struct rtl8168_private *tp)
{
unsigned int i;
for (i = 0; i < NUM_RX_DESC; i++) {
if (tp->Rx_databuff[i]) {
- rtl8169_free_rx_databuff(tp, tp->Rx_databuff + i,
+ rtl8168_free_rx_databuff(tp, tp->Rx_databuff + i,
tp->RxDescArray + i);
}
}
}
-static inline void rtl8169_mark_as_last_descriptor(struct RxDesc *desc)
+static inline void rtl8168_mark_as_last_descriptor(struct RxDesc *desc)
{
desc->opts1 |= cpu_to_le32(RingEnd);
}
-static int rtl8169_rx_fill(struct rtl8169_private *tp)
+static int rtl8168_rx_fill(struct rtl8168_private *tp)
{
unsigned int i;
@@ -6605,35 +6605,35 @@ static int rtl8169_rx_fill(struct rtl8169_private *tp)
if (tp->Rx_databuff[i])
continue;
- data = rtl8169_alloc_rx_data(tp, tp->RxDescArray + i);
+ data = rtl8168_alloc_rx_data(tp, tp->RxDescArray + i);
if (!data) {
- rtl8169_make_unusable_by_asic(tp->RxDescArray + i);
+ rtl8168_make_unusable_by_asic(tp->RxDescArray + i);
goto err_out;
}
tp->Rx_databuff[i] = data;
}
- rtl8169_mark_as_last_descriptor(tp->RxDescArray + NUM_RX_DESC - 1);
+ rtl8168_mark_as_last_descriptor(tp->RxDescArray + NUM_RX_DESC - 1);
return 0;
err_out:
- rtl8169_rx_clear(tp);
+ rtl8168_rx_clear(tp);
return -ENOMEM;
}
-static int rtl8169_init_ring(struct net_device *dev)
+static int rtl8168_init_ring(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
- rtl8169_init_ring_indexes(tp);
+ rtl8168_init_ring_indexes(tp);
memset(tp->tx_skb, 0x0, NUM_TX_DESC * sizeof(struct ring_info));
memset(tp->Rx_databuff, 0x0, NUM_RX_DESC * sizeof(void *));
- return rtl8169_rx_fill(tp);
+ return rtl8168_rx_fill(tp);
}
-static void rtl8169_unmap_tx_skb(struct device *d, struct ring_info *tx_skb,
+static void rtl8168_unmap_tx_skb(struct device *d, struct ring_info *tx_skb,
struct TxDesc *desc)
{
unsigned int len = tx_skb->len;
@@ -6646,7 +6646,7 @@ static void rtl8169_unmap_tx_skb(struct device *d, struct ring_info *tx_skb,
tx_skb->len = 0;
}
-static void rtl8169_tx_clear_range(struct rtl8169_private *tp, u32 start,
+static void rtl8168_tx_clear_range(struct rtl8168_private *tp, u32 start,
unsigned int n)
{
unsigned int i;
@@ -6659,7 +6659,7 @@ static void rtl8169_tx_clear_range(struct rtl8169_private *tp, u32 start,
if (len) {
struct sk_buff *skb = tx_skb->skb;
- rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
+ rtl8168_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
tp->TxDescArray + entry);
if (skb) {
dev_consume_skb_any(skb);
@@ -6669,13 +6669,13 @@ static void rtl8169_tx_clear_range(struct rtl8169_private *tp, u32 start,
}
}
-static void rtl8169_tx_clear(struct rtl8169_private *tp)
+static void rtl8168_tx_clear(struct rtl8168_private *tp)
{
- rtl8169_tx_clear_range(tp, tp->dirty_tx, NUM_TX_DESC);
+ rtl8168_tx_clear_range(tp, tp->dirty_tx, NUM_TX_DESC);
tp->cur_tx = tp->dirty_tx = 0;
}
-static void rtl_reset_work(struct rtl8169_private *tp)
+static void rtl_reset_work(struct rtl8168_private *tp)
{
struct net_device *dev = tp->dev;
int i;
@@ -6684,28 +6684,28 @@ static void rtl_reset_work(struct rtl8169_private *tp)
netif_stop_queue(dev);
synchronize_sched();
- rtl8169_hw_reset(tp);
+ rtl8168_hw_reset(tp);
for (i = 0; i < NUM_RX_DESC; i++)
- rtl8169_mark_to_asic(tp->RxDescArray + i, rx_buf_sz);
+ rtl8168_mark_to_asic(tp->RxDescArray + i, rx_buf_sz);
- rtl8169_tx_clear(tp);
- rtl8169_init_ring_indexes(tp);
+ rtl8168_tx_clear(tp);
+ rtl8168_init_ring_indexes(tp);
napi_enable(&tp->napi);
rtl_hw_start(dev);
netif_wake_queue(dev);
- rtl8169_check_link_status(dev, tp, tp->mmio_addr);
+ rtl8168_check_link_status(dev, tp, tp->mmio_addr);
}
-static void rtl8169_tx_timeout(struct net_device *dev)
+static void rtl8168_tx_timeout(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
}
-static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb,
+static int rtl8168_xmit_frags(struct rtl8168_private *tp, struct sk_buff *skb,
u32 *opts)
{
struct skb_shared_info *info = skb_shinfo(skb);
@@ -6752,22 +6752,22 @@ static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb,
return cur_frag;
err_out:
- rtl8169_tx_clear_range(tp, tp->cur_tx + 1, cur_frag);
+ rtl8168_tx_clear_range(tp, tp->cur_tx + 1, cur_frag);
return -EIO;
}
-static bool rtl_test_hw_pad_bug(struct rtl8169_private *tp, struct sk_buff *skb)
+static bool rtl_test_hw_pad_bug(struct rtl8168_private *tp, struct sk_buff *skb)
{
return skb->len < ETH_ZLEN && tp->mac_version == RTL_GIGA_MAC_VER_34;
}
-static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
+static netdev_tx_t rtl8168_start_xmit(struct sk_buff *skb,
struct net_device *dev);
-/* r8169_csum_workaround()
+/* r8168_csum_workaround()
* The hw limites the value the transport offset. When the offset is out of the
* range, calculate the checksum by sw.
*/
-static void r8169_csum_workaround(struct rtl8169_private *tp,
+static void r8168_csum_workaround(struct rtl8168_private *tp,
struct sk_buff *skb)
{
if (skb_shinfo(skb)->gso_size) {
@@ -6783,7 +6783,7 @@ static void r8169_csum_workaround(struct rtl8169_private *tp,
nskb = segs;
segs = segs->next;
nskb->next = NULL;
- rtl8169_start_xmit(nskb, tp->dev);
+ rtl8168_start_xmit(nskb, tp->dev);
} while (segs);
dev_consume_skb_any(skb);
@@ -6791,7 +6791,7 @@ static void r8169_csum_workaround(struct rtl8169_private *tp,
if (skb_checksum_help(skb) < 0)
goto drop;
- rtl8169_start_xmit(skb, tp->dev);
+ rtl8168_start_xmit(skb, tp->dev);
} else {
struct net_device_stats *stats;
@@ -6837,7 +6837,7 @@ static inline __be16 get_protocol(struct sk_buff *skb)
return protocol;
}
-static bool rtl8169_tso_csum_v1(struct rtl8169_private *tp,
+static bool rtl8168_tso_csum_v1(struct rtl8168_private *tp,
struct sk_buff *skb, u32 *opts)
{
u32 mss = skb_shinfo(skb)->gso_size;
@@ -6859,7 +6859,7 @@ static bool rtl8169_tso_csum_v1(struct rtl8169_private *tp,
return true;
}
-static bool rtl8169_tso_csum_v2(struct rtl8169_private *tp,
+static bool rtl8168_tso_csum_v2(struct rtl8168_private *tp,
struct sk_buff *skb, u32 *opts)
{
u32 transport_offset = (u32)skb_transport_offset(skb);
@@ -6937,10 +6937,10 @@ static bool rtl8169_tso_csum_v2(struct rtl8169_private *tp,
return true;
}
-static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
+static netdev_tx_t rtl8168_start_xmit(struct sk_buff *skb,
struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
unsigned int entry = tp->cur_tx % NUM_TX_DESC;
struct TxDesc *txd = tp->TxDescArray + entry;
void __iomem *ioaddr = tp->mmio_addr;
@@ -6958,11 +6958,11 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
if (unlikely(le32_to_cpu(txd->opts1) & DescOwn))
goto err_stop_0;
- opts[1] = cpu_to_le32(rtl8169_tx_vlan_tag(skb));
+ opts[1] = cpu_to_le32(rtl8168_tx_vlan_tag(skb));
opts[0] = DescOwn;
if (!tp->tso_csum(tp, skb, opts)) {
- r8169_csum_workaround(tp, skb);
+ r8168_csum_workaround(tp, skb);
return NETDEV_TX_OK;
}
@@ -6977,7 +6977,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
tp->tx_skb[entry].len = len;
txd->addr = cpu_to_le64(mapping);
- frags = rtl8169_xmit_frags(tp, skb, opts);
+ frags = rtl8168_xmit_frags(tp, skb, opts);
if (frags < 0)
goto err_dma_1;
else if (frags)
@@ -7028,7 +7028,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
err_dma_1:
- rtl8169_unmap_tx_skb(d, tp->tx_skb + entry, txd);
+ rtl8168_unmap_tx_skb(d, tp->tx_skb + entry, txd);
err_dma_0:
dev_kfree_skb_any(skb);
dev->stats.tx_dropped++;
@@ -7040,9 +7040,9 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
return NETDEV_TX_BUSY;
}
-static void rtl8169_pcierr_interrupt(struct net_device *dev)
+static void rtl8168_pcierr_interrupt(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
struct pci_dev *pdev = tp->pci_dev;
u16 pci_status, pci_cmd;
@@ -7082,12 +7082,12 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
dev->features &= ~NETIF_F_HIGHDMA;
}
- rtl8169_hw_reset(tp);
+ rtl8168_hw_reset(tp);
rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
}
-static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
+static void rtl_tx(struct net_device *dev, struct rtl8168_private *tp)
{
unsigned int dirty_tx, tx_left;
@@ -7110,7 +7110,7 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
*/
dma_rmb();
- rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
+ rtl8168_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
tp->TxDescArray + entry);
if (status & LastFrag) {
u64_stats_update_begin(&tp->tx_stats.syncp);
@@ -7126,7 +7126,7 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
if (tp->dirty_tx != dirty_tx) {
tp->dirty_tx = dirty_tx;
- /* Sync with rtl8169_start_xmit:
+ /* Sync with rtl8168_start_xmit:
* - publish dirty_tx ring index (write barrier)
* - refresh cur_tx ring index and queue status (read barrier)
* May the current thread miss the stopped queue condition,
@@ -7152,12 +7152,12 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
}
}
-static inline int rtl8169_fragmented_frame(u32 status)
+static inline int rtl8168_fragmented_frame(u32 status)
{
return (status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag);
}
-static inline void rtl8169_rx_csum(struct sk_buff *skb, u32 opts1)
+static inline void rtl8168_rx_csum(struct sk_buff *skb, u32 opts1)
{
u32 status = opts1 & RxProtoMask;
@@ -7168,15 +7168,15 @@ static inline void rtl8169_rx_csum(struct sk_buff *skb, u32 opts1)
skb_checksum_none_assert(skb);
}
-static struct sk_buff *rtl8169_try_rx_copy(void *data,
- struct rtl8169_private *tp,
+static struct sk_buff *rtl8168_try_rx_copy(void *data,
+ struct rtl8168_private *tp,
int pkt_size,
dma_addr_t addr)
{
struct sk_buff *skb;
struct device *d = &tp->pci_dev->dev;
- data = rtl8169_align(data);
+ data = rtl8168_align(data);
dma_sync_single_for_cpu(d, addr, pkt_size, DMA_FROM_DEVICE);
prefetch(data);
skb = napi_alloc_skb(&tp->napi, pkt_size);
@@ -7187,7 +7187,7 @@ static struct sk_buff *rtl8169_try_rx_copy(void *data,
return skb;
}
-static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget)
+static int rtl_rx(struct net_device *dev, struct rtl8168_private *tp, u32 budget)
{
unsigned int cur_rx, rx_left;
unsigned int count;
@@ -7242,24 +7242,24 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget
* frames. They are seen as a symptom of over-mtu
* sized frames.
*/
- if (unlikely(rtl8169_fragmented_frame(status))) {
+ if (unlikely(rtl8168_fragmented_frame(status))) {
dev->stats.rx_dropped++;
dev->stats.rx_length_errors++;
goto release_descriptor;
}
- skb = rtl8169_try_rx_copy(tp->Rx_databuff[entry],
+ skb = rtl8168_try_rx_copy(tp->Rx_databuff[entry],
tp, pkt_size, addr);
if (!skb) {
dev->stats.rx_dropped++;
goto release_descriptor;
}
- rtl8169_rx_csum(skb, status);
+ rtl8168_rx_csum(skb, status);
skb_put(skb, pkt_size);
skb->protocol = eth_type_trans(skb, dev);
- rtl8169_rx_vlan_tag(desc, skb);
+ rtl8168_rx_vlan_tag(desc, skb);
if (skb->pkt_type == PACKET_MULTICAST)
dev->stats.multicast++;
@@ -7273,7 +7273,7 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget
}
release_descriptor:
desc->opts2 = 0;
- rtl8169_mark_to_asic(desc, rx_buf_sz);
+ rtl8168_mark_to_asic(desc, rx_buf_sz);
}
count = cur_rx - tp->cur_rx;
@@ -7282,10 +7282,10 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget
return count;
}
-static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
+static irqreturn_t rtl8168_interrupt(int irq, void *dev_instance)
{
struct net_device *dev = dev_instance;
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
int handled = 0;
u16 status;
@@ -7305,7 +7305,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
/*
* Workqueue context.
*/
-static void rtl_slow_event_work(struct rtl8169_private *tp)
+static void rtl_slow_event_work(struct rtl8168_private *tp)
{
struct net_device *dev = tp->dev;
u16 status;
@@ -7326,10 +7326,10 @@ static void rtl_slow_event_work(struct rtl8169_private *tp)
}
if (unlikely(status & SYSErr))
- rtl8169_pcierr_interrupt(dev);
+ rtl8168_pcierr_interrupt(dev);
if (status & LinkChg)
- __rtl8169_check_link_status(dev, tp, tp->mmio_addr, true);
+ __rtl8168_check_link_status(dev, tp, tp->mmio_addr, true);
rtl_irq_enable_all(tp);
}
@@ -7338,15 +7338,15 @@ static void rtl_task(struct work_struct *work)
{
static const struct {
int bitnr;
- void (*action)(struct rtl8169_private *);
+ void (*action)(struct rtl8168_private *);
} rtl_work[] = {
/* XXX - keep rtl_slow_event_work() as first element. */
{ RTL_FLAG_TASK_SLOW_PENDING, rtl_slow_event_work },
{ RTL_FLAG_TASK_RESET_PENDING, rtl_reset_work },
{ RTL_FLAG_TASK_PHY_PENDING, rtl_phy_work }
};
- struct rtl8169_private *tp =
- container_of(work, struct rtl8169_private, wk.work);
+ struct rtl8168_private *tp =
+ container_of(work, struct rtl8168_private, wk.work);
struct net_device *dev = tp->dev;
int i;
@@ -7368,9 +7368,9 @@ static void rtl_task(struct work_struct *work)
rtl_unlock_work(tp);
}
-static int rtl8169_poll(struct napi_struct *napi, int budget)
+static int rtl8168_poll(struct napi_struct *napi, int budget)
{
- struct rtl8169_private *tp = container_of(napi, struct rtl8169_private, napi);
+ struct rtl8168_private *tp = container_of(napi, struct rtl8168_private, napi);
struct net_device *dev = tp->dev;
u16 enable_mask = RTL_EVENT_NAPI | tp->event_slow;
int work_done= 0;
@@ -7401,50 +7401,50 @@ static int rtl8169_poll(struct napi_struct *napi, int budget)
return work_done;
}
-static void rtl8169_down(struct net_device *dev)
+static void rtl8168_down(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
del_timer_sync(&tp->timer);
napi_disable(&tp->napi);
netif_stop_queue(dev);
- rtl8169_hw_reset(tp);
+ rtl8168_hw_reset(tp);
/* Give a racing hard_start_xmit a few cycles to complete. */
synchronize_sched();
- rtl8169_tx_clear(tp);
+ rtl8168_tx_clear(tp);
- rtl8169_rx_clear(tp);
+ rtl8168_rx_clear(tp);
rtl_pll_power_down(tp);
}
-static int rtl8169_close(struct net_device *dev)
+static int rtl8168_close(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
struct pci_dev *pdev = tp->pci_dev;
pm_runtime_get_sync(&pdev->dev);
/* Update counters before going down */
- rtl8169_update_counters(dev);
+ rtl8168_update_counters(dev);
rtl_lock_work(tp);
clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
- rtl8169_down(dev);
+ rtl8168_down(dev);
rtl_unlock_work(tp);
cancel_work_sync(&tp->wk.work);
free_irq(pdev->irq, dev);
- dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray,
+ dma_free_coherent(&pdev->dev, R8168_RX_RING_BYTES, tp->RxDescArray,
tp->RxPhyAddr);
- dma_free_coherent(&pdev->dev, R8169_TX_RING_BYTES, tp->TxDescArray,
+ dma_free_coherent(&pdev->dev, R8168_TX_RING_BYTES, tp->TxDescArray,
tp->TxPhyAddr);
tp->TxDescArray = NULL;
tp->RxDescArray = NULL;
@@ -7455,17 +7455,17 @@ static int rtl8169_close(struct net_device *dev)
}
#ifdef CONFIG_NET_POLL_CONTROLLER
-static void rtl8169_netpoll(struct net_device *dev)
+static void rtl8168_netpoll(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
- rtl8169_interrupt(tp->pci_dev->irq, dev);
+ rtl8168_interrupt(tp->pci_dev->irq, dev);
}
#endif
static int rtl_open(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
int retval = -ENOMEM;
@@ -7476,17 +7476,17 @@ static int rtl_open(struct net_device *dev)
* Rx and Tx descriptors needs 256 bytes alignment.
* dma_alloc_coherent provides more.
*/
- tp->TxDescArray = dma_alloc_coherent(&pdev->dev, R8169_TX_RING_BYTES,
+ tp->TxDescArray = dma_alloc_coherent(&pdev->dev, R8168_TX_RING_BYTES,
&tp->TxPhyAddr, GFP_KERNEL);
if (!tp->TxDescArray)
goto err_pm_runtime_put;
- tp->RxDescArray = dma_alloc_coherent(&pdev->dev, R8169_RX_RING_BYTES,
+ tp->RxDescArray = dma_alloc_coherent(&pdev->dev, R8168_RX_RING_BYTES,
&tp->RxPhyAddr, GFP_KERNEL);
if (!tp->RxDescArray)
goto err_free_tx_0;
- retval = rtl8169_init_ring(dev);
+ retval = rtl8168_init_ring(dev);
if (retval < 0)
goto err_free_rx_1;
@@ -7496,7 +7496,7 @@ static int rtl_open(struct net_device *dev)
rtl_request_firmware(tp);
- retval = request_irq(pdev->irq, rtl8169_interrupt,
+ retval = request_irq(pdev->irq, rtl8168_interrupt,
(tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED,
dev->name, dev);
if (retval < 0)
@@ -7508,15 +7508,15 @@ static int rtl_open(struct net_device *dev)
napi_enable(&tp->napi);
- rtl8169_init_phy(dev, tp);
+ rtl8168_init_phy(dev, tp);
- __rtl8169_set_features(dev, dev->features);
+ __rtl8168_set_features(dev, dev->features);
rtl_pll_power_up(tp);
rtl_hw_start(dev);
- if (!rtl8169_init_counter_offsets(dev))
+ if (!rtl8168_init_counter_offsets(dev))
netif_warn(tp, hw, dev, "counter reset/update failed\n");
netif_start_queue(dev);
@@ -7526,19 +7526,19 @@ static int rtl_open(struct net_device *dev)
tp->saved_wolopts = 0;
pm_runtime_put_noidle(&pdev->dev);
- rtl8169_check_link_status(dev, tp, ioaddr);
+ rtl8168_check_link_status(dev, tp, ioaddr);
out:
return retval;
err_release_fw_2:
rtl_release_firmware(tp);
- rtl8169_rx_clear(tp);
+ rtl8168_rx_clear(tp);
err_free_rx_1:
- dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray,
+ dma_free_coherent(&pdev->dev, R8168_RX_RING_BYTES, tp->RxDescArray,
tp->RxPhyAddr);
tp->RxDescArray = NULL;
err_free_tx_0:
- dma_free_coherent(&pdev->dev, R8169_TX_RING_BYTES, tp->TxDescArray,
+ dma_free_coherent(&pdev->dev, R8168_TX_RING_BYTES, tp->TxDescArray,
tp->TxPhyAddr);
tp->TxDescArray = NULL;
err_pm_runtime_put:
@@ -7547,11 +7547,11 @@ static int rtl_open(struct net_device *dev)
}
static void
-rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
+rtl8168_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
struct pci_dev *pdev = tp->pci_dev;
- struct rtl8169_counters *counters = tp->counters;
+ struct rtl8168_counters *counters = tp->counters;
unsigned int start;
pm_runtime_get_noresume(&pdev->dev);
@@ -7582,11 +7582,11 @@ rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
* from tally counters.
*/
if (pm_runtime_active(&pdev->dev))
- rtl8169_update_counters(dev);
+ rtl8168_update_counters(dev);
/*
* Subtract values fetched during initalization.
- * See rtl8169_init_counter_offsets for a description why we do that.
+ * See rtl8168_init_counter_offsets for a description why we do that.
*/
stats->tx_errors = le64_to_cpu(counters->tx_errors) -
le64_to_cpu(tp->tc_offset.tx_errors);
@@ -7598,9 +7598,9 @@ rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
pm_runtime_put_noidle(&pdev->dev);
}
-static void rtl8169_net_suspend(struct net_device *dev)
+static void rtl8168_net_suspend(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
if (!netif_running(dev))
return;
@@ -7618,19 +7618,19 @@ static void rtl8169_net_suspend(struct net_device *dev)
#ifdef CONFIG_PM
-static int rtl8169_suspend(struct device *device)
+static int rtl8168_suspend(struct device *device)
{
struct pci_dev *pdev = to_pci_dev(device);
struct net_device *dev = pci_get_drvdata(pdev);
- rtl8169_net_suspend(dev);
+ rtl8168_net_suspend(dev);
return 0;
}
-static void __rtl8169_resume(struct net_device *dev)
+static void __rtl8168_resume(struct net_device *dev)
{
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
netif_device_attach(dev);
@@ -7644,94 +7644,94 @@ static void __rtl8169_resume(struct net_device *dev)
rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
}
-static int rtl8169_resume(struct device *device)
+static int rtl8168_resume(struct device *device)
{
struct pci_dev *pdev = to_pci_dev(device);
struct net_device *dev = pci_get_drvdata(pdev);
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
- rtl8169_init_phy(dev, tp);
+ rtl8168_init_phy(dev, tp);
if (netif_running(dev))
- __rtl8169_resume(dev);
+ __rtl8168_resume(dev);
return 0;
}
-static int rtl8169_runtime_suspend(struct device *device)
+static int rtl8168_runtime_suspend(struct device *device)
{
struct pci_dev *pdev = to_pci_dev(device);
struct net_device *dev = pci_get_drvdata(pdev);
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
if (!tp->TxDescArray)
return 0;
rtl_lock_work(tp);
- tp->saved_wolopts = __rtl8169_get_wol(tp);
- __rtl8169_set_wol(tp, WAKE_ANY);
+ tp->saved_wolopts = __rtl8168_get_wol(tp);
+ __rtl8168_set_wol(tp, WAKE_ANY);
rtl_unlock_work(tp);
- rtl8169_net_suspend(dev);
+ rtl8168_net_suspend(dev);
/* Update counters before going runtime suspend */
- rtl8169_update_counters(dev);
+ rtl8168_update_counters(dev);
return 0;
}
-static int rtl8169_runtime_resume(struct device *device)
+static int rtl8168_runtime_resume(struct device *device)
{
struct pci_dev *pdev = to_pci_dev(device);
struct net_device *dev = pci_get_drvdata(pdev);
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
rtl_rar_set(tp, dev->dev_addr);
if (!tp->TxDescArray)
return 0;
rtl_lock_work(tp);
- __rtl8169_set_wol(tp, tp->saved_wolopts);
+ __rtl8168_set_wol(tp, tp->saved_wolopts);
tp->saved_wolopts = 0;
rtl_unlock_work(tp);
- rtl8169_init_phy(dev, tp);
+ rtl8168_init_phy(dev, tp);
- __rtl8169_resume(dev);
+ __rtl8168_resume(dev);
return 0;
}
-static int rtl8169_runtime_idle(struct device *device)
+static int rtl8168_runtime_idle(struct device *device)
{
struct pci_dev *pdev = to_pci_dev(device);
struct net_device *dev = pci_get_drvdata(pdev);
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
return tp->TxDescArray ? -EBUSY : 0;
}
static const struct dev_pm_ops rtl8168_pm_ops = {
- .suspend = rtl8169_suspend,
- .resume = rtl8169_resume,
- .freeze = rtl8169_suspend,
- .thaw = rtl8169_resume,
- .poweroff = rtl8169_suspend,
- .restore = rtl8169_resume,
- .runtime_suspend = rtl8169_runtime_suspend,
- .runtime_resume = rtl8169_runtime_resume,
- .runtime_idle = rtl8169_runtime_idle,
+ .suspend = rtl8168_suspend,
+ .resume = rtl8168_resume,
+ .freeze = rtl8168_suspend,
+ .thaw = rtl8168_resume,
+ .poweroff = rtl8168_suspend,
+ .restore = rtl8168_resume,
+ .runtime_suspend = rtl8168_runtime_suspend,
+ .runtime_resume = rtl8168_runtime_resume,
+ .runtime_idle = rtl8168_runtime_idle,
};
#define RTL8168_PM_OPS (&rtl8168_pm_ops)
#else /* !CONFIG_PM */
-#define RTL8169_PM_OPS NULL
+#define RTL8168_PM_OPS NULL
#endif /* !CONFIG_PM */
-static void rtl_wol_shutdown_quirk(struct rtl8169_private *tp)
+static void rtl_wol_shutdown_quirk(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -7754,20 +7754,20 @@ static void rtl_wol_shutdown_quirk(struct rtl8169_private *tp)
static void rtl_shutdown(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
struct device *d = &pdev->dev;
pm_runtime_get_sync(d);
- rtl8169_net_suspend(dev);
+ rtl8168_net_suspend(dev);
/* Restore original MAC address */
rtl_rar_set(tp, dev->perm_addr);
- rtl8169_hw_reset(tp);
+ rtl8168_hw_reset(tp);
if (system_state == SYSTEM_POWER_OFF) {
- if (__rtl8169_get_wol(tp) & WAKE_ANY) {
+ if (__rtl8168_get_wol(tp) & WAKE_ANY) {
rtl_wol_suspend_quirk(tp);
rtl_wol_shutdown_quirk(tp);
}
@@ -7782,7 +7782,7 @@ static void rtl_shutdown(struct pci_dev *pdev)
static void rtl_remove_one(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
- struct rtl8169_private *tp = netdev_priv(dev);
+ struct rtl8168_private *tp = netdev_priv(dev);
if ((tp->mac_version == RTL_GIGA_MAC_VER_27 ||
tp->mac_version == RTL_GIGA_MAC_VER_28 ||
@@ -7809,19 +7809,19 @@ static void rtl_remove_one(struct pci_dev *pdev)
static const struct net_device_ops rtl_netdev_ops = {
.ndo_open = rtl_open,
- .ndo_stop = rtl8169_close,
- .ndo_get_stats64 = rtl8169_get_stats64,
- .ndo_start_xmit = rtl8169_start_xmit,
- .ndo_tx_timeout = rtl8169_tx_timeout,
+ .ndo_stop = rtl8168_close,
+ .ndo_get_stats64 = rtl8168_get_stats64,
+ .ndo_start_xmit = rtl8168_start_xmit,
+ .ndo_tx_timeout = rtl8168_tx_timeout,
.ndo_validate_addr = eth_validate_addr,
- .ndo_change_mtu = rtl8169_change_mtu,
- .ndo_fix_features = rtl8169_fix_features,
- .ndo_set_features = rtl8169_set_features,
+ .ndo_change_mtu = rtl8168_change_mtu,
+ .ndo_fix_features = rtl8168_fix_features,
+ .ndo_set_features = rtl8168_set_features,
.ndo_set_mac_address = rtl_set_mac_address,
- .ndo_do_ioctl = rtl8169_ioctl,
+ .ndo_do_ioctl = rtl8168_ioctl,
.ndo_set_rx_mode = rtl_set_rx_mode,
#ifdef CONFIG_NET_POLL_CONTROLLER
- .ndo_poll_controller = rtl8169_netpoll,
+ .ndo_poll_controller = rtl8168_netpoll,
#endif
};
@@ -7866,7 +7866,7 @@ static const struct rtl_cfg_info {
};
/* Cfg9346_Unlock assumed. */
-static unsigned rtl_try_msi(struct rtl8169_private *tp,
+static unsigned rtl_try_msi(struct rtl8168_private *tp,
const struct rtl_cfg_info *cfg)
{
void __iomem *ioaddr = tp->mmio_addr;
@@ -7899,7 +7899,7 @@ DECLARE_RTL_COND(rtl_rxtx_empty_cond)
return (RTL_R8(MCU) & RXTX_EMPTY) == RXTX_EMPTY;
}
-static void rtl_hw_init_8168g(struct rtl8169_private *tp)
+static void rtl_hw_init_8168g(struct rtl8168_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
u32 data;
@@ -7933,13 +7933,13 @@ static void rtl_hw_init_8168g(struct rtl8169_private *tp)
return;
}
-static void rtl_hw_init_8168ep(struct rtl8169_private *tp)
+static void rtl_hw_init_8168ep(struct rtl8168_private *tp)
{
rtl8168ep_stop_cmac(tp);
rtl_hw_init_8168g(tp);
}
-static void rtl_hw_initialize(struct rtl8169_private *tp)
+static void rtl_hw_initialize(struct rtl8168_private *tp)
{
switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_40:
@@ -7967,7 +7967,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data;
const unsigned int region = cfg->region;
- struct rtl8169_private *tp;
+ struct rtl8168_private *tp;
struct mii_if_info *mii;
struct net_device *dev;
void __iomem *ioaddr;
@@ -7976,7 +7976,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if (netif_msg_drv(&debug)) {
printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n",
- MODULENAME, RTL8169_VERSION);
+ MODULENAME, RTL8168_VERSION);
}
dev = devm_alloc_etherdev(&pdev->dev, sizeof (*tp));
@@ -7988,7 +7988,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp = netdev_priv(dev);
tp->dev = dev;
tp->pci_dev = pdev;
- tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT);
+ tp->msg_enable = netif_msg_init(debug.msg_enable, R8168_MSG_DEFAULT);
mii = &tp->mii;
mii->dev = dev;
@@ -8022,7 +8022,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
}
/* check for weird/broken PCI region reporting */
- if (pci_resource_len(pdev, region) < R8169_REGS_SIZE) {
+ if (pci_resource_len(pdev, region) < R8168_REGS_SIZE) {
netif_err(tp, probe, dev,
"Invalid PCI region size(s), aborting\n");
return -ENODEV;
@@ -8036,7 +8036,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
/* ioremap MMIO region */
ioaddr = devm_ioremap(&pdev->dev, pci_resource_start(pdev, region),
- R8169_REGS_SIZE);
+ R8168_REGS_SIZE);
if (!ioaddr) {
netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n");
return -EIO;
@@ -8047,7 +8047,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
netif_info(tp, probe, dev, "not PCI Express\n");
/* Identify chip attached to board */
- rtl8169_get_mac_version(tp, dev, cfg->default_ver);
+ rtl8168_get_mac_version(tp, dev, cfg->default_ver);
/* This driver doesn't handle the older non-PCIE models */
if (tp->mac_version >= RTL_GIGA_MAC_VER_01 &&
tp->mac_version <= RTL_GIGA_MAC_VER_06)
@@ -8090,7 +8090,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
rtl_init_jumbo_ops(tp);
rtl_init_csi_ops(tp);
- rtl8169_print_mac_version(tp);
+ rtl8168_print_mac_version(tp);
chipset = tp->mac_version;
tp->txd_version = rtl_chip_infos[chipset].txd_version;
@@ -8163,10 +8163,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
for (i = 0; i < ETH_ALEN; i++)
dev->dev_addr[i] = RTL_R8(MAC0 + i);
- dev->ethtool_ops = &rtl8169_ethtool_ops;
- dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
+ dev->ethtool_ops = &rtl8168_ethtool_ops;
+ dev->watchdog_timeo = RTL8168_TX_TIMEOUT;
- netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT);
+ netif_napi_add(dev, &tp->napi, rtl8168_poll, R8168_NAPI_WEIGHT);
/* don't enable SG, IP_CSUM and TSO by default - it might not work
* properly for all devices */
@@ -8182,9 +8182,9 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->cp_cmd |= RxChkSum | RxVlan;
if (tp->txd_version == RTL_TD_0)
- tp->tso_csum = rtl8169_tso_csum_v1;
+ tp->tso_csum = rtl8168_tso_csum_v1;
else if (tp->txd_version == RTL_TD_1) {
- tp->tso_csum = rtl8169_tso_csum_v2;
+ tp->tso_csum = rtl8168_tso_csum_v2;
dev->hw_features |= NETIF_F_IPV6_CSUM | NETIF_F_TSO6;
} else
WARN_ON_ONCE(1);
@@ -8202,7 +8202,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->opts1_mask = ~(RxBOVF | RxFOVF);
- timer_setup(&tp->timer, rtl8169_phy_timer, 0);
+ timer_setup(&tp->timer, rtl8168_phy_timer, 0);
tp->rtl_fw = RTL_FIRMWARE_UNKNOWN;
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 06/18] r8168: remove function rtl8169_rx_missed() being specific to MAC version 01 - 06
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
Function rtl8169_rx_missed() does nothing on MAC versions > 06,
therefore remove it.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8168.c | 23 -----------------------
1 file changed, 23 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index 0ce789814..0ba0ac5ec 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -7401,21 +7401,9 @@ static int rtl8169_poll(struct napi_struct *napi, int budget)
return work_done;
}
-static void rtl8169_rx_missed(struct net_device *dev, void __iomem *ioaddr)
-{
- struct rtl8169_private *tp = netdev_priv(dev);
-
- if (tp->mac_version > RTL_GIGA_MAC_VER_06)
- return;
-
- dev->stats.rx_missed_errors += (RTL_R32(RxMissed) & 0xffffff);
- RTL_W32(RxMissed, 0);
-}
-
static void rtl8169_down(struct net_device *dev)
{
struct rtl8169_private *tp = netdev_priv(dev);
- void __iomem *ioaddr = tp->mmio_addr;
del_timer_sync(&tp->timer);
@@ -7423,12 +7411,6 @@ static void rtl8169_down(struct net_device *dev)
netif_stop_queue(dev);
rtl8169_hw_reset(tp);
- /*
- * At this point device interrupts can not be enabled in any function,
- * as netif_running is not true (rtl8169_interrupt, rtl8169_reset_task)
- * and napi is disabled (rtl8169_poll).
- */
- rtl8169_rx_missed(dev, ioaddr);
/* Give a racing hard_start_xmit a few cycles to complete. */
synchronize_sched();
@@ -7568,16 +7550,12 @@ static void
rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
{
struct rtl8169_private *tp = netdev_priv(dev);
- void __iomem *ioaddr = tp->mmio_addr;
struct pci_dev *pdev = tp->pci_dev;
struct rtl8169_counters *counters = tp->counters;
unsigned int start;
pm_runtime_get_noresume(&pdev->dev);
- if (netif_running(dev) && pm_runtime_active(&pdev->dev))
- rtl8169_rx_missed(dev, ioaddr);
-
do {
start = u64_stats_fetch_begin_irq(&tp->rx_stats.syncp);
stats->rx_packets = tp->rx_stats.packets;
@@ -7697,7 +7675,6 @@ static int rtl8169_runtime_suspend(struct device *device)
rtl8169_net_suspend(dev);
/* Update counters before going runtime suspend */
- rtl8169_rx_missed(dev, tp->mmio_addr);
rtl8169_update_counters(dev);
return 0;
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 05/18] r8168: remove unneeded callbacks from struct rtl8169_private
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
All supported chips provide a MII interface, therefore some callbacks
can be removed from struct rtl8169_private.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8168.c | 46 +++++++++++++-----------------------
1 file changed, 16 insertions(+), 30 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index 48b7edff8..0ce789814 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -806,14 +806,7 @@ struct rtl8169_private {
u32 (*read)(struct rtl8169_private *, int);
} csi_ops;
- int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
- int (*get_link_ksettings)(struct net_device *,
- struct ethtool_link_ksettings *);
- void (*phy_reset_enable)(struct rtl8169_private *tp);
void (*hw_start)(struct net_device *);
- unsigned int (*phy_reset_pending)(struct rtl8169_private *tp);
- unsigned int (*link_ok)(void __iomem *);
- int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd);
bool (*tso_csum)(struct rtl8169_private *, struct sk_buff *, u32 *);
struct {
@@ -1643,7 +1636,7 @@ static void __rtl8169_check_link_status(struct net_device *dev,
struct rtl8169_private *tp,
void __iomem *ioaddr, bool pm)
{
- if (tp->link_ok(ioaddr)) {
+ if (rtl8169_xmii_link_ok(ioaddr)) {
rtl_link_chg_patch(tp);
/* This is to cancel a scheduled suspend if there's one. */
if (pm)
@@ -1947,7 +1940,7 @@ static int rtl8169_set_speed(struct net_device *dev,
struct rtl8169_private *tp = netdev_priv(dev);
int ret;
- ret = tp->set_speed(dev, autoneg, speed, duplex, advertising);
+ ret = rtl8169_set_speed_xmii(dev, autoneg, speed, duplex, advertising);
if (ret < 0)
goto out;
@@ -2053,7 +2046,7 @@ static int rtl8169_get_link_ksettings(struct net_device *dev,
int rc;
rtl_lock_work(tp);
- rc = tp->get_link_ksettings(dev, cmd);
+ rc = rtl8169_get_link_ksettings_xmii(dev, cmd);
rtl_unlock_work(tp);
return rc;
@@ -4307,7 +4300,7 @@ static void rtl_phy_work(struct rtl8169_private *tp)
assert(tp->mac_version > RTL_GIGA_MAC_VER_01);
- if (tp->phy_reset_pending(tp)) {
+ if (rtl8169_xmii_reset_pending(tp)) {
/*
* A busy loop could burn quite a few cycles on nowadays CPU.
* Let's delay the execution of the timer for a few ticks.
@@ -4316,12 +4309,12 @@ static void rtl_phy_work(struct rtl8169_private *tp)
goto out_mod_timer;
}
- if (tp->link_ok(ioaddr))
+ if (rtl8169_xmii_link_ok(ioaddr))
return;
netif_dbg(tp, link, tp->dev, "PHY reset until link up\n");
- tp->phy_reset_enable(tp);
+ rtl8169_xmii_reset_enable(tp);
out_mod_timer:
mod_timer(timer, jiffies + timeout);
@@ -4342,13 +4335,13 @@ static void rtl8169_phy_timer(struct timer_list *t)
DECLARE_RTL_COND(rtl_phy_reset_cond)
{
- return tp->phy_reset_pending(tp);
+ return rtl8169_xmii_reset_pending(tp);
}
static void rtl8169_phy_reset(struct net_device *dev,
struct rtl8169_private *tp)
{
- tp->phy_reset_enable(tp);
+ rtl8169_xmii_reset_enable(tp);
rtl_msleep_loop_wait_low(tp, &rtl_phy_reset_cond, 1, 100);
}
@@ -4411,14 +4404,6 @@ static int rtl_set_mac_address(struct net_device *dev, void *p)
return 0;
}
-static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
-{
- struct rtl8169_private *tp = netdev_priv(dev);
- struct mii_ioctl_data *data = if_mii(ifr);
-
- return netif_running(dev) ? tp->do_ioctl(tp, data, cmd) : -ENODEV;
-}
-
static int rtl_xmii_ioctl(struct rtl8169_private *tp,
struct mii_ioctl_data *data, int cmd)
{
@@ -4438,6 +4423,14 @@ static int rtl_xmii_ioctl(struct rtl8169_private *tp,
return -EOPNOTSUPP;
}
+static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+ struct rtl8169_private *tp = netdev_priv(dev);
+ struct mii_ioctl_data *data = if_mii(ifr);
+
+ return netif_running(dev) ? rtl_xmii_ioctl(tp, data, cmd) : -ENODEV;
+}
+
static void rtl_init_mdio_ops(struct rtl8169_private *tp)
{
struct mdio_ops *ops = &tp->mdio_ops;
@@ -8161,13 +8154,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->features |= rtl_try_msi(tp, cfg);
RTL_W8(Cfg9346, Cfg9346_Lock);
- tp->set_speed = rtl8169_set_speed_xmii;
- tp->get_link_ksettings = rtl8169_get_link_ksettings_xmii;
- tp->phy_reset_enable = rtl8169_xmii_reset_enable;
- tp->phy_reset_pending = rtl8169_xmii_reset_pending;
- tp->link_ok = rtl8169_xmii_link_ok;
- tp->do_ioctl = rtl_xmii_ioctl;
-
mutex_init(&tp->wk.mutex);
u64_stats_init(&tp->rx_stats.syncp);
u64_stats_init(&tp->tx_stats.syncp);
--
2.15.1
^ permalink raw reply related
* [PATCH RFC 04/18] r8168: remove TBI mode support needed for MAC version 01 only
From: Heiner Kallweit @ 2017-12-21 20:50 UTC (permalink / raw)
To: Andrew Lunn, Realtek linux nic maintainers, Chun-Hao Lin
Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com>
Remove TBI mode support needed for MAC version 01 only.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8168.c | 123 ++---------------------------------
1 file changed, 6 insertions(+), 117 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c
index a80b7ce80..48b7edff8 100644
--- a/drivers/net/ethernet/realtek/r8168.c
+++ b/drivers/net/ethernet/realtek/r8168.c
@@ -426,12 +426,6 @@ enum rtl_registers {
FuncForceEvent = 0xfc,
};
-enum rtl8110_registers {
- TBICSR = 0x64,
- TBI_ANAR = 0x68,
- TBI_LPAR = 0x6a,
-};
-
enum rtl8168_8101_registers {
CSIDR = 0x64,
CSIAR = 0x68,
@@ -603,14 +597,6 @@ enum rtl_register_content {
PMEStatus = (1 << 0), /* PME status can be reset by PCI RST# */
ASPM_en = (1 << 0), /* ASPM enable */
- /* TBICSR p.28 */
- TBIReset = 0x80000000,
- TBILoopback = 0x40000000,
- TBINwEnable = 0x20000000,
- TBINwRestart = 0x10000000,
- TBILinkOk = 0x02000000,
- TBINwComplete = 0x01000000,
-
/* CPlusCmd p.31 */
EnableBist = (1 << 15), // 8168 8101
Mac_dbgo_oe = (1 << 14), // 8168 8101
@@ -641,9 +627,6 @@ enum rtl_register_content {
LinkStatus = 0x02,
FullDup = 0x01,
- /* _TBICSRBit */
- TBILinkOK = 0x02000000,
-
/* ResetCounterCommand */
CounterReset = 0x1,
@@ -1581,35 +1564,16 @@ static void rtl8169_irq_mask_and_ack(struct rtl8169_private *tp)
RTL_R8(ChipCmd);
}
-static unsigned int rtl8169_tbi_reset_pending(struct rtl8169_private *tp)
-{
- void __iomem *ioaddr = tp->mmio_addr;
-
- return RTL_R32(TBICSR) & TBIReset;
-}
-
static unsigned int rtl8169_xmii_reset_pending(struct rtl8169_private *tp)
{
return rtl_readphy(tp, MII_BMCR) & BMCR_RESET;
}
-static unsigned int rtl8169_tbi_link_ok(void __iomem *ioaddr)
-{
- return RTL_R32(TBICSR) & TBILinkOk;
-}
-
static unsigned int rtl8169_xmii_link_ok(void __iomem *ioaddr)
{
return RTL_R8(PHYstatus) & LinkStatus;
}
-static void rtl8169_tbi_reset_enable(struct rtl8169_private *tp)
-{
- void __iomem *ioaddr = tp->mmio_addr;
-
- RTL_W32(TBICSR, RTL_R32(TBICSR) | TBIReset);
-}
-
static void rtl8169_xmii_reset_enable(struct rtl8169_private *tp)
{
unsigned int val;
@@ -1911,29 +1875,6 @@ static int rtl8169_get_regs_len(struct net_device *dev)
return R8169_REGS_SIZE;
}
-static int rtl8169_set_speed_tbi(struct net_device *dev,
- u8 autoneg, u16 speed, u8 duplex, u32 ignored)
-{
- struct rtl8169_private *tp = netdev_priv(dev);
- void __iomem *ioaddr = tp->mmio_addr;
- int ret = 0;
- u32 reg;
-
- reg = RTL_R32(TBICSR);
- if ((autoneg == AUTONEG_DISABLE) && (speed == SPEED_1000) &&
- (duplex == DUPLEX_FULL)) {
- RTL_W32(TBICSR, reg & ~(TBINwEnable | TBINwRestart));
- } else if (autoneg == AUTONEG_ENABLE)
- RTL_W32(TBICSR, reg | TBINwEnable | TBINwRestart);
- else {
- netif_warn(tp, link, dev,
- "incorrect speed setting refused in TBI mode\n");
- ret = -EOPNOTSUPP;
- }
-
- return ret;
-}
-
static int rtl8169_set_speed_xmii(struct net_device *dev,
u8 autoneg, u16 speed, u8 duplex, u32 adv)
{
@@ -2095,33 +2036,6 @@ static void rtl8169_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), swab16(opts2 & 0xffff));
}
-static int rtl8169_get_link_ksettings_tbi(struct net_device *dev,
- struct ethtool_link_ksettings *cmd)
-{
- struct rtl8169_private *tp = netdev_priv(dev);
- void __iomem *ioaddr = tp->mmio_addr;
- u32 status;
- u32 supported, advertising;
-
- supported =
- SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg | SUPPORTED_FIBRE;
- cmd->base.port = PORT_FIBRE;
-
- status = RTL_R32(TBICSR);
- advertising = (status & TBINwEnable) ? ADVERTISED_Autoneg : 0;
- cmd->base.autoneg = !!(status & TBINwEnable);
-
- cmd->base.speed = SPEED_1000;
- cmd->base.duplex = DUPLEX_FULL; /* Always set */
-
- ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
- supported);
- ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
- advertising);
-
- return 0;
-}
-
static int rtl8169_get_link_ksettings_xmii(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{
@@ -4438,14 +4352,6 @@ static void rtl8169_phy_reset(struct net_device *dev,
rtl_msleep_loop_wait_low(tp, &rtl_phy_reset_cond, 1, 100);
}
-static bool rtl_tbi_enabled(struct rtl8169_private *tp)
-{
- void __iomem *ioaddr = tp->mmio_addr;
-
- return (tp->mac_version == RTL_GIGA_MAC_VER_01) &&
- (RTL_R8(PHYstatus) & TBI_Enable);
-}
-
static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
{
rtl_hw_phy_config(dev);
@@ -4460,9 +4366,6 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
(tp->mii.supports_gmii ?
ADVERTISED_1000baseT_Half |
ADVERTISED_1000baseT_Full : 0));
-
- if (rtl_tbi_enabled(tp))
- netif_info(tp, link, dev, "TBI auto-negotiating\n");
}
static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
@@ -4535,11 +4438,6 @@ static int rtl_xmii_ioctl(struct rtl8169_private *tp,
return -EOPNOTSUPP;
}
-static int rtl_tbi_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd)
-{
- return -EOPNOTSUPP;
-}
-
static void rtl_init_mdio_ops(struct rtl8169_private *tp)
{
struct mdio_ops *ops = &tp->mdio_ops;
@@ -8263,21 +8161,12 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->features |= rtl_try_msi(tp, cfg);
RTL_W8(Cfg9346, Cfg9346_Lock);
- if (rtl_tbi_enabled(tp)) {
- tp->set_speed = rtl8169_set_speed_tbi;
- tp->get_link_ksettings = rtl8169_get_link_ksettings_tbi;
- tp->phy_reset_enable = rtl8169_tbi_reset_enable;
- tp->phy_reset_pending = rtl8169_tbi_reset_pending;
- tp->link_ok = rtl8169_tbi_link_ok;
- tp->do_ioctl = rtl_tbi_ioctl;
- } else {
- tp->set_speed = rtl8169_set_speed_xmii;
- tp->get_link_ksettings = rtl8169_get_link_ksettings_xmii;
- tp->phy_reset_enable = rtl8169_xmii_reset_enable;
- tp->phy_reset_pending = rtl8169_xmii_reset_pending;
- tp->link_ok = rtl8169_xmii_link_ok;
- tp->do_ioctl = rtl_xmii_ioctl;
- }
+ tp->set_speed = rtl8169_set_speed_xmii;
+ tp->get_link_ksettings = rtl8169_get_link_ksettings_xmii;
+ tp->phy_reset_enable = rtl8169_xmii_reset_enable;
+ tp->phy_reset_pending = rtl8169_xmii_reset_pending;
+ tp->link_ok = rtl8169_xmii_link_ok;
+ tp->do_ioctl = rtl_xmii_ioctl;
mutex_init(&tp->wk.mutex);
u64_stats_init(&tp->rx_stats.syncp);
--
2.15.1
^ permalink raw reply related
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