// SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2020, Intel Corporation. */ /* flow director ethtool support for iavf */ #include <linux/bitfield.h> #include "iavf.h" #define GTPU_PORT … #define NAT_T_ESP_PORT … #define PFCP_PORT … static const struct in6_addr ipv6_addr_full_mask = …; static const struct in6_addr ipv6_addr_zero_mask = …; /** * iavf_validate_fdir_fltr_masks - validate Flow Director filter fields masks * @adapter: pointer to the VF adapter structure * @fltr: Flow Director filter data structure * * Returns 0 if all masks of packet fields are either full or empty. Returns * error on at least one partial mask. */ int iavf_validate_fdir_fltr_masks(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr) { … } /** * iavf_pkt_udp_no_pay_len - the length of UDP packet without payload * @fltr: Flow Director filter data structure */ static u16 iavf_pkt_udp_no_pay_len(struct iavf_fdir_fltr *fltr) { … } /** * iavf_fill_fdir_gtpu_hdr - fill the GTP-U protocol header * @fltr: Flow Director filter data structure * @proto_hdrs: Flow Director protocol headers data structure * * Returns 0 if the GTP-U protocol header is set successfully */ static int iavf_fill_fdir_gtpu_hdr(struct iavf_fdir_fltr *fltr, struct virtchnl_proto_hdrs *proto_hdrs) { … } /** * iavf_fill_fdir_pfcp_hdr - fill the PFCP protocol header * @fltr: Flow Director filter data structure * @proto_hdrs: Flow Director protocol headers data structure * * Returns 0 if the PFCP protocol header is set successfully */ static int iavf_fill_fdir_pfcp_hdr(struct iavf_fdir_fltr *fltr, struct virtchnl_proto_hdrs *proto_hdrs) { … } /** * iavf_fill_fdir_nat_t_esp_hdr - fill the NAT-T-ESP protocol header * @fltr: Flow Director filter data structure * @proto_hdrs: Flow Director protocol headers data structure * * Returns 0 if the NAT-T-ESP protocol header is set successfully */ static int iavf_fill_fdir_nat_t_esp_hdr(struct iavf_fdir_fltr *fltr, struct virtchnl_proto_hdrs *proto_hdrs) { … } /** * iavf_fill_fdir_udp_flex_pay_hdr - fill the UDP payload header * @fltr: Flow Director filter data structure * @proto_hdrs: Flow Director protocol headers data structure * * Returns 0 if the UDP payload defined protocol header is set successfully */ static int iavf_fill_fdir_udp_flex_pay_hdr(struct iavf_fdir_fltr *fltr, struct virtchnl_proto_hdrs *proto_hdrs) { … } /** * iavf_fill_fdir_ip4_hdr - fill the IPv4 protocol header * @fltr: Flow Director filter data structure * @proto_hdrs: Flow Director protocol headers data structure * * Returns 0 if the IPv4 protocol header is set successfully */ static int iavf_fill_fdir_ip4_hdr(struct iavf_fdir_fltr *fltr, struct virtchnl_proto_hdrs *proto_hdrs) { … } /** * iavf_fill_fdir_ip6_hdr - fill the IPv6 protocol header * @fltr: Flow Director filter data structure * @proto_hdrs: Flow Director protocol headers data structure * * Returns 0 if the IPv6 protocol header is set successfully */ static int iavf_fill_fdir_ip6_hdr(struct iavf_fdir_fltr *fltr, struct virtchnl_proto_hdrs *proto_hdrs) { … } /** * iavf_fill_fdir_tcp_hdr - fill the TCP protocol header * @fltr: Flow Director filter data structure * @proto_hdrs: Flow Director protocol headers data structure * * Returns 0 if the TCP protocol header is set successfully */ static int iavf_fill_fdir_tcp_hdr(struct iavf_fdir_fltr *fltr, struct virtchnl_proto_hdrs *proto_hdrs) { … } /** * iavf_fill_fdir_udp_hdr - fill the UDP protocol header * @fltr: Flow Director filter data structure * @proto_hdrs: Flow Director protocol headers data structure * * Returns 0 if the UDP protocol header is set successfully */ static int iavf_fill_fdir_udp_hdr(struct iavf_fdir_fltr *fltr, struct virtchnl_proto_hdrs *proto_hdrs) { … } /** * iavf_fill_fdir_sctp_hdr - fill the SCTP protocol header * @fltr: Flow Director filter data structure * @proto_hdrs: Flow Director protocol headers data structure * * Returns 0 if the SCTP protocol header is set successfully */ static int iavf_fill_fdir_sctp_hdr(struct iavf_fdir_fltr *fltr, struct virtchnl_proto_hdrs *proto_hdrs) { … } /** * iavf_fill_fdir_ah_hdr - fill the AH protocol header * @fltr: Flow Director filter data structure * @proto_hdrs: Flow Director protocol headers data structure * * Returns 0 if the AH protocol header is set successfully */ static int iavf_fill_fdir_ah_hdr(struct iavf_fdir_fltr *fltr, struct virtchnl_proto_hdrs *proto_hdrs) { … } /** * iavf_fill_fdir_esp_hdr - fill the ESP protocol header * @fltr: Flow Director filter data structure * @proto_hdrs: Flow Director protocol headers data structure * * Returns 0 if the ESP protocol header is set successfully */ static int iavf_fill_fdir_esp_hdr(struct iavf_fdir_fltr *fltr, struct virtchnl_proto_hdrs *proto_hdrs) { … } /** * iavf_fill_fdir_l4_hdr - fill the L4 protocol header * @fltr: Flow Director filter data structure * @proto_hdrs: Flow Director protocol headers data structure * * Returns 0 if the L4 protocol header is set successfully */ static int iavf_fill_fdir_l4_hdr(struct iavf_fdir_fltr *fltr, struct virtchnl_proto_hdrs *proto_hdrs) { … } /** * iavf_fill_fdir_eth_hdr - fill the Ethernet protocol header * @fltr: Flow Director filter data structure * @proto_hdrs: Flow Director protocol headers data structure * * Returns 0 if the Ethernet protocol header is set successfully */ static int iavf_fill_fdir_eth_hdr(struct iavf_fdir_fltr *fltr, struct virtchnl_proto_hdrs *proto_hdrs) { … } /** * iavf_fill_fdir_add_msg - fill the Flow Director filter into virtchnl message * @adapter: pointer to the VF adapter structure * @fltr: Flow Director filter data structure * * Returns 0 if the add Flow Director virtchnl message is filled successfully */ int iavf_fill_fdir_add_msg(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr) { … } /** * iavf_fdir_flow_proto_name - get the flow protocol name * @flow_type: Flow Director filter flow type **/ static const char *iavf_fdir_flow_proto_name(enum iavf_fdir_flow_type flow_type) { … } /** * iavf_print_fdir_fltr * @adapter: adapter structure * @fltr: Flow Director filter to print * * Print the Flow Director filter **/ void iavf_print_fdir_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr) { … } /** * iavf_fdir_is_dup_fltr - test if filter is already in list * @adapter: pointer to the VF adapter structure * @fltr: Flow Director filter data structure * * Returns true if the filter is found in the list */ bool iavf_fdir_is_dup_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr) { … } /** * iavf_find_fdir_fltr - find FDIR filter * @adapter: pointer to the VF adapter structure * @is_raw: filter type, is raw (tc u32) or not (ethtool) * @data: data to ID the filter, type dependent * * Returns: pointer to Flow Director filter if found or NULL. Lock must be held. */ struct iavf_fdir_fltr *iavf_find_fdir_fltr(struct iavf_adapter *adapter, bool is_raw, u32 data) { … } /** * iavf_fdir_add_fltr - add a new node to the flow director filter list * @adapter: pointer to the VF adapter structure * @fltr: filter node to add to structure * * Return: 0 on success or negative errno on failure. */ int iavf_fdir_add_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr) { … } /** * iavf_fdir_del_fltr - delete a flow director filter from the list * @adapter: pointer to the VF adapter structure * @is_raw: filter type, is raw (tc u32) or not (ethtool) * @data: data to ID the filter, type dependent * * Return: 0 on success or negative errno on failure. */ int iavf_fdir_del_fltr(struct iavf_adapter *adapter, bool is_raw, u32 data) { … }