Skip to content

Commit 6843e7a

Browse files
jrfastabdavem330
authored andcommitted
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: John Fastabend <john.r.fastabend@intel.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d2e42a1 commit 6843e7a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

include/net/pkt_cls.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,4 +392,9 @@ struct tc_cls_u32_offload {
392392
};
393393
};
394394

395+
static inline bool tc_should_offload(struct net_device *dev)
396+
{
397+
return dev->netdev_ops->ndo_setup_tc;
398+
}
399+
395400
#endif

net/sched/cls_u32.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ static void u32_remove_hw_knode(struct tcf_proto *tp, u32 handle)
434434
offload.type = TC_SETUP_CLSU32;
435435
offload.cls_u32 = &u32_offload;
436436

437-
if (dev->netdev_ops->ndo_setup_tc) {
437+
if (tc_should_offload(dev)) {
438438
offload.cls_u32->command = TC_CLSU32_DELETE_KNODE;
439439
offload.cls_u32->knode.handle = handle;
440440
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)
451451
offload.type = TC_SETUP_CLSU32;
452452
offload.cls_u32 = &u32_offload;
453453

454-
if (dev->netdev_ops->ndo_setup_tc) {
454+
if (tc_should_offload(dev)) {
455455
offload.cls_u32->command = TC_CLSU32_NEW_HNODE;
456456
offload.cls_u32->hnode.divisor = h->divisor;
457457
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)
471471
offload.type = TC_SETUP_CLSU32;
472472
offload.cls_u32 = &u32_offload;
473473

474-
if (dev->netdev_ops->ndo_setup_tc) {
474+
if (tc_should_offload(dev)) {
475475
offload.cls_u32->command = TC_CLSU32_DELETE_HNODE;
476476
offload.cls_u32->hnode.divisor = h->divisor;
477477
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)
491491
offload.type = TC_SETUP_CLSU32;
492492
offload.cls_u32 = &u32_offload;
493493

494-
if (dev->netdev_ops->ndo_setup_tc) {
494+
if (tc_should_offload(dev)) {
495495
offload.cls_u32->command = TC_CLSU32_REPLACE_KNODE;
496496
offload.cls_u32->knode.handle = n->handle;
497497
offload.cls_u32->knode.fshift = n->fshift;

0 commit comments

Comments
 (0)