net/i40e: fix bitmap free
[dpdk.git] / lib / librte_ethdev / rte_flow.c
index 8ec9c90..f8fdd68 100644 (file)
@@ -19,7 +19,7 @@
 #include "rte_flow.h"
 
 /* Mbuf dynamic field name for metadata. */
-int rte_flow_dynf_metadata_offs = -1;
+int32_t rte_flow_dynf_metadata_offs = -1;
 
 /* Mbuf dynamic field flag bit number for metadata. */
 uint64_t rte_flow_dynf_metadata_mask;
@@ -93,6 +93,9 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
        MK_FLOW_ITEM(IGMP, sizeof(struct rte_flow_item_igmp)),
        MK_FLOW_ITEM(AH, sizeof(struct rte_flow_item_ah)),
        MK_FLOW_ITEM(HIGIG2, sizeof(struct rte_flow_item_higig2_hdr)),
+       MK_FLOW_ITEM(L2TPV3OIP, sizeof(struct rte_flow_item_l2tpv3oip)),
+       MK_FLOW_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
+       MK_FLOW_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
 };
 
 /** Generate flow_action[] entry. */
@@ -168,6 +171,9 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
        MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
        MK_FLOW_ACTION(SET_TAG, sizeof(struct rte_flow_action_set_tag)),
        MK_FLOW_ACTION(SET_META, sizeof(struct rte_flow_action_set_meta)),
+       MK_FLOW_ACTION(SET_IPV4_DSCP, sizeof(struct rte_flow_action_set_dscp)),
+       MK_FLOW_ACTION(SET_IPV6_DSCP, sizeof(struct rte_flow_action_set_dscp)),
+       MK_FLOW_ACTION(AGE, sizeof(struct rte_flow_action_age)),
 };
 
 int
@@ -218,12 +224,21 @@ rte_flow_expand_rss_item_complete(const struct rte_flow_item *item)
 {
        enum rte_flow_item_type ret = RTE_FLOW_ITEM_TYPE_VOID;
        uint16_t ether_type = 0;
+       uint16_t ether_type_m;
        uint8_t ip_next_proto = 0;
+       uint8_t ip_next_proto_m;
 
        if (item == NULL || item->spec == NULL)
                return ret;
        switch (item->type) {
        case RTE_FLOW_ITEM_TYPE_ETH:
+               if (item->mask)
+                       ether_type_m = ((const struct rte_flow_item_eth *)
+                                               (item->mask))->type;
+               else
+                       ether_type_m = rte_flow_item_eth_mask.type;
+               if (ether_type_m != RTE_BE16(0xFFFF))
+                       break;
                ether_type = ((const struct rte_flow_item_eth *)
                                (item->spec))->type;
                if (rte_be_to_cpu_16(ether_type) == RTE_ETHER_TYPE_IPV4)
@@ -234,6 +249,13 @@ rte_flow_expand_rss_item_complete(const struct rte_flow_item *item)
                        ret = RTE_FLOW_ITEM_TYPE_VLAN;
                break;
        case RTE_FLOW_ITEM_TYPE_VLAN:
+               if (item->mask)
+                       ether_type_m = ((const struct rte_flow_item_vlan *)
+                                               (item->mask))->inner_type;
+               else
+                       ether_type_m = rte_flow_item_vlan_mask.inner_type;
+               if (ether_type_m != RTE_BE16(0xFFFF))
+                       break;
                ether_type = ((const struct rte_flow_item_vlan *)
                                (item->spec))->inner_type;
                if (rte_be_to_cpu_16(ether_type) == RTE_ETHER_TYPE_IPV4)
@@ -244,6 +266,14 @@ rte_flow_expand_rss_item_complete(const struct rte_flow_item *item)
                        ret = RTE_FLOW_ITEM_TYPE_VLAN;
                break;
        case RTE_FLOW_ITEM_TYPE_IPV4:
+               if (item->mask)
+                       ip_next_proto_m = ((const struct rte_flow_item_ipv4 *)
+                                       (item->mask))->hdr.next_proto_id;
+               else
+                       ip_next_proto_m =
+                               rte_flow_item_ipv4_mask.hdr.next_proto_id;
+               if (ip_next_proto_m != 0xFF)
+                       break;
                ip_next_proto = ((const struct rte_flow_item_ipv4 *)
                                (item->spec))->hdr.next_proto_id;
                if (ip_next_proto == IPPROTO_UDP)
@@ -256,6 +286,14 @@ rte_flow_expand_rss_item_complete(const struct rte_flow_item *item)
                        ret = RTE_FLOW_ITEM_TYPE_IPV6;
                break;
        case RTE_FLOW_ITEM_TYPE_IPV6:
+               if (item->mask)
+                       ip_next_proto_m = ((const struct rte_flow_item_ipv6 *)
+                                               (item->mask))->hdr.proto;
+               else
+                       ip_next_proto_m =
+                               rte_flow_item_ipv6_mask.hdr.proto;
+               if (ip_next_proto_m != 0xFF)
+                       break;
                ip_next_proto = ((const struct rte_flow_item_ipv6 *)
                                (item->spec))->hdr.proto;
                if (ip_next_proto == IPPROTO_UDP)
@@ -1039,6 +1077,7 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, size_t size,
        int elt = 0;
        const struct rte_flow_item *last_item = NULL;
 
+       memset(&missed_item, 0, sizeof(missed_item));
        lsize = offsetof(struct rte_flow_expand_rss, entry) +
                elt_n * sizeof(buf->entry[0]);
        if (lsize <= size) {
@@ -1179,3 +1218,36 @@ rte_flow_expand_rss(struct rte_flow_expand_rss *buf, size_t size,
        }
        return lsize;
 }
+
+int
+rte_flow_dev_dump(uint16_t port_id, FILE *file, struct rte_flow_error *error)
+{
+       struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+       const struct rte_flow_ops *ops = rte_flow_ops_get(port_id, error);
+
+       if (unlikely(!ops))
+               return -rte_errno;
+       if (likely(!!ops->dev_dump))
+               return flow_err(port_id, ops->dev_dump(dev, file, error),
+                               error);
+       return rte_flow_error_set(error, ENOSYS,
+                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+                                 NULL, rte_strerror(ENOSYS));
+}
+
+int
+rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
+                   uint32_t nb_contexts, struct rte_flow_error *error)
+{
+       struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+       const struct rte_flow_ops *ops = rte_flow_ops_get(port_id, error);
+
+       if (unlikely(!ops))
+               return -rte_errno;
+       if (likely(!!ops->get_aged_flows))
+               return flow_err(port_id, ops->get_aged_flows(dev, contexts,
+                               nb_contexts, error), error);
+       return rte_flow_error_set(error, ENOTSUP,
+                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+                                 NULL, rte_strerror(ENOTSUP));
+}