0001
0002
0003
0004 #ifndef _ICE_TC_LIB_H_
0005 #define _ICE_TC_LIB_H_
0006
0007 #define ICE_TC_FLWR_FIELD_DST_MAC BIT(0)
0008 #define ICE_TC_FLWR_FIELD_SRC_MAC BIT(1)
0009 #define ICE_TC_FLWR_FIELD_VLAN BIT(2)
0010 #define ICE_TC_FLWR_FIELD_DEST_IPV4 BIT(3)
0011 #define ICE_TC_FLWR_FIELD_SRC_IPV4 BIT(4)
0012 #define ICE_TC_FLWR_FIELD_DEST_IPV6 BIT(5)
0013 #define ICE_TC_FLWR_FIELD_SRC_IPV6 BIT(6)
0014 #define ICE_TC_FLWR_FIELD_DEST_L4_PORT BIT(7)
0015 #define ICE_TC_FLWR_FIELD_SRC_L4_PORT BIT(8)
0016 #define ICE_TC_FLWR_FIELD_TENANT_ID BIT(9)
0017 #define ICE_TC_FLWR_FIELD_ENC_DEST_IPV4 BIT(10)
0018 #define ICE_TC_FLWR_FIELD_ENC_SRC_IPV4 BIT(11)
0019 #define ICE_TC_FLWR_FIELD_ENC_DEST_IPV6 BIT(12)
0020 #define ICE_TC_FLWR_FIELD_ENC_SRC_IPV6 BIT(13)
0021 #define ICE_TC_FLWR_FIELD_ENC_DEST_L4_PORT BIT(14)
0022 #define ICE_TC_FLWR_FIELD_ENC_SRC_L4_PORT BIT(15)
0023 #define ICE_TC_FLWR_FIELD_ENC_DST_MAC BIT(16)
0024 #define ICE_TC_FLWR_FIELD_ETH_TYPE_ID BIT(17)
0025 #define ICE_TC_FLWR_FIELD_ENC_OPTS BIT(18)
0026 #define ICE_TC_FLWR_FIELD_CVLAN BIT(19)
0027 #define ICE_TC_FLWR_FIELD_PPPOE_SESSID BIT(20)
0028 #define ICE_TC_FLWR_FIELD_PPP_PROTO BIT(21)
0029
0030 #define ICE_TC_FLOWER_MASK_32 0xFFFFFFFF
0031
0032 struct ice_indr_block_priv {
0033 struct net_device *netdev;
0034 struct ice_netdev_priv *np;
0035 struct list_head list;
0036 };
0037
0038 struct ice_tc_flower_action {
0039 u32 tc_class;
0040 enum ice_sw_fwd_act_type fltr_act;
0041 };
0042
0043 struct ice_tc_vlan_hdr {
0044 __be16 vlan_id;
0045 u16 vlan_prio;
0046 __be16 vlan_tpid;
0047 };
0048
0049 struct ice_tc_pppoe_hdr {
0050 __be16 session_id;
0051 __be16 ppp_proto;
0052 };
0053
0054 struct ice_tc_l2_hdr {
0055 u8 dst_mac[ETH_ALEN];
0056 u8 src_mac[ETH_ALEN];
0057 __be16 n_proto;
0058 };
0059
0060 struct ice_tc_l3_hdr {
0061 u8 ip_proto;
0062 union {
0063 struct {
0064 struct in_addr dst_ip;
0065 struct in_addr src_ip;
0066 } v4;
0067 struct {
0068 struct in6_addr dst_ip6;
0069 struct in6_addr src_ip6;
0070 } v6;
0071 } ip;
0072 #define dst_ipv6 ip.v6.dst_ip6.s6_addr32
0073 #define dst_ipv6_addr ip.v6.dst_ip6.s6_addr
0074 #define src_ipv6 ip.v6.src_ip6.s6_addr32
0075 #define src_ipv6_addr ip.v6.src_ip6.s6_addr
0076 #define dst_ipv4 ip.v4.dst_ip.s_addr
0077 #define src_ipv4 ip.v4.src_ip.s_addr
0078
0079 u8 tos;
0080 u8 ttl;
0081 };
0082
0083 struct ice_tc_l4_hdr {
0084 __be16 dst_port;
0085 __be16 src_port;
0086 };
0087
0088 struct ice_tc_flower_lyr_2_4_hdrs {
0089
0090 struct ice_tc_l2_hdr l2_key;
0091 struct ice_tc_l2_hdr l2_mask;
0092 struct ice_tc_vlan_hdr vlan_hdr;
0093 struct ice_tc_vlan_hdr cvlan_hdr;
0094 struct ice_tc_pppoe_hdr pppoe_hdr;
0095
0096 struct ice_tc_l3_hdr l3_key;
0097 struct ice_tc_l3_hdr l3_mask;
0098
0099
0100 struct ice_tc_l4_hdr l4_key;
0101 struct ice_tc_l4_hdr l4_mask;
0102 };
0103
0104 enum ice_eswitch_fltr_direction {
0105 ICE_ESWITCH_FLTR_INGRESS,
0106 ICE_ESWITCH_FLTR_EGRESS,
0107 };
0108
0109 struct ice_tc_flower_fltr {
0110 struct hlist_node tc_flower_node;
0111
0112
0113 unsigned long cookie;
0114
0115
0116
0117
0118 u16 rid;
0119 u16 rule_id;
0120
0121
0122
0123 u16 dest_id;
0124
0125 struct ice_vsi *dest_vsi;
0126
0127 enum ice_eswitch_fltr_direction direction;
0128
0129
0130 struct ice_tc_flower_lyr_2_4_hdrs outer_headers;
0131 struct ice_tc_flower_lyr_2_4_hdrs inner_headers;
0132 struct ice_vsi *src_vsi;
0133 __be32 tenant_id;
0134 struct gtp_pdu_session_info gtp_pdu_info_keys;
0135 struct gtp_pdu_session_info gtp_pdu_info_masks;
0136 u32 flags;
0137 u8 tunnel_type;
0138 struct ice_tc_flower_action action;
0139
0140
0141
0142
0143 struct netlink_ext_ack *extack;
0144 };
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154 static inline bool ice_is_chnl_fltr(struct ice_tc_flower_fltr *f)
0155 {
0156 return !!f->action.tc_class;
0157 }
0158
0159
0160
0161
0162
0163 static inline int ice_chnl_dmac_fltr_cnt(struct ice_pf *pf)
0164 {
0165 return pf->num_dmac_chnl_fltrs;
0166 }
0167
0168 int
0169 ice_add_cls_flower(struct net_device *netdev, struct ice_vsi *vsi,
0170 struct flow_cls_offload *cls_flower);
0171 int
0172 ice_del_cls_flower(struct ice_vsi *vsi, struct flow_cls_offload *cls_flower);
0173 void ice_replay_tc_fltrs(struct ice_pf *pf);
0174 bool ice_is_tunnel_supported(struct net_device *dev);
0175
0176 #endif