Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Jamal Hadi Salim | 200e10f | 2016-02-27 08:08:56 -0500 | [diff] [blame] | 2 | /* |
| 3 | * net/sched/act_meta_prio.c IFE skb->priority metadata module |
| 4 | * |
Jamal Hadi Salim | 200e10f | 2016-02-27 08:08:56 -0500 | [diff] [blame] | 5 | * copyright Jamal Hadi Salim (2015) |
Jamal Hadi Salim | 200e10f | 2016-02-27 08:08:56 -0500 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <linux/types.h> |
| 9 | #include <linux/kernel.h> |
| 10 | #include <linux/string.h> |
| 11 | #include <linux/errno.h> |
| 12 | #include <linux/skbuff.h> |
| 13 | #include <linux/rtnetlink.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <net/netlink.h> |
| 17 | #include <net/pkt_sched.h> |
| 18 | #include <uapi/linux/tc_act/tc_ife.h> |
| 19 | #include <net/tc_act/tc_ife.h> |
| 20 | |
| 21 | static int skbprio_check(struct sk_buff *skb, struct tcf_meta_info *e) |
| 22 | { |
| 23 | return ife_check_meta_u32(skb->priority, e); |
| 24 | } |
| 25 | |
| 26 | static int skbprio_encode(struct sk_buff *skb, void *skbdata, |
| 27 | struct tcf_meta_info *e) |
| 28 | { |
| 29 | u32 ifeprio = skb->priority; /* avoid having to cast skb->priority*/ |
| 30 | |
| 31 | return ife_encode_meta_u32(ifeprio, skbdata, e); |
| 32 | } |
| 33 | |
| 34 | static int skbprio_decode(struct sk_buff *skb, void *data, u16 len) |
| 35 | { |
| 36 | u32 ifeprio = *(u32 *)data; |
| 37 | |
| 38 | skb->priority = ntohl(ifeprio); |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | static struct tcf_meta_ops ife_prio_ops = { |
| 43 | .metaid = IFE_META_PRIO, |
| 44 | .metatype = NLA_U32, |
| 45 | .name = "skbprio", |
| 46 | .synopsis = "skb prio metadata", |
| 47 | .check_presence = skbprio_check, |
| 48 | .encode = skbprio_encode, |
| 49 | .decode = skbprio_decode, |
| 50 | .get = ife_get_meta_u32, |
| 51 | .alloc = ife_alloc_meta_u32, |
| 52 | .owner = THIS_MODULE, |
| 53 | }; |
| 54 | |
| 55 | static int __init ifeprio_init_module(void) |
| 56 | { |
| 57 | return register_ife_op(&ife_prio_ops); |
| 58 | } |
| 59 | |
| 60 | static void __exit ifeprio_cleanup_module(void) |
| 61 | { |
| 62 | unregister_ife_op(&ife_prio_ops); |
| 63 | } |
| 64 | |
| 65 | module_init(ifeprio_init_module); |
| 66 | module_exit(ifeprio_cleanup_module); |
| 67 | |
| 68 | MODULE_AUTHOR("Jamal Hadi Salim(2015)"); |
| 69 | MODULE_DESCRIPTION("Inter-FE skb prio metadata action"); |
| 70 | MODULE_LICENSE("GPL"); |
Roman Mashak | 8f04748 | 2017-10-11 10:50:29 -0400 | [diff] [blame] | 71 | MODULE_ALIAS_IFE_META("skbprio"); |