blob: 12b34bb3a3ccac92611372a3f1930d21dbe0bb31 [file] [log] [blame]
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +05301/*
2 * sfe_flow_cookie.h
3 * Flow cookie related callbacks.
4 *
5 * Copyright (c) 2013-2016, 2019-2020, The Linux Foundation. All rights reserved.
6 * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
7 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
21#ifdef CONFIG_NF_FLOW_COOKIE
22#define SFE_FLOW_COOKIE_SIZE 2048
23#define SFE_FLOW_COOKIE_MASK 0x7ff
24
25struct sfe_ipv4_connection_match;
26struct sfe_ipv6_connection_match;
27
28struct sfe_flow_cookie_entry {
29 struct sfe_ipv4_connection_match *match;
30 unsigned long last_clean_time;
31};
32
33struct sfe_ipv6_flow_cookie_entry {
34 struct sfe_ipv6_connection_match *match;
35 unsigned long last_clean_time;
36};
37
38typedef int (*flow_cookie_set_func_t)(u32 protocol, __be32 src_ip, __be16 src_port,
39 __be32 dst_ip, __be16 dst_port, u16 flow_cookie);
40/*
41 * sfe_register_flow_cookie_cb
42 * register a function in SFE to let SFE use this function to configure flow cookie for a flow
43 *
44 * Hardware driver which support flow cookie should register a callback function in SFE. Then SFE
45 * can use this function to configure flow cookie for a flow.
46 * return: 0, success; !=0, fail
47 */
48int sfe_register_flow_cookie_cb(flow_cookie_set_func_t cb);
49
50/*
51 * sfe_unregister_flow_cookie_cb
52 * unregister function which is used to configure flow cookie for a flow
53 *
54 * return: 0, success; !=0, fail
55 */
56int sfe_unregister_flow_cookie_cb(flow_cookie_set_func_t cb);
57
58typedef int (*sfe_ipv6_flow_cookie_set_func_t)(u32 protocol, __be32 src_ip[4], __be16 src_port,
59 __be32 dst_ip[4], __be16 dst_port, u16 flow_cookie);
60
61/*
62 * sfe_ipv6_register_flow_cookie_cb
63 * register a function in SFE to let SFE use this function to configure flow cookie for a flow
64 *
65 * Hardware driver which support flow cookie should register a callback function in SFE. Then SFE
66 * can use this function to configure flow cookie for a flow.
67 * return: 0, success; !=0, fail
68 */
69int sfe_ipv6_register_flow_cookie_cb(sfe_ipv6_flow_cookie_set_func_t cb);
70
71/*
72 * sfe_ipv6_unregister_flow_cookie_cb
73 * unregister function which is used to configure flow cookie for a flow
74 *
75 * return: 0, success; !=0, fail
76 */
77int sfe_ipv6_unregister_flow_cookie_cb(sfe_ipv6_flow_cookie_set_func_t cb);
78
79#endif /*CONFIG_NF_FLOW_COOKIE*/