net: ptp: do not reimplement PTP/BPF classifier
There are currently pch_gbe, cpts, and ixp4xx_eth drivers that open-code and reimplement a BPF classifier for the PTP protocol. Since all of them effectively do the very same thing and load the very same PTP/BPF filter, we can just consolidate that code by introducing ptp_classify_raw() in the time-stamping core framework which can be used in drivers. As drivers get initialized after bootstrapping the core networking subsystem, they can make use of ptp_insns wrapped through ptp_classify_raw(), which allows to simplify and remove PTP classifier setup code in drivers. Joint work with Alexei Starovoitov. Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Cc: Richard Cochran <richard.cochran@omicron.at> Cc: Jiri Benc <jbenc@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
e62d2df084
commit
164d8c6665
@@ -31,10 +31,6 @@
|
||||
|
||||
#ifdef CONFIG_TI_CPTS
|
||||
|
||||
static struct sock_filter ptp_filter[] = {
|
||||
PTP_FILTER
|
||||
};
|
||||
|
||||
#define cpts_read32(c, r) __raw_readl(&c->reg->r)
|
||||
#define cpts_write32(c, v, r) __raw_writel(v, &c->reg->r)
|
||||
|
||||
@@ -301,7 +297,7 @@ static u64 cpts_find_ts(struct cpts *cpts, struct sk_buff *skb, int ev_type)
|
||||
u64 ns = 0;
|
||||
struct cpts_event *event;
|
||||
struct list_head *this, *next;
|
||||
unsigned int class = sk_run_filter(skb, ptp_filter);
|
||||
unsigned int class = ptp_classify_raw(skb);
|
||||
unsigned long flags;
|
||||
u16 seqid;
|
||||
u8 mtype;
|
||||
@@ -372,10 +368,6 @@ int cpts_register(struct device *dev, struct cpts *cpts,
|
||||
int err, i;
|
||||
unsigned long flags;
|
||||
|
||||
if (ptp_filter_init(ptp_filter, ARRAY_SIZE(ptp_filter))) {
|
||||
pr_err("cpts: bad ptp filter\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
cpts->info = cpts_info;
|
||||
cpts->clock = ptp_clock_register(&cpts->info, dev);
|
||||
if (IS_ERR(cpts->clock)) {
|
||||
|
Reference in New Issue
Block a user