aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJiri Pirko <jiri@mellanox.com>2017-08-07 10:15:29 +0200
committerDavid S. Miller <davem@davemloft.net>2017-08-07 09:42:37 -0700
commit5fd9fc4e207dba0c05cafe78417952b4c4ca02dc (patch)
tree5e6aba80c4d3ec11e2e58983748b497e7f80f2fa /net
parenthns3pf: don't check handle during mqprio offload (diff)
downloadlinux-dev-5fd9fc4e207dba0c05cafe78417952b4c4ca02dc.tar.xz
linux-dev-5fd9fc4e207dba0c05cafe78417952b4c4ca02dc.zip
net: sched: push cls related args into cls_common structure
As ndo_setup_tc is generic offload op for whole tc subsystem, does not really make sense to have cls-specific args. So move them under cls_common structurure which is embedded in all cls structs. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/dsa/slave.c14
-rw-r--r--net/sched/cls_bpf.c7
-rw-r--r--net/sched/cls_flower.c13
-rw-r--r--net/sched/cls_matchall.c8
-rw-r--r--net/sched/cls_u32.c20
-rw-r--r--net/sched/sch_mqprio.c6
6 files changed, 27 insertions, 41 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index e76d576b941d..5e01e9271619 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -774,12 +774,12 @@ dsa_slave_mall_tc_entry_find(struct dsa_slave_priv *p,
}
static int dsa_slave_add_cls_matchall(struct net_device *dev,
- __be16 protocol,
struct tc_cls_matchall_offload *cls,
bool ingress)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_mall_tc_entry *mall_tc_entry;
+ __be16 protocol = cls->common.protocol;
struct dsa_switch *ds = p->dp->ds;
struct net *net = dev_net(dev);
struct dsa_slave_priv *to_p;
@@ -864,18 +864,16 @@ static void dsa_slave_del_cls_matchall(struct net_device *dev,
}
static int dsa_slave_setup_tc_cls_matchall(struct net_device *dev,
- u32 handle, u32 chain_index,
- __be16 protocol,
struct tc_cls_matchall_offload *cls)
{
- bool ingress = TC_H_MAJ(handle) == TC_H_MAJ(TC_H_INGRESS);
+ bool ingress = TC_H_MAJ(cls->common.handle) == TC_H_MAJ(TC_H_INGRESS);
- if (chain_index)
+ if (cls->common.chain_index)
return -EOPNOTSUPP;
switch (cls->command) {
case TC_CLSMATCHALL_REPLACE:
- return dsa_slave_add_cls_matchall(dev, protocol, cls, ingress);
+ return dsa_slave_add_cls_matchall(dev, cls, ingress);
case TC_CLSMATCHALL_DESTROY:
dsa_slave_del_cls_matchall(dev, cls);
return 0;
@@ -885,13 +883,11 @@ static int dsa_slave_setup_tc_cls_matchall(struct net_device *dev,
}
static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type,
- u32 handle, u32 chain_index, __be16 protocol,
struct tc_to_netdev *tc)
{
switch (type) {
case TC_SETUP_CLSMATCHALL:
- return dsa_slave_setup_tc_cls_matchall(dev, handle, chain_index,
- protocol, tc->cls_mall);
+ return dsa_slave_setup_tc_cls_matchall(dev, tc->cls_mall);
default:
return -EOPNOTSUPP;
}
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index e2bf2753173d..dde8efdcee3b 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -153,6 +153,7 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog,
offload.cls_bpf = &bpf_offload;
+ tc_cls_common_offload_init(&bpf_offload.common, tp);
bpf_offload.command = cmd;
bpf_offload.exts = &prog->exts;
bpf_offload.prog = prog->filter;
@@ -160,11 +161,7 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog,
bpf_offload.exts_integrated = prog->exts_integrated;
bpf_offload.gen_flags = prog->gen_flags;
- err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSBPF,
- tp->q->handle,
- tp->chain->index,
- tp->protocol, &offload);
-
+ err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSBPF, &offload);
if (!err && (cmd == TC_CLSBPF_ADD || cmd == TC_CLSBPF_REPLACE))
prog->gen_flags |= TCA_CLS_FLAGS_IN_HW;
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 52deeed2b7f5..1fdf2889ba9f 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -232,14 +232,14 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, struct cls_fl_filter *f)
if (!tc_can_offload(dev, tp))
return;
+ tc_cls_common_offload_init(&offload.common, tp);
offload.command = TC_CLSFLOWER_DESTROY;
offload.prio = tp->prio;
offload.cookie = (unsigned long)f;
tc->cls_flower = &offload;
- dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER, tp->q->handle,
- tp->chain->index, tp->protocol, tc);
+ dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER, tc);
}
static int fl_hw_replace_filter(struct tcf_proto *tp,
@@ -264,6 +264,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp,
f->hw_dev = dev;
}
+ tc_cls_common_offload_init(&offload.common, tp);
offload.command = TC_CLSFLOWER_REPLACE;
offload.prio = tp->prio;
offload.cookie = (unsigned long)f;
@@ -274,9 +275,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp,
tc->cls_flower = &offload;
- err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER,
- tp->q->handle, tp->chain->index,
- tp->protocol, tc);
+ err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER, tc);
if (!err)
f->flags |= TCA_CLS_FLAGS_IN_HW;
@@ -294,6 +293,7 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f)
if (!tc_can_offload(dev, tp))
return;
+ tc_cls_common_offload_init(&offload.common, tp);
offload.command = TC_CLSFLOWER_STATS;
offload.prio = tp->prio;
offload.cookie = (unsigned long)f;
@@ -301,8 +301,7 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f)
tc->cls_flower = &offload;
- dev->netdev_ops->ndo_setup_tc(dev, TC_CLSFLOWER_STATS, tp->q->handle,
- tp->chain->index, tp->protocol, tc);
+ dev->netdev_ops->ndo_setup_tc(dev, TC_CLSFLOWER_STATS, tc);
}
static void __fl_delete(struct tcf_proto *tp, struct cls_fl_filter *f)
diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c
index a8853ada22f6..174c700160ca 100644
--- a/net/sched/cls_matchall.c
+++ b/net/sched/cls_matchall.c
@@ -58,14 +58,14 @@ static int mall_replace_hw_filter(struct tcf_proto *tp,
struct tc_cls_matchall_offload mall_offload = {0};
int err;
+ tc_cls_common_offload_init(&mall_offload.common, tp);
offload.cls_mall = &mall_offload;
offload.cls_mall->command = TC_CLSMATCHALL_REPLACE;
offload.cls_mall->exts = &head->exts;
offload.cls_mall->cookie = cookie;
err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSMATCHALL,
- tp->q->handle, tp->chain->index,
- tp->protocol, &offload);
+ &offload);
if (!err)
head->flags |= TCA_CLS_FLAGS_IN_HW;
@@ -80,13 +80,13 @@ static void mall_destroy_hw_filter(struct tcf_proto *tp,
struct tc_to_netdev offload;
struct tc_cls_matchall_offload mall_offload = {0};
+ tc_cls_common_offload_init(&mall_offload.common, tp);
offload.cls_mall = &mall_offload;
offload.cls_mall->command = TC_CLSMATCHALL_DESTROY;
offload.cls_mall->exts = NULL;
offload.cls_mall->cookie = cookie;
- dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSMATCHALL, tp->q->handle,
- tp->chain->index, tp->protocol, &offload);
+ dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSMATCHALL, &offload);
}
static void mall_destroy(struct tcf_proto *tp)
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index d1bae4cc749f..c0f59c471523 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -437,11 +437,10 @@ static void u32_remove_hw_knode(struct tcf_proto *tp, u32 handle)
offload.cls_u32 = &u32_offload;
if (tc_should_offload(dev, tp, 0)) {
+ tc_cls_common_offload_init(&u32_offload.common, tp);
offload.cls_u32->command = TC_CLSU32_DELETE_KNODE;
offload.cls_u32->knode.handle = handle;
- dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSU32,
- tp->q->handle, tp->chain->index,
- tp->protocol, &offload);
+ dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSU32, &offload);
}
}
@@ -458,14 +457,13 @@ static int u32_replace_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h,
offload.cls_u32 = &u32_offload;
+ tc_cls_common_offload_init(&u32_offload.common, tp);
offload.cls_u32->command = TC_CLSU32_NEW_HNODE;
offload.cls_u32->hnode.divisor = h->divisor;
offload.cls_u32->hnode.handle = h->handle;
offload.cls_u32->hnode.prio = h->prio;
- err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSU32, tp->q->handle,
- tp->chain->index, tp->protocol,
- &offload);
+ err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSU32, &offload);
if (tc_skip_sw(flags))
return err;
@@ -481,14 +479,13 @@ static void u32_clear_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h)
offload.cls_u32 = &u32_offload;
if (tc_should_offload(dev, tp, 0)) {
+ tc_cls_common_offload_init(&u32_offload.common, tp);
offload.cls_u32->command = TC_CLSU32_DELETE_HNODE;
offload.cls_u32->hnode.divisor = h->divisor;
offload.cls_u32->hnode.handle = h->handle;
offload.cls_u32->hnode.prio = h->prio;
- dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSU32,
- tp->q->handle, tp->chain->index,
- tp->protocol, &offload);
+ dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSU32, &offload);
}
}
@@ -505,6 +502,7 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,
if (!tc_should_offload(dev, tp, flags))
return tc_skip_sw(flags) ? -EINVAL : 0;
+ tc_cls_common_offload_init(&u32_offload.common, tp);
offload.cls_u32->command = TC_CLSU32_REPLACE_KNODE;
offload.cls_u32->knode.handle = n->handle;
offload.cls_u32->knode.fshift = n->fshift;
@@ -520,9 +518,7 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,
if (n->ht_down)
offload.cls_u32->knode.link_handle = n->ht_down->handle;
- err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSU32, tp->q->handle,
- tp->chain->index, tp->protocol,
- &offload);
+ err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSU32, &offload);
if (!err)
n->flags |= TCA_CLS_FLAGS_IN_HW;
diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
index 329610ce4dfe..09b577dde49c 100644
--- a/net/sched/sch_mqprio.c
+++ b/net/sched/sch_mqprio.c
@@ -42,8 +42,7 @@ static void mqprio_destroy(struct Qdisc *sch)
struct tc_mqprio_qopt offload = { 0 };
struct tc_to_netdev tc = { { .mqprio = &offload } };
- dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_MQPRIO,
- sch->handle, 0, 0, &tc);
+ dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_MQPRIO, &tc);
} else {
netdev_set_num_tc(dev, 0);
}
@@ -151,8 +150,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt)
struct tc_mqprio_qopt offload = *qopt;
struct tc_to_netdev tc = { { .mqprio = &offload } };
- err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_MQPRIO,
- sch->handle, 0, 0, &tc);
+ err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_MQPRIO, &tc);
if (err)
return err;