memzone: rename address from physical to IOVA
[dpdk.git] / drivers / net / qede / qede_fdir.c
index f0dc73a..da6364e 100644 (file)
 #endif
 
 #define QEDE_VALID_FLOW(flow_type) \
-       ((flow_type) == RTE_ETH_FLOW_FRAG_IPV4          || \
-       (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV4_TCP    || \
+       ((flow_type) == RTE_ETH_FLOW_NONFRAG_IPV4_TCP   || \
        (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV4_UDP    || \
-       (flow_type) == RTE_ETH_FLOW_FRAG_IPV6           || \
        (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV6_TCP    || \
        (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV6_UDP)
 
@@ -55,7 +53,7 @@ int qede_check_fdir_support(struct rte_eth_dev *eth_dev)
                DP_INFO(edev, "flowdir is disabled\n");
        break;
        case RTE_FDIR_MODE_PERFECT:
-               if (edev->num_hwfns > 1) {
+               if (ECORE_IS_CMT(edev)) {
                        DP_ERR(edev, "flowdir is not supported in 100G mode\n");
                        qdev->fdir_info.arfs.arfs_enable = false;
                        return -ENOTSUP;
@@ -76,9 +74,7 @@ int qede_check_fdir_support(struct rte_eth_dev *eth_dev)
 void qede_fdir_dealloc_resc(struct rte_eth_dev *eth_dev)
 {
        struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev);
-       struct ecore_dev *edev = QEDE_INIT_EDEV(qdev);
        struct qede_fdir_entry *tmp = NULL;
-       struct qede_fdir_entry *fdir;
 
        SLIST_FOREACH(tmp, &qdev->fdir_info.fdir_list_head, list) {
                if (tmp) {
@@ -100,12 +96,11 @@ qede_config_cmn_fdir_filter(struct rte_eth_dev *eth_dev,
        struct ecore_dev *edev = QEDE_INIT_EDEV(qdev);
        char mz_name[RTE_MEMZONE_NAMESIZE] = {0};
        struct qede_fdir_entry *tmp = NULL;
-       struct qede_fdir_entry *fdir;
+       struct qede_fdir_entry *fdir = NULL;
        const struct rte_memzone *mz;
        struct ecore_hwfn *p_hwfn;
        enum _ecore_status_t rc;
        uint16_t pkt_len;
-       uint16_t len;
        void *pkt;
 
        if (add) {
@@ -176,8 +171,8 @@ qede_config_cmn_fdir_filter(struct rte_eth_dev *eth_dev,
                                          &qdev->fdir_info.arfs);
        }
        /* configure filter with ECORE_SPQ_MODE_EBLOCK */
-       rc = ecore_configure_rfs_ntuple_filter(p_hwfn, p_hwfn->p_arfs_ptt, NULL,
-                                              (dma_addr_t)mz->phys_addr,
+       rc = ecore_configure_rfs_ntuple_filter(p_hwfn, NULL,
+                                              (dma_addr_t)mz->iova,
                                               pkt_len,
                                               fdir_filter->action.rx_queue,
                                               0, add);
@@ -253,7 +248,7 @@ qede_fdir_filter_add(struct rte_eth_dev *eth_dev,
 }
 
 /* Fills the L3/L4 headers and returns the actual length  of flowdir packet */
-static uint16_t
+uint16_t
 qede_fdir_construct_pkt(struct rte_eth_dev *eth_dev,
                        struct rte_eth_fdir_filter *fdir,
                        void *buff,
@@ -270,14 +265,10 @@ qede_fdir_construct_pkt(struct rte_eth_dev *eth_dev,
        struct ipv6_hdr *ip6;
        struct udp_hdr *udp;
        struct tcp_hdr *tcp;
-       struct sctp_hdr *sctp;
-       uint8_t size, dst = 0;
        uint16_t len;
        static const uint8_t next_proto[] = {
-               [RTE_ETH_FLOW_FRAG_IPV4] = IPPROTO_IP,
                [RTE_ETH_FLOW_NONFRAG_IPV4_TCP] = IPPROTO_TCP,
                [RTE_ETH_FLOW_NONFRAG_IPV4_UDP] = IPPROTO_UDP,
-               [RTE_ETH_FLOW_FRAG_IPV6] = IPPROTO_NONE,
                [RTE_ETH_FLOW_NONFRAG_IPV6_TCP] = IPPROTO_TCP,
                [RTE_ETH_FLOW_NONFRAG_IPV6_UDP] = IPPROTO_UDP,
        };
@@ -300,11 +291,10 @@ qede_fdir_construct_pkt(struct rte_eth_dev *eth_dev,
        raw_pkt += sizeof(uint16_t);
        len += sizeof(uint16_t);
 
-       /* fill the common ip header */
        switch (input->flow_type) {
        case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
        case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
-       case RTE_ETH_FLOW_FRAG_IPV4:
+               /* fill the common ip header */
                ip = (struct ipv4_hdr *)raw_pkt;
                *ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
                ip->version_ihl = QEDE_FDIR_IP_DEFAULT_VERSION_IHL;
@@ -320,10 +310,31 @@ qede_fdir_construct_pkt(struct rte_eth_dev *eth_dev,
                ip->src_addr = input->flow.ip4_flow.src_ip;
                len += sizeof(struct ipv4_hdr);
                params->ipv4 = true;
+
+               raw_pkt = (uint8_t *)buff;
+               /* UDP */
+               if (input->flow_type == RTE_ETH_FLOW_NONFRAG_IPV4_UDP) {
+                       udp = (struct udp_hdr *)(raw_pkt + len);
+                       udp->dst_port = input->flow.udp4_flow.dst_port;
+                       udp->src_port = input->flow.udp4_flow.src_port;
+                       udp->dgram_len = sizeof(struct udp_hdr);
+                       len += sizeof(struct udp_hdr);
+                       /* adjust ip total_length */
+                       ip->total_length += sizeof(struct udp_hdr);
+                       params->udp = true;
+               } else { /* TCP */
+                       tcp = (struct tcp_hdr *)(raw_pkt + len);
+                       tcp->src_port = input->flow.tcp4_flow.src_port;
+                       tcp->dst_port = input->flow.tcp4_flow.dst_port;
+                       tcp->data_off = QEDE_FDIR_TCP_DEFAULT_DATAOFF;
+                       len += sizeof(struct tcp_hdr);
+                       /* adjust ip total_length */
+                       ip->total_length += sizeof(struct tcp_hdr);
+                       params->tcp = true;
+               }
                break;
        case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
        case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
-       case RTE_ETH_FLOW_FRAG_IPV6:
                ip6 = (struct ipv6_hdr *)raw_pkt;
                *ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv6);
                ip6->proto = input->flow.ipv6_flow.proto ?
@@ -334,6 +345,23 @@ qede_fdir_construct_pkt(struct rte_eth_dev *eth_dev,
                rte_memcpy(&ip6->dst_addr, &input->flow.ipv6_flow.src_ip,
                           IPV6_ADDR_LEN);
                len += sizeof(struct ipv6_hdr);
+
+               raw_pkt = (uint8_t *)buff;
+               /* UDP */
+               if (input->flow_type == RTE_ETH_FLOW_NONFRAG_IPV6_UDP) {
+                       udp = (struct udp_hdr *)(raw_pkt + len);
+                       udp->src_port = input->flow.udp6_flow.dst_port;
+                       udp->dst_port = input->flow.udp6_flow.src_port;
+                       len += sizeof(struct udp_hdr);
+                       params->udp = true;
+               } else { /* TCP */
+                       tcp = (struct tcp_hdr *)(raw_pkt + len);
+                       tcp->src_port = input->flow.tcp4_flow.src_port;
+                       tcp->dst_port = input->flow.tcp4_flow.dst_port;
+                       tcp->data_off = QEDE_FDIR_TCP_DEFAULT_DATAOFF;
+                       len += sizeof(struct tcp_hdr);
+                       params->tcp = true;
+               }
                break;
        default:
                DP_ERR(edev, "Unsupported flow_type %u\n",
@@ -341,50 +369,6 @@ qede_fdir_construct_pkt(struct rte_eth_dev *eth_dev,
                return 0;
        }
 
-       /* fill the L4 header */
-       raw_pkt = (uint8_t *)buff;
-       switch (input->flow_type) {
-       case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
-               udp = (struct udp_hdr *)(raw_pkt + len);
-               udp->dst_port = input->flow.udp4_flow.dst_port;
-               udp->src_port = input->flow.udp4_flow.src_port;
-               udp->dgram_len = sizeof(struct udp_hdr);
-               len += sizeof(struct udp_hdr);
-               /* adjust ip total_length */
-               ip->total_length += sizeof(struct udp_hdr);
-               params->udp = true;
-       break;
-       case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
-               tcp = (struct tcp_hdr *)(raw_pkt + len);
-               tcp->src_port = input->flow.tcp4_flow.src_port;
-               tcp->dst_port = input->flow.tcp4_flow.dst_port;
-               tcp->data_off = QEDE_FDIR_TCP_DEFAULT_DATAOFF;
-               len += sizeof(struct tcp_hdr);
-               /* adjust ip total_length */
-               ip->total_length += sizeof(struct tcp_hdr);
-               params->tcp = true;
-       break;
-       case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
-               tcp = (struct tcp_hdr *)(raw_pkt + len);
-               tcp->data_off = QEDE_FDIR_TCP_DEFAULT_DATAOFF;
-               tcp->src_port = input->flow.udp6_flow.src_port;
-               tcp->dst_port = input->flow.udp6_flow.dst_port;
-               /* adjust ip total_length */
-               len += sizeof(struct tcp_hdr);
-               params->tcp = true;
-       break;
-       case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
-               udp = (struct udp_hdr *)(raw_pkt + len);
-               udp->src_port = input->flow.udp6_flow.dst_port;
-               udp->dst_port = input->flow.udp6_flow.src_port;
-               /* adjust ip total_length */
-               len += sizeof(struct udp_hdr);
-               params->udp = true;
-       break;
-       default:
-               DP_ERR(edev, "Unsupported flow_type %d\n", input->flow_type);
-               return 0;
-       }
        return len;
 }
 
@@ -402,7 +386,7 @@ qede_fdir_filter_conf(struct rte_eth_dev *eth_dev,
        switch (filter_op) {
        case RTE_ETH_FILTER_NOP:
                /* Typically used to query flowdir support */
-               if (edev->num_hwfns > 1) {
+               if (ECORE_IS_CMT(edev)) {
                        DP_ERR(edev, "flowdir is not supported in 100G mode\n");
                        return -ENOTSUP;
                }
@@ -436,13 +420,12 @@ int qede_ntuple_filter_conf(struct rte_eth_dev *eth_dev,
        struct rte_eth_fdir_filter fdir_entry;
        struct rte_eth_tcpv4_flow *tcpv4_flow;
        struct rte_eth_udpv4_flow *udpv4_flow;
-       struct ecore_hwfn *p_hwfn;
-       bool add;
+       bool add = false;
 
        switch (filter_op) {
        case RTE_ETH_FILTER_NOP:
                /* Typically used to query fdir support */
-               if (edev->num_hwfns > 1) {
+               if (ECORE_IS_CMT(edev)) {
                        DP_ERR(edev, "flowdir is not supported in 100G mode\n");
                        return -ENOTSUP;
                }
@@ -451,7 +434,6 @@ int qede_ntuple_filter_conf(struct rte_eth_dev *eth_dev,
                add = true;
        break;
        case RTE_ETH_FILTER_DELETE:
-               add = false;
        break;
        case RTE_ETH_FILTER_INFO:
        case RTE_ETH_FILTER_GET: