Commit 6843e7a2 authored by John Fastabend's avatar John Fastabend Committed by David S. Miller

net: sched: consolidate offload decision in cls_u32

The offload decision was originally very basic and tied to if the dev
implemented the appropriate ndo op hook. The next step is to allow
the user to more flexibly define if any paticular rule should be
offloaded or not. In order to have this logic in one function lift
the current check into a helper routine tc_should_offload().
Signed-off-by: default avatarJohn Fastabend <john.r.fastabend@intel.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d2e42a17
...@@ -392,4 +392,9 @@ struct tc_cls_u32_offload { ...@@ -392,4 +392,9 @@ struct tc_cls_u32_offload {
}; };
}; };
static inline bool tc_should_offload(struct net_device *dev)
{
return dev->netdev_ops->ndo_setup_tc;
}
#endif #endif
...@@ -434,7 +434,7 @@ static void u32_remove_hw_knode(struct tcf_proto *tp, u32 handle) ...@@ -434,7 +434,7 @@ static void u32_remove_hw_knode(struct tcf_proto *tp, u32 handle)
offload.type = TC_SETUP_CLSU32; offload.type = TC_SETUP_CLSU32;
offload.cls_u32 = &u32_offload; offload.cls_u32 = &u32_offload;
if (dev->netdev_ops->ndo_setup_tc) { if (tc_should_offload(dev)) {
offload.cls_u32->command = TC_CLSU32_DELETE_KNODE; offload.cls_u32->command = TC_CLSU32_DELETE_KNODE;
offload.cls_u32->knode.handle = handle; offload.cls_u32->knode.handle = handle;
dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle,
...@@ -451,7 +451,7 @@ static void u32_replace_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h) ...@@ -451,7 +451,7 @@ static void u32_replace_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h)
offload.type = TC_SETUP_CLSU32; offload.type = TC_SETUP_CLSU32;
offload.cls_u32 = &u32_offload; offload.cls_u32 = &u32_offload;
if (dev->netdev_ops->ndo_setup_tc) { if (tc_should_offload(dev)) {
offload.cls_u32->command = TC_CLSU32_NEW_HNODE; offload.cls_u32->command = TC_CLSU32_NEW_HNODE;
offload.cls_u32->hnode.divisor = h->divisor; offload.cls_u32->hnode.divisor = h->divisor;
offload.cls_u32->hnode.handle = h->handle; offload.cls_u32->hnode.handle = h->handle;
...@@ -471,7 +471,7 @@ static void u32_clear_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h) ...@@ -471,7 +471,7 @@ static void u32_clear_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h)
offload.type = TC_SETUP_CLSU32; offload.type = TC_SETUP_CLSU32;
offload.cls_u32 = &u32_offload; offload.cls_u32 = &u32_offload;
if (dev->netdev_ops->ndo_setup_tc) { if (tc_should_offload(dev)) {
offload.cls_u32->command = TC_CLSU32_DELETE_HNODE; offload.cls_u32->command = TC_CLSU32_DELETE_HNODE;
offload.cls_u32->hnode.divisor = h->divisor; offload.cls_u32->hnode.divisor = h->divisor;
offload.cls_u32->hnode.handle = h->handle; offload.cls_u32->hnode.handle = h->handle;
...@@ -491,7 +491,7 @@ static void u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n) ...@@ -491,7 +491,7 @@ static void u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n)
offload.type = TC_SETUP_CLSU32; offload.type = TC_SETUP_CLSU32;
offload.cls_u32 = &u32_offload; offload.cls_u32 = &u32_offload;
if (dev->netdev_ops->ndo_setup_tc) { if (tc_should_offload(dev)) {
offload.cls_u32->command = TC_CLSU32_REPLACE_KNODE; offload.cls_u32->command = TC_CLSU32_REPLACE_KNODE;
offload.cls_u32->knode.handle = n->handle; offload.cls_u32->knode.handle = n->handle;
offload.cls_u32->knode.fshift = n->fshift; offload.cls_u32->knode.fshift = n->fshift;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment