net/ice/base: refactor flow director filter swap
authorQi Zhang <qi.z.zhang@intel.com>
Mon, 15 Jun 2020 02:04:35 +0000 (10:04 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jun 2020 17:21:07 +0000 (19:21 +0200)
Move the swap of flow director addresses and ports into training packet
generation. This reduces the code written for ACL.

Signed-off-by: Henry Tieman <henry.w.tieman@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Qiming Yang <qiming.yang@intel.com>
drivers/net/ice/base/ice_fdir.c
drivers/net/ice/ice_fdir_filter.c

index c925332..2257eba 100644 (file)
@@ -764,16 +764,19 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
                loc = &pkt[ICE_FDIR_TUN_PKT_OFF];
        }
 
+       /* Reverse the src and dst, since the HW expects them to be from Tx
+        * perspective. The input from user is from Rx filter perspective.
+        */
        switch (flow) {
        case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
                ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
-                                  input->ip.v4.dst_ip);
+                                  input->ip.v4.src_ip);
                ice_pkt_insert_u16(loc, ICE_IPV4_TCP_DST_PORT_OFFSET,
-                                  input->ip.v4.dst_port);
+                                  input->ip.v4.src_port);
                ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
-                                  input->ip.v4.src_ip);
+                                  input->ip.v4.dst_ip);
                ice_pkt_insert_u16(loc, ICE_IPV4_TCP_SRC_PORT_OFFSET,
-                                  input->ip.v4.src_port);
+                                  input->ip.v4.dst_port);
                ice_pkt_insert_u8(loc, ICE_IPV4_TOS_OFFSET, input->ip.v4.tos);
                ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
                ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
@@ -782,35 +785,35 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
                break;
        case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
                ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
-                                  input->ip.v4.dst_ip);
+                                  input->ip.v4.src_ip);
                ice_pkt_insert_u16(loc, ICE_IPV4_UDP_DST_PORT_OFFSET,
-                                  input->ip.v4.dst_port);
+                                  input->ip.v4.src_port);
                ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
-                                  input->ip.v4.src_ip);
+                                  input->ip.v4.dst_ip);
                ice_pkt_insert_u16(loc, ICE_IPV4_UDP_SRC_PORT_OFFSET,
-                                  input->ip.v4.src_port);
+                                  input->ip.v4.dst_port);
                ice_pkt_insert_u8(loc, ICE_IPV4_TOS_OFFSET, input->ip.v4.tos);
                ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
                ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
                break;
        case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
                ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
-                                  input->ip.v4.dst_ip);
+                                  input->ip.v4.src_ip);
                ice_pkt_insert_u16(loc, ICE_IPV4_SCTP_DST_PORT_OFFSET,
-                                  input->ip.v4.dst_port);
+                                  input->ip.v4.src_port);
                ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
-                                  input->ip.v4.src_ip);
+                                  input->ip.v4.dst_ip);
                ice_pkt_insert_u16(loc, ICE_IPV4_SCTP_SRC_PORT_OFFSET,
-                                  input->ip.v4.src_port);
+                                  input->ip.v4.dst_port);
                ice_pkt_insert_u8(loc, ICE_IPV4_TOS_OFFSET, input->ip.v4.tos);
                ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
                ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
                break;
        case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
                ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
-                                  input->ip.v4.dst_ip);
-               ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
                                   input->ip.v4.src_ip);
+               ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
+                                  input->ip.v4.dst_ip);
                ice_pkt_insert_u8(loc, ICE_IPV4_TOS_OFFSET, input->ip.v4.tos);
                ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
                ice_pkt_insert_u8(loc, ICE_IPV4_PROTO_OFFSET,
@@ -836,48 +839,48 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
                break;
        case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
                ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
-                                        input->ip.v6.dst_ip);
-               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
                                         input->ip.v6.src_ip);
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
+                                        input->ip.v6.dst_ip);
                ice_pkt_insert_u16(loc, ICE_IPV6_TCP_DST_PORT_OFFSET,
-                                  input->ip.v6.dst_port);
-               ice_pkt_insert_u16(loc, ICE_IPV6_TCP_SRC_PORT_OFFSET,
                                   input->ip.v6.src_port);
+               ice_pkt_insert_u16(loc, ICE_IPV6_TCP_SRC_PORT_OFFSET,
+                                  input->ip.v6.dst_port);
                ice_pkt_insert_u8_tc(loc, ICE_IPV6_TC_OFFSET, input->ip.v6.tc);
                ice_pkt_insert_u8(loc, ICE_IPV6_HLIM_OFFSET, input->ip.v6.hlim);
                ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
                break;
        case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
                ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
-                                        input->ip.v6.dst_ip);
-               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
                                         input->ip.v6.src_ip);
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
+                                        input->ip.v6.dst_ip);
                ice_pkt_insert_u16(loc, ICE_IPV6_UDP_DST_PORT_OFFSET,
-                                  input->ip.v6.dst_port);
-               ice_pkt_insert_u16(loc, ICE_IPV6_UDP_SRC_PORT_OFFSET,
                                   input->ip.v6.src_port);
+               ice_pkt_insert_u16(loc, ICE_IPV6_UDP_SRC_PORT_OFFSET,
+                                  input->ip.v6.dst_port);
                ice_pkt_insert_u8_tc(loc, ICE_IPV6_TC_OFFSET, input->ip.v6.tc);
                ice_pkt_insert_u8(loc, ICE_IPV6_HLIM_OFFSET, input->ip.v6.hlim);
                ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
                break;
        case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
                ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
-                                        input->ip.v6.dst_ip);
-               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
                                         input->ip.v6.src_ip);
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
+                                        input->ip.v6.dst_ip);
                ice_pkt_insert_u16(loc, ICE_IPV6_SCTP_DST_PORT_OFFSET,
-                                  input->ip.v6.dst_port);
-               ice_pkt_insert_u16(loc, ICE_IPV6_SCTP_SRC_PORT_OFFSET,
                                   input->ip.v6.src_port);
+               ice_pkt_insert_u16(loc, ICE_IPV6_SCTP_SRC_PORT_OFFSET,
+                                  input->ip.v6.dst_port);
                ice_pkt_insert_u8_tc(loc, ICE_IPV6_TC_OFFSET, input->ip.v6.tc);
                ice_pkt_insert_u8(loc, ICE_IPV6_HLIM_OFFSET, input->ip.v6.hlim);
                ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
                break;
        case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
                ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
-                                        input->ip.v6.dst_ip);
-               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
                                         input->ip.v6.src_ip);
+               ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
+                                        input->ip.v6.dst_ip);
                ice_pkt_insert_u8_tc(loc, ICE_IPV6_TC_OFFSET, input->ip.v6.tc);
                ice_pkt_insert_u8(loc, ICE_IPV6_HLIM_OFFSET, input->ip.v6.hlim);
                ice_pkt_insert_u8(loc, ICE_IPV6_PROTO_OFFSET,
index 69c714c..19fa41a 100644 (file)
@@ -1676,9 +1676,9 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
                                        input_set |= ICE_INSET_IPV4_PROTO;
 
                                filter->input.ip.v4.dst_ip =
-                                       ipv4_spec->hdr.src_addr;
-                               filter->input.ip.v4.src_ip =
                                        ipv4_spec->hdr.dst_addr;
+                               filter->input.ip.v4.src_ip =
+                                       ipv4_spec->hdr.src_addr;
                                filter->input.ip.v4.tos =
                                        ipv4_spec->hdr.type_of_service;
                                filter->input.ip.v4.ttl =
@@ -1723,9 +1723,9 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
                                        input_set |= ICE_INSET_IPV6_HOP_LIMIT;
 
                                rte_memcpy(filter->input.ip.v6.dst_ip,
-                                          ipv6_spec->hdr.src_addr, 16);
-                               rte_memcpy(filter->input.ip.v6.src_ip,
                                           ipv6_spec->hdr.dst_addr, 16);
+                               rte_memcpy(filter->input.ip.v6.src_ip,
+                                          ipv6_spec->hdr.src_addr, 16);
 
                                vtc_flow_cpu =
                                      rte_be_to_cpu_32(ipv6_spec->hdr.vtc_flow);
@@ -1777,14 +1777,14 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
                                /* Get filter info */
                                if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
                                        filter->input.ip.v4.dst_port =
-                                               tcp_spec->hdr.src_port;
-                                       filter->input.ip.v4.src_port =
                                                tcp_spec->hdr.dst_port;
+                                       filter->input.ip.v4.src_port =
+                                               tcp_spec->hdr.src_port;
                                } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
                                        filter->input.ip.v6.dst_port =
-                                               tcp_spec->hdr.src_port;
-                                       filter->input.ip.v6.src_port =
                                                tcp_spec->hdr.dst_port;
+                                       filter->input.ip.v6.src_port =
+                                               tcp_spec->hdr.src_port;
                                }
                        }
                        break;
@@ -1820,14 +1820,14 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
                                /* Get filter info */
                                if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
                                        filter->input.ip.v4.dst_port =
-                                               udp_spec->hdr.src_port;
-                                       filter->input.ip.v4.src_port =
                                                udp_spec->hdr.dst_port;
+                                       filter->input.ip.v4.src_port =
+                                               udp_spec->hdr.src_port;
                                } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
                                        filter->input.ip.v6.src_port =
-                                               udp_spec->hdr.dst_port;
-                                       filter->input.ip.v6.dst_port =
                                                udp_spec->hdr.src_port;
+                                       filter->input.ip.v6.dst_port =
+                                               udp_spec->hdr.dst_port;
                                }
                        }
                        break;
@@ -1862,14 +1862,14 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
                                /* Get filter info */
                                if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
                                        filter->input.ip.v4.dst_port =
-                                               sctp_spec->hdr.src_port;
-                                       filter->input.ip.v4.src_port =
                                                sctp_spec->hdr.dst_port;
+                                       filter->input.ip.v4.src_port =
+                                               sctp_spec->hdr.src_port;
                                } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
                                        filter->input.ip.v6.dst_port =
-                                               sctp_spec->hdr.src_port;
-                                       filter->input.ip.v6.src_port =
                                                sctp_spec->hdr.dst_port;
+                                       filter->input.ip.v6.src_port =
+                                               sctp_spec->hdr.src_port;
                                }
                        }
                        break;