| @@ -59,6 +59,7 @@ struct tc_u_knode { · 58 unmodified lines |
| 59 | 59 | #ifdef CONFIG_CLS_U32_PERF |
| 60 | 60 | struct tc_u32_pcnt __percpu *pf; |
| 61 | 61 | #endif |
| 62 | + u32 flags; |
| 62 | 63 | #ifdef CONFIG_CLS_U32_MARK |
| 63 | 64 | u32 val; |
| 64 | 65 | u32 mask; |
| @@ -434,7 +435,7 @@ static void u32_remove_hw_knode(struct tcf_proto *tp, u32 handle) · 369 unmodified lines |
| 434 | 435 | offload.type = TC_SETUP_CLSU32; |
| 435 | 436 | offload.cls_u32 = &u32_offload; |
| 436 | 437 | |
| 437 | | − if (tc_should_offload(dev)) { |
| 438 | + if (tc_should_offload(dev, 0)) { |
| 438 | 439 | offload.cls_u32->command = TC_CLSU32_DELETE_KNODE; |
| 439 | 440 | offload.cls_u32->knode.handle = handle; |
| 440 | 441 | dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, |
| @@ -442,7 +443,9 @@ static void u32_remove_hw_knode(struct tcf_proto *tp, u32 handle) · 1 unmodified line |
| 442 | 443 | } |
| 443 | 444 | } |
| 444 | 445 | |
| 445 | | −static void u32_replace_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h) |
| 446 | +static void u32_replace_hw_hnode(struct tcf_proto *tp, |
| 447 | + struct tc_u_hnode *h, |
| 448 | + u32 flags) |
| 446 | 449 | { |
| 447 | 450 | struct net_device *dev = tp->q->dev_queue->dev; |
| 448 | 451 | struct tc_cls_u32_offload u32_offload = {0}; |
| @@ -451,7 +454,7 @@ static void u32_replace_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h) · 2 unmodified lines |
| 451 | 454 | offload.type = TC_SETUP_CLSU32; |
| 452 | 455 | offload.cls_u32 = &u32_offload; |
| 453 | 456 | |
| 454 | | − if (tc_should_offload(dev)) { |
| 457 | + if (tc_should_offload(dev, flags)) { |
| 455 | 458 | offload.cls_u32->command = TC_CLSU32_NEW_HNODE; |
| 456 | 459 | offload.cls_u32->hnode.divisor = h->divisor; |
| 457 | 460 | offload.cls_u32->hnode.handle = h->handle; |
| @@ -471,7 +474,7 @@ static void u32_clear_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h) · 13 unmodified lines |
| 471 | 474 | offload.type = TC_SETUP_CLSU32; |
| 472 | 475 | offload.cls_u32 = &u32_offload; |
| 473 | 476 | |
| 474 | | − if (tc_should_offload(dev)) { |
| 477 | + if (tc_should_offload(dev, 0)) { |
| 475 | 478 | offload.cls_u32->command = TC_CLSU32_DELETE_HNODE; |
| 476 | 479 | offload.cls_u32->hnode.divisor = h->divisor; |
| 477 | 480 | offload.cls_u32->hnode.handle = h->handle; |
| @@ -482,7 +485,9 @@ static void u32_clear_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h) · 4 unmodified lines |
| 482 | 485 | } |
| 483 | 486 | } |
| 484 | 487 | |
| 485 | | −static void u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n) |
| 488 | +static void u32_replace_hw_knode(struct tcf_proto *tp, |
| 489 | + struct tc_u_knode *n, |
| 490 | + u32 flags) |
| 486 | 491 | { |
| 487 | 492 | struct net_device *dev = tp->q->dev_queue->dev; |
| 488 | 493 | struct tc_cls_u32_offload u32_offload = {0}; |
| @@ -491,7 +496,7 @@ static void u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n) · 2 unmodified lines |
| 491 | 496 | offload.type = TC_SETUP_CLSU32; |
| 492 | 497 | offload.cls_u32 = &u32_offload; |
| 493 | 498 | |
| 494 | | − if (tc_should_offload(dev)) { |
| 499 | + if (tc_should_offload(dev, flags)) { |
| 495 | 500 | offload.cls_u32->command = TC_CLSU32_REPLACE_KNODE; |
| 496 | 501 | offload.cls_u32->knode.handle = n->handle; |
| 497 | 502 | offload.cls_u32->knode.fshift = n->fshift; |
| @@ -679,6 +684,7 @@ static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { · 181 unmodified lines |
| 679 | 684 | [TCA_U32_SEL] = { .len = sizeof(struct tc_u32_sel) }, |
| 680 | 685 | [TCA_U32_INDEV] = { .type = NLA_STRING, .len = IFNAMSIZ }, |
| 681 | 686 | [TCA_U32_MARK] = { .len = sizeof(struct tc_u32_mark) }, |
| 687 | + [TCA_U32_FLAGS] = { .type = NLA_U32 }, |
| 682 | 688 | }; |
| 683 | 689 | |
| 684 | 690 | static int u32_set_parms(struct net *net, struct tcf_proto *tp, |
| @@ -786,6 +792,7 @@ static struct tc_u_knode *u32_init_knode(struct tcf_proto *tp, · 101 unmodified lines |
| 786 | 792 | #endif |
| 787 | 793 | new->fshift = n->fshift; |
| 788 | 794 | new->res = n->res; |
| 795 | + new->flags = n->flags; |
| 789 | 796 | RCU_INIT_POINTER(new->ht_down, n->ht_down); |
| 790 | 797 | |
| 791 | 798 | /* bump reference count as long as we hold pointer to structure */ |
| @@ -825,7 +832,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, · 33 unmodified lines |
| 825 | 832 | struct tc_u32_sel *s; |
| 826 | 833 | struct nlattr *opt = tca[TCA_OPTIONS]; |
| 827 | 834 | struct nlattr *tb[TCA_U32_MAX + 1]; |
| 828 | | − u32 htid; |
| 835 | + u32 htid, flags = 0; |
| 829 | 836 | int err; |
| 830 | 837 | #ifdef CONFIG_CLS_U32_PERF |
| 831 | 838 | size_t size; |
| @@ -838,6 +845,9 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, · 6 unmodified lines |
| 838 | 845 | if (err < 0) |
| 839 | 846 | return err; |
| 840 | 847 | |
| 848 | + if (tb[TCA_U32_FLAGS]) |
| 849 | + flags = nla_get_u32(tb[TCA_U32_FLAGS]); |
| 850 | + |
| 841 | 851 | n = (struct tc_u_knode *)*arg; |
| 842 | 852 | if (n) { |
| 843 | 853 | struct tc_u_knode *new; |
| @@ -845,6 +855,9 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, · 1 unmodified line |
| 845 | 855 | if (TC_U32_KEY(n->handle) == 0) |
| 846 | 856 | return -EINVAL; |
| 847 | 857 | |
| 858 | + if (n->flags != flags) |
| 859 | + return -EINVAL; |
| 860 | + |
| 848 | 861 | new = u32_init_knode(tp, n); |
| 849 | 862 | if (!new) |
| 850 | 863 | return -ENOMEM; |
| @@ -861,7 +874,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, · 10 unmodified lines |
| 861 | 874 | u32_replace_knode(tp, tp_c, new); |
| 862 | 875 | tcf_unbind_filter(tp, &n->res); |
| 863 | 876 | call_rcu(&n->rcu, u32_delete_key_rcu); |
| 864 | | − u32_replace_hw_knode(tp, new); |
| 877 | + u32_replace_hw_knode(tp, new, flags); |
| 865 | 878 | return 0; |
| 866 | 879 | } |
| 867 | 880 | |
| @@ -889,7 +902,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, · 21 unmodified lines |
| 889 | 902 | rcu_assign_pointer(tp_c->hlist, ht); |
| 890 | 903 | *arg = (unsigned long)ht; |
| 891 | 904 | |
| 892 | | − u32_replace_hw_hnode(tp, ht); |
| 905 | + u32_replace_hw_hnode(tp, ht, flags); |
| 893 | 906 | return 0; |
| 894 | 907 | } |
| 895 | 908 | |
| @@ -940,6 +953,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, · 44 unmodified lines |
| 940 | 953 | RCU_INIT_POINTER(n->ht_up, ht); |
| 941 | 954 | n->handle = handle; |
| 942 | 955 | n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0; |
| 956 | + n->flags = flags; |
| 943 | 957 | tcf_exts_init(&n->exts, TCA_U32_ACT, TCA_U32_POLICE); |
| 944 | 958 | n->tp = tp; |
| 945 | 959 | |
| @@ -972,7 +986,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, · 26 unmodified lines |
| 972 | 986 | |
| 973 | 987 | RCU_INIT_POINTER(n->next, pins); |
| 974 | 988 | rcu_assign_pointer(*ins, n); |
| 975 | | − u32_replace_hw_knode(tp, n); |
| 989 | + u32_replace_hw_knode(tp, n, flags); |
| 976 | 990 | *arg = (unsigned long)n; |
| 977 | 991 | return 0; |
| 978 | 992 | } |
| @@ -1077,6 +1091,9 @@ static int u32_dump(struct net *net, struct tcf_proto *tp, unsigned long fh, · 98 unmodified lines |
| 1077 | 1091 | nla_put_u32(skb, TCA_U32_LINK, ht_down->handle)) |
| 1078 | 1092 | goto nla_put_failure; |
| 1079 | 1093 | |
| 1094 | + if (n->flags && nla_put_u32(skb, TCA_U32_FLAGS, n->flags)) |
| 1095 | + goto nla_put_failure; |
| 1096 | + |
| 1080 | 1097 | #ifdef CONFIG_CLS_U32_MARK |
| 1081 | 1098 | if ((n->val || n->mask)) { |
| 1082 | 1099 | struct tc_u32_mark mark = {.val = n->val, |