drivers/net: remove unnecessary macro for unused variables
[dpdk.git] / drivers / net / ixgbe / ixgbe_flow.c
index e2ba9c2..29e5ddc 100644 (file)
  * IPV4                src_addr 192.168.1.20   0xFFFFFFFF
  *             dst_addr 192.167.3.50   0xFFFFFFFF
  *             next_proto_id   17      0xFF
- * UDP/TCP     src_port        80      0xFFFF
- *             dst_port        80      0xFFFF
+ * UDP/TCP/    src_port        80      0xFFFF
+ * SCTP                dst_port        80      0xFFFF
  * END
  * other members in mask and spec should set to 0x00.
  * item->last should be NULL.
@@ -142,6 +142,8 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
        const struct rte_flow_item_tcp *tcp_mask;
        const struct rte_flow_item_udp *udp_spec;
        const struct rte_flow_item_udp *udp_mask;
+       const struct rte_flow_item_sctp *sctp_spec;
+       const struct rte_flow_item_sctp *sctp_mask;
        uint32_t index;
 
        if (!pattern) {
@@ -253,7 +255,8 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
        index++;
        NEXT_ITEM_OF_PATTERN(item, pattern, index);
        if (item->type != RTE_FLOW_ITEM_TYPE_TCP &&
-           item->type != RTE_FLOW_ITEM_TYPE_UDP) {
+           item->type != RTE_FLOW_ITEM_TYPE_UDP &&
+           item->type != RTE_FLOW_ITEM_TYPE_SCTP) {
                memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ITEM,
@@ -319,7 +322,7 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
                filter->dst_port  = tcp_spec->hdr.dst_port;
                filter->src_port  = tcp_spec->hdr.src_port;
                filter->tcp_flags = tcp_spec->hdr.tcp_flags;
-       } else {
+       } else if (item->type == RTE_FLOW_ITEM_TYPE_UDP) {
                udp_mask = (const struct rte_flow_item_udp *)item->mask;
 
                /**
@@ -342,6 +345,29 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
                udp_spec = (const struct rte_flow_item_udp *)item->spec;
                filter->dst_port = udp_spec->hdr.dst_port;
                filter->src_port = udp_spec->hdr.src_port;
+       } else {
+               sctp_mask = (const struct rte_flow_item_sctp *)item->mask;
+
+               /**
+                * Only support src & dst ports,
+                * others should be masked.
+                */
+               if (sctp_mask->hdr.tag ||
+                   sctp_mask->hdr.cksum) {
+                       memset(filter, 0,
+                               sizeof(struct rte_eth_ntuple_filter));
+                       rte_flow_error_set(error, EINVAL,
+                               RTE_FLOW_ERROR_TYPE_ITEM,
+                               item, "Not supported by ntuple filter");
+                       return -rte_errno;
+               }
+
+               filter->dst_port_mask = sctp_mask->hdr.dst_port;
+               filter->src_port_mask = sctp_mask->hdr.src_port;
+
+               sctp_spec = (const struct rte_flow_item_sctp *)item->spec;
+               filter->dst_port = sctp_spec->hdr.dst_port;
+               filter->src_port = sctp_spec->hdr.src_port;
        }
 
        /* check if the next not void item is END */
@@ -1315,7 +1341,6 @@ ixgbe_parse_fdir_act_attr(const struct rte_flow_attr *attr,
                {0xAC, 0x7B, 0xA1,      {0xFF, 0xFF, 0xFF,
                0x2C, 0x6D, 0x36}       0xFF, 0xFF, 0xFF}
  * MAC VLAN    tci     0x2016          0xEFFF
- *             tpid    0x8100          0xFFFF
  * END
  * Other members in mask and spec should set to 0x00.
  * Item->last should be NULL.
@@ -1513,23 +1538,8 @@ ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
                vlan_spec = (const struct rte_flow_item_vlan *)item->spec;
                vlan_mask = (const struct rte_flow_item_vlan *)item->mask;
 
-               if (vlan_spec->tpid != rte_cpu_to_be_16(ETHER_TYPE_VLAN)) {
-                       memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
-                       rte_flow_error_set(error, EINVAL,
-                               RTE_FLOW_ERROR_TYPE_ITEM,
-                               item, "Not supported by fdir filter");
-                       return -rte_errno;
-               }
-
                rule->ixgbe_fdir.formatted.vlan_id = vlan_spec->tci;
 
-               if (vlan_mask->tpid != (uint16_t)~0U) {
-                       memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
-                       rte_flow_error_set(error, EINVAL,
-                               RTE_FLOW_ERROR_TYPE_ITEM,
-                               item, "Not supported by fdir filter");
-                       return -rte_errno;
-               }
                rule->mask.vlan_tci_mask = vlan_mask->tci;
                rule->mask.vlan_tci_mask &= rte_cpu_to_be_16(0xEFFF);
                /* More than one tags are not supported. */
@@ -1824,6 +1834,7 @@ ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
  * IPV4/IPV6   NULL                    NULL
  * UDP         NULL                    NULL
  * VxLAN       vni{0x00, 0x32, 0x54}   {0xFF, 0xFF, 0xFF}
+ * MAC VLAN    tci     0x2016          0xEFFF
  * END
  * NEGRV pattern example:
  * ITEM                Spec                    Mask
@@ -1831,6 +1842,7 @@ ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
  * IPV4/IPV6   NULL                    NULL
  * NVGRE       protocol        0x6558  0xFFFF
  *             tni{0x00, 0x32, 0x54}   {0xFF, 0xFF, 0xFF}
+ * MAC VLAN    tci     0x2016          0xEFFF
  * END
  * other members in mask and spec should set to 0x00.
  * item->last should be NULL.
@@ -2231,7 +2243,7 @@ ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,
        index++;
        NEXT_ITEM_OF_PATTERN(item, pattern, index);
        if ((item->type != RTE_FLOW_ITEM_TYPE_VLAN) &&
-               (item->type != RTE_FLOW_ITEM_TYPE_VLAN)) {
+               (item->type != RTE_FLOW_ITEM_TYPE_IPV4)) {
                memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ITEM,
@@ -2258,48 +2270,16 @@ ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,
                vlan_spec = (const struct rte_flow_item_vlan *)item->spec;
                vlan_mask = (const struct rte_flow_item_vlan *)item->mask;
 
-               if (vlan_spec->tpid != rte_cpu_to_be_16(ETHER_TYPE_VLAN)) {
-                       memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
-                       rte_flow_error_set(error, EINVAL,
-                               RTE_FLOW_ERROR_TYPE_ITEM,
-                               item, "Not supported by fdir filter");
-                       return -rte_errno;
-               }
-
                rule->ixgbe_fdir.formatted.vlan_id = vlan_spec->tci;
 
-               if (vlan_mask->tpid != (uint16_t)~0U) {
-                       memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
-                       rte_flow_error_set(error, EINVAL,
-                               RTE_FLOW_ERROR_TYPE_ITEM,
-                               item, "Not supported by fdir filter");
-                       return -rte_errno;
-               }
                rule->mask.vlan_tci_mask = vlan_mask->tci;
                rule->mask.vlan_tci_mask &= rte_cpu_to_be_16(0xEFFF);
                /* More than one tags are not supported. */
 
-               /**
-                * Check if the next not void item is not vlan.
-                */
-               index++;
-               NEXT_ITEM_OF_PATTERN(item, pattern, index);
-               if (item->type == RTE_FLOW_ITEM_TYPE_VLAN) {
-                       memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
-                       rte_flow_error_set(error, EINVAL,
-                               RTE_FLOW_ERROR_TYPE_ITEM,
-                               item, "Not supported by fdir filter");
-                       return -rte_errno;
-               } else if (item->type != RTE_FLOW_ITEM_TYPE_END) {
-                       memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
-                       rte_flow_error_set(error, EINVAL,
-                               RTE_FLOW_ERROR_TYPE_ITEM,
-                               item, "Not supported by fdir filter");
-                       return -rte_errno;
-               }
                /* check if the next not void item is END */
                index++;
                NEXT_ITEM_OF_PATTERN(item, pattern, index);
+
                if (item->type != RTE_FLOW_ITEM_TYPE_END) {
                        memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
                        rte_flow_error_set(error, EINVAL,
@@ -2589,6 +2569,9 @@ ixgbe_flow_create(struct rte_eth_dev *dev,
 out:
        TAILQ_REMOVE(&ixgbe_flow_list,
                ixgbe_flow_mem_ptr, entries);
+       rte_flow_error_set(error, -ret,
+                          RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+                          "Failed to create flow.");
        rte_free(ixgbe_flow_mem_ptr);
        rte_free(flow);
        return NULL;
@@ -2600,7 +2583,7 @@ out:
  * the HW. Because there can be no enough room for the rule.
  */
 static int
-ixgbe_flow_validate(__rte_unused struct rte_eth_dev *dev,
+ixgbe_flow_validate(struct rte_eth_dev *dev,
                const struct rte_flow_attr *attr,
                const struct rte_flow_item pattern[],
                const struct rte_flow_action actions[],