0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #ifndef __CXGB4_TC_FLOWER_H
0036 #define __CXGB4_TC_FLOWER_H
0037
0038 #include <net/pkt_cls.h>
0039
0040 struct ch_tc_flower_stats {
0041 u64 prev_packet_count;
0042 u64 packet_count;
0043 u64 byte_count;
0044 u64 last_used;
0045 };
0046
0047 struct ch_tc_flower_entry {
0048 struct ch_filter_specification fs;
0049 struct ch_tc_flower_stats stats;
0050 unsigned long tc_flower_cookie;
0051 struct rhash_head node;
0052 struct rcu_head rcu;
0053 spinlock_t lock;
0054 u32 filter_id;
0055 };
0056
0057 enum {
0058 ETH_DMAC_31_0,
0059 ETH_DMAC_47_32,
0060 ETH_SMAC_15_0,
0061 ETH_SMAC_47_16,
0062
0063 IP4_SRC,
0064 IP4_DST,
0065
0066 IP6_SRC_31_0,
0067 IP6_SRC_63_32,
0068 IP6_SRC_95_64,
0069 IP6_SRC_127_96,
0070
0071 IP6_DST_31_0,
0072 IP6_DST_63_32,
0073 IP6_DST_95_64,
0074 IP6_DST_127_96,
0075
0076 TCP_SPORT,
0077 TCP_DPORT,
0078
0079 UDP_SPORT,
0080 UDP_DPORT,
0081 };
0082
0083 struct ch_tc_pedit_fields {
0084 u8 field;
0085 u8 size;
0086 u32 offset;
0087 };
0088
0089 #define PEDIT_FIELDS(type, field, size, fs_field, offset) \
0090 { type## field, size, \
0091 offsetof(struct ch_filter_specification, fs_field) + (offset) }
0092
0093 #define PEDIT_ETH_DMAC_MASK 0xffff
0094 #define PEDIT_TCP_UDP_SPORT_MASK 0xffff
0095 #define PEDIT_ETH_DMAC_31_0 0x0
0096 #define PEDIT_ETH_DMAC_47_32_SMAC_15_0 0x4
0097 #define PEDIT_ETH_SMAC_47_16 0x8
0098 #define PEDIT_IP4_SRC 0xC
0099 #define PEDIT_IP4_DST 0x10
0100 #define PEDIT_IP6_SRC_31_0 0x8
0101 #define PEDIT_IP6_SRC_63_32 0xC
0102 #define PEDIT_IP6_SRC_95_64 0x10
0103 #define PEDIT_IP6_SRC_127_96 0x14
0104 #define PEDIT_IP6_DST_31_0 0x18
0105 #define PEDIT_IP6_DST_63_32 0x1C
0106 #define PEDIT_IP6_DST_95_64 0x20
0107 #define PEDIT_IP6_DST_127_96 0x24
0108 #define PEDIT_TCP_SPORT_DPORT 0x0
0109 #define PEDIT_UDP_SPORT_DPORT 0x0
0110
0111 enum cxgb4_action_natmode_flags {
0112 CXGB4_ACTION_NATMODE_NONE = 0,
0113 CXGB4_ACTION_NATMODE_DIP = (1 << 0),
0114 CXGB4_ACTION_NATMODE_SIP = (1 << 1),
0115 CXGB4_ACTION_NATMODE_DPORT = (1 << 2),
0116 CXGB4_ACTION_NATMODE_SPORT = (1 << 3),
0117 };
0118
0119
0120 struct cxgb4_natmode_config {
0121 enum chip_type chip;
0122 u8 flags;
0123 u8 natmode;
0124 };
0125
0126 void cxgb4_process_flow_actions(struct net_device *in,
0127 struct flow_action *actions,
0128 struct ch_filter_specification *fs);
0129 int cxgb4_validate_flow_actions(struct net_device *dev,
0130 struct flow_action *actions,
0131 struct netlink_ext_ack *extack,
0132 u8 matchall_filter);
0133
0134 int cxgb4_tc_flower_replace(struct net_device *dev,
0135 struct flow_cls_offload *cls);
0136 int cxgb4_tc_flower_destroy(struct net_device *dev,
0137 struct flow_cls_offload *cls);
0138 int cxgb4_tc_flower_stats(struct net_device *dev,
0139 struct flow_cls_offload *cls);
0140 int cxgb4_flow_rule_replace(struct net_device *dev, struct flow_rule *rule,
0141 u32 tc_prio, struct netlink_ext_ack *extack,
0142 struct ch_filter_specification *fs, u32 *tid);
0143 int cxgb4_flow_rule_destroy(struct net_device *dev, u32 tc_prio,
0144 struct ch_filter_specification *fs, int tid);
0145
0146 int cxgb4_init_tc_flower(struct adapter *adap);
0147 void cxgb4_cleanup_tc_flower(struct adapter *adap);
0148 #endif