1 /* Broadcom NetXtreme-C/E network driver.
3 * Copyright (c) 2017 Broadcom Limited
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation.
13 #ifdef CONFIG_BNXT_FLOWER_OFFLOAD
15 /* Structs used for storing the filter/actions of the TC cmd.
17 struct bnxt_tc_l2_key {
20 __be16 inner_vlan_tpid;
21 __be16 inner_vlan_tci;
26 struct bnxt_tc_l3_key {
33 struct in6_addr daddr;
34 struct in6_addr saddr;
39 struct bnxt_tc_l4_key {
53 struct bnxt_tc_actions {
55 #define BNXT_TC_ACTION_FLAG_FWD BIT(0)
56 #define BNXT_TC_ACTION_FLAG_FWD_VXLAN BIT(1)
57 #define BNXT_TC_ACTION_FLAG_PUSH_VLAN BIT(3)
58 #define BNXT_TC_ACTION_FLAG_POP_VLAN BIT(4)
59 #define BNXT_TC_ACTION_FLAG_DROP BIT(5)
62 struct net_device *dst_dev;
63 __be16 push_vlan_tpid;
67 struct bnxt_tc_flow_stats {
74 #define BNXT_TC_FLOW_FLAGS_ETH_ADDRS BIT(1)
75 #define BNXT_TC_FLOW_FLAGS_IPV4_ADDRS BIT(2)
76 #define BNXT_TC_FLOW_FLAGS_IPV6_ADDRS BIT(3)
77 #define BNXT_TC_FLOW_FLAGS_PORTS BIT(4)
78 #define BNXT_TC_FLOW_FLAGS_ICMP BIT(5)
80 /* flow applicable to pkts ingressing on this fid */
82 struct bnxt_tc_l2_key l2_key;
83 struct bnxt_tc_l2_key l2_mask;
84 struct bnxt_tc_l3_key l3_key;
85 struct bnxt_tc_l3_key l3_mask;
86 struct bnxt_tc_l4_key l4_key;
87 struct bnxt_tc_l4_key l4_mask;
89 struct bnxt_tc_actions actions;
91 /* updated stats accounting for hw-counter wrap-around */
92 struct bnxt_tc_flow_stats stats;
93 /* previous snap-shot of stats */
94 struct bnxt_tc_flow_stats prev_stats;
95 unsigned long lastused; /* jiffies */
99 * This data-struct is used for L2-flow table.
100 * The L2 part of a flow is stored in a hash table.
101 * A flow that shares the same L2 key/mask with an
102 * already existing flow must refer to it's flow handle.
104 struct bnxt_tc_l2_node {
105 /* hash key: first 16b of key */
106 #define BNXT_TC_L2_KEY_LEN 16
107 struct bnxt_tc_l2_key key;
108 struct rhash_head node;
110 /* a linked list of flows that share the same l2 key */
111 struct list_head common_l2_flows;
113 /* number of flows sharing the l2 key */
119 struct bnxt_tc_flow_node {
120 /* hash key: provided by TC */
121 unsigned long cookie;
122 struct rhash_head node;
124 struct bnxt_tc_flow flow;
128 /* L2 node in l2 hashtable that shares flow's l2 key */
129 struct bnxt_tc_l2_node *l2_node;
130 /* for the shared_flows list maintained in l2_node */
131 struct list_head l2_list_node;
136 int bnxt_tc_setup_flower(struct bnxt *bp, u16 src_fid,
137 struct tc_cls_flower_offload *cls_flower);
138 int bnxt_init_tc(struct bnxt *bp);
139 void bnxt_shutdown_tc(struct bnxt *bp);
141 #else /* CONFIG_BNXT_FLOWER_OFFLOAD */
143 static inline int bnxt_tc_setup_flower(struct bnxt *bp, u16 src_fid,
144 struct tc_cls_flower_offload *cls_flower)
149 static inline int bnxt_init_tc(struct bnxt *bp)
154 static inline void bnxt_shutdown_tc(struct bnxt *bp)
157 #endif /* CONFIG_BNXT_FLOWER_OFFLOAD */
158 #endif /* BNXT_TC_H */