]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/spdk/dpdk/drivers/net/enic/enic_clsf.c
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / dpdk / drivers / net / enic / enic_clsf.c
index 9d95201ece47427660cbe0417908f4e8e1469fa6..53f57b01ae6aec67b12f45c05503489bd6b7834b 100644 (file)
@@ -3,8 +3,6 @@
  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
  */
 
-#include <libgen.h>
-
 #include <rte_ethdev_driver.h>
 #include <rte_malloc.h>
 #include <rte_hash.h>
@@ -13,7 +11,6 @@
 #include <rte_tcp.h>
 #include <rte_udp.h>
 #include <rte_sctp.h>
-#include <rte_eth_ctrl.h>
 
 #include "enic_compat.h"
 #include "enic.h"
 
 #define ENICPMD_CLSF_HASH_ENTRIES       ENICPMD_FDIR_MAX
 
+static void copy_fltr_v1(struct filter_v2 *fltr,
+               const struct rte_eth_fdir_input *input,
+               const struct rte_eth_fdir_masks *masks);
+static void copy_fltr_v2(struct filter_v2 *fltr,
+               const struct rte_eth_fdir_input *input,
+               const struct rte_eth_fdir_masks *masks);
+
 void enic_fdir_stats_get(struct enic *enic, struct rte_eth_fdir_stats *stats)
 {
        *stats = enic->fdir.stats;
@@ -81,9 +85,9 @@ enic_set_layer(struct filter_generic_1 *gp, unsigned int flag,
 /* Copy Flow Director filter to a VIC ipv4 filter (for Cisco VICs
  * without advanced filter support.
  */
-void
-copy_fltr_v1(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
-            __rte_unused struct rte_eth_fdir_masks *masks)
+static void
+copy_fltr_v1(struct filter_v2 *fltr, const struct rte_eth_fdir_input *input,
+            __rte_unused const struct rte_eth_fdir_masks *masks)
 {
        fltr->type = FILTER_IPV4_5TUPLE;
        fltr->u.ipv4.src_addr = rte_be_to_cpu_32(
@@ -106,9 +110,9 @@ copy_fltr_v1(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
 /* Copy Flow Director filter to a VIC generic filter (requires advanced
  * filter support.
  */
-void
-copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
-            struct rte_eth_fdir_masks *masks)
+static void
+copy_fltr_v2(struct filter_v2 *fltr, const struct rte_eth_fdir_input *input,
+            const struct rte_eth_fdir_masks *masks)
 {
        struct filter_generic_1 *gp = &fltr->u.generic_1;
 
@@ -165,9 +169,11 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
                        sctp_val.tag = input->flow.sctp4_flow.verify_tag;
                }
 
-               /* v4 proto should be 132, override ip4_flow.proto */
-               input->flow.ip4_flow.proto = 132;
-
+               /*
+                * Unlike UDP/TCP (FILTER_GENERIC_1_{UDP,TCP}), the firmware
+                * has no "packet is SCTP" flag. Use flag=0 (generic L4) and
+                * manually set proto_id=sctp below.
+                */
                enic_set_layer(gp, 0, FILTER_GENERIC_1_L4, &sctp_mask,
                               &sctp_val, sizeof(struct sctp_hdr));
        }
@@ -191,6 +197,10 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
                if (input->flow.ip4_flow.proto) {
                        ip4_mask.next_proto_id = masks->ipv4_mask.proto;
                        ip4_val.next_proto_id = input->flow.ip4_flow.proto;
+               } else if (input->flow_type == RTE_ETH_FLOW_NONFRAG_IPV4_SCTP) {
+                       /* Explicitly match the SCTP protocol number */
+                       ip4_mask.next_proto_id = 0xff;
+                       ip4_val.next_proto_id = IPPROTO_SCTP;
                }
                if (input->flow.ip4_flow.src_ip) {
                        ip4_mask.src_addr =  masks->ipv4_mask.src_ip;
@@ -253,9 +263,6 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
                        sctp_val.tag = input->flow.sctp6_flow.verify_tag;
                }
 
-               /* v4 proto should be 132, override ipv6_flow.proto */
-               input->flow.ipv6_flow.proto = 132;
-
                enic_set_layer(gp, 0, FILTER_GENERIC_1_L4, &sctp_mask,
                               &sctp_val, sizeof(struct sctp_hdr));
        }
@@ -271,6 +278,10 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
                if (input->flow.ipv6_flow.proto) {
                        ipv6_mask.proto = masks->ipv6_mask.proto;
                        ipv6_val.proto = input->flow.ipv6_flow.proto;
+               } else if (input->flow_type == RTE_ETH_FLOW_NONFRAG_IPV6_SCTP) {
+                       /* See comments for IPv4 SCTP above. */
+                       ipv6_mask.proto = 0xff;
+                       ipv6_val.proto = IPPROTO_SCTP;
                }
                memcpy(ipv6_mask.src_addr, masks->ipv6_mask.src_ip,
                       sizeof(ipv6_mask.src_addr));