net/mlx5: add ConnectX6-DX device ID
[dpdk.git] / drivers / net / octeontx2 / otx2_ethdev.c
index 1a6afed..aab34db 100644 (file)
@@ -33,7 +33,8 @@ nix_get_tx_offload_capa(struct otx2_eth_dev *dev)
        if (otx2_dev_is_96xx_A0(dev) || otx2_dev_is_95xx_Ax(dev))
                capa &= ~(DEV_TX_OFFLOAD_TCP_TSO |
                          DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
-                         DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+                         DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+                         DEV_TX_OFFLOAD_GRE_TNL_TSO);
        return capa;
 }
 
@@ -89,6 +90,30 @@ nix_lf_alloc(struct otx2_eth_dev *dev, uint32_t nb_rxq, uint32_t nb_txq)
        return 0;
 }
 
+static int
+nix_lf_switch_header_type_enable(struct otx2_eth_dev *dev)
+{
+       struct otx2_mbox *mbox = dev->mbox;
+       struct npc_set_pkind *req;
+       struct msg_resp *rsp;
+       int rc;
+
+       if (dev->npc_flow.switch_header_type == 0)
+               return 0;
+
+       /* Notify AF about higig2 config */
+       req = otx2_mbox_alloc_msg_npc_set_pkind(mbox);
+       req->mode = dev->npc_flow.switch_header_type;
+       req->dir = PKIND_RX;
+       rc = otx2_mbox_process_msg(mbox, (void *)&rsp);
+       if (rc)
+               return rc;
+       req = otx2_mbox_alloc_msg_npc_set_pkind(mbox);
+       req->mode = dev->npc_flow.switch_header_type;
+       req->dir = PKIND_TX;
+       return otx2_mbox_process_msg(mbox, (void *)&rsp);
+}
+
 static int
 nix_lf_free(struct otx2_eth_dev *dev)
 {
@@ -119,7 +144,7 @@ otx2_cgx_rxtx_start(struct otx2_eth_dev *dev)
 {
        struct otx2_mbox *mbox = dev->mbox;
 
-       if (otx2_dev_is_vf(dev))
+       if (otx2_dev_is_vf_or_sdp(dev))
                return 0;
 
        otx2_mbox_alloc_msg_cgx_start_rxtx(mbox);
@@ -132,7 +157,7 @@ otx2_cgx_rxtx_stop(struct otx2_eth_dev *dev)
 {
        struct otx2_mbox *mbox = dev->mbox;
 
-       if (otx2_dev_is_vf(dev))
+       if (otx2_dev_is_vf_or_sdp(dev))
                return 0;
 
        otx2_mbox_alloc_msg_cgx_stop_rxtx(mbox);
@@ -165,7 +190,7 @@ nix_cgx_start_link_event(struct otx2_eth_dev *dev)
 {
        struct otx2_mbox *mbox = dev->mbox;
 
-       if (otx2_dev_is_vf(dev))
+       if (otx2_dev_is_vf_or_sdp(dev))
                return 0;
 
        otx2_mbox_alloc_msg_cgx_start_linkevents(mbox);
@@ -178,7 +203,7 @@ cgx_intlbk_enable(struct otx2_eth_dev *dev, bool en)
 {
        struct otx2_mbox *mbox = dev->mbox;
 
-       if (otx2_dev_is_vf(dev))
+       if (otx2_dev_is_vf_or_sdp(dev))
                return 0;
 
        if (en)
@@ -194,7 +219,7 @@ nix_cgx_stop_link_event(struct otx2_eth_dev *dev)
 {
        struct otx2_mbox *mbox = dev->mbox;
 
-       if (otx2_dev_is_vf(dev))
+       if (otx2_dev_is_vf_or_sdp(dev))
                return 0;
 
        otx2_mbox_alloc_msg_cgx_stop_linkevents(mbox);
@@ -655,7 +680,8 @@ nix_tx_offload_flags(struct rte_eth_dev *eth_dev)
 
        /* Enable Inner and Outer checksum for Tunnel TSO */
        if (conf & (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
-                   DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
+                   DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+                   DEV_TX_OFFLOAD_GRE_TNL_TSO))
                flags |= (NIX_TX_OFFLOAD_TSO_F |
                          NIX_TX_OFFLOAD_OL3_OL4_CSUM_F |
                          NIX_TX_OFFLOAD_L3_L4_CSUM_F);
@@ -1322,6 +1348,61 @@ nix_lso_udp_tun_tcp(struct nix_lso_format_cfg *req,
        field++;
 }
 
+static void
+nix_lso_tun_tcp(struct nix_lso_format_cfg *req,
+               bool outer_v4, bool inner_v4)
+{
+       volatile struct nix_lso_format *field;
+
+       field = (volatile struct nix_lso_format *)&req->fields[0];
+       req->field_mask = NIX_LSO_FIELD_MASK;
+       /* Outer IPv4/IPv6 len */
+       field->layer = NIX_TXLAYER_OL3;
+       field->offset = outer_v4 ? 2 : 4;
+       field->sizem1 = 1; /* 2B */
+       field->alg = NIX_LSOALG_ADD_PAYLEN;
+       field++;
+       if (outer_v4) {
+               /* IPID */
+               field->layer = NIX_TXLAYER_OL3;
+               field->offset = 4;
+               field->sizem1 = 1;
+               /* Incremented linearly per segment */
+               field->alg = NIX_LSOALG_ADD_SEGNUM;
+               field++;
+       }
+
+       /* Inner IPv4/IPv6 */
+       field->layer = NIX_TXLAYER_IL3;
+       field->offset = inner_v4 ? 2 : 4;
+       field->sizem1 = 1; /* 2B */
+       field->alg = NIX_LSOALG_ADD_PAYLEN;
+       field++;
+       if (inner_v4) {
+               /* IPID field */
+               field->layer = NIX_TXLAYER_IL3;
+               field->offset = 4;
+               field->sizem1 = 1;
+               /* Incremented linearly per segment */
+               field->alg = NIX_LSOALG_ADD_SEGNUM;
+               field++;
+       }
+
+       /* TCP sequence number update */
+       field->layer = NIX_TXLAYER_IL4;
+       field->offset = 4;
+       field->sizem1 = 3; /* 4 bytes */
+       field->alg = NIX_LSOALG_ADD_OFFSET;
+       field++;
+
+       /* TCP flags field */
+       field->layer = NIX_TXLAYER_IL4;
+       field->offset = 12;
+       field->sizem1 = 1;
+       field->alg = NIX_LSOALG_TCP_FLAGS;
+       field++;
+}
+
 static int
 nix_setup_lso_formats(struct otx2_eth_dev *dev)
 {
@@ -1414,6 +1495,56 @@ nix_setup_lso_formats(struct otx2_eth_dev *dev)
                return -EFAULT;
        otx2_nix_dbg("udp tun v6v6 fmt=%u\n", base + 5);
 
+       /*
+        * IPv4/TUN HDR/IPv4/TCP LSO
+        */
+       req = otx2_mbox_alloc_msg_nix_lso_format_cfg(mbox);
+       nix_lso_tun_tcp(req, true, true);
+       rc = otx2_mbox_process_msg(mbox, (void *)&rsp);
+       if (rc)
+               return rc;
+
+       if (rsp->lso_format_idx != base + 6)
+               return -EFAULT;
+       otx2_nix_dbg("tun v4v4 fmt=%u\n", base + 6);
+
+       /*
+        * IPv4/TUN HDR/IPv6/TCP LSO
+        */
+       req = otx2_mbox_alloc_msg_nix_lso_format_cfg(mbox);
+       nix_lso_tun_tcp(req, true, false);
+       rc = otx2_mbox_process_msg(mbox, (void *)&rsp);
+       if (rc)
+               return rc;
+
+       if (rsp->lso_format_idx != base + 7)
+               return -EFAULT;
+       otx2_nix_dbg("tun v4v6 fmt=%u\n", base + 7);
+
+       /*
+        * IPv6/TUN HDR/IPv4/TCP LSO
+        */
+       req = otx2_mbox_alloc_msg_nix_lso_format_cfg(mbox);
+       nix_lso_tun_tcp(req, false, true);
+       rc = otx2_mbox_process_msg(mbox, (void *)&rsp);
+       if (rc)
+               return rc;
+
+       if (rsp->lso_format_idx != base + 8)
+               return -EFAULT;
+       otx2_nix_dbg("tun v6v4 fmt=%u\n", base + 8);
+
+       /*
+        * IPv6/TUN HDR/IPv6/TCP LSO
+        */
+       req = otx2_mbox_alloc_msg_nix_lso_format_cfg(mbox);
+       nix_lso_tun_tcp(req, false, false);
+       rc = otx2_mbox_process_msg(mbox, (void *)&rsp);
+       if (rc)
+               return rc;
+       if (rsp->lso_format_idx != base + 9)
+               return -EFAULT;
+       otx2_nix_dbg("tun v6v6 fmt=%u\n", base + 9);
        return 0;
 }
 
@@ -1476,6 +1607,7 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev)
        if (dev->configured == 1) {
                otx2_nix_rxchan_bpid_cfg(eth_dev, false);
                otx2_nix_vlan_fini(eth_dev);
+               otx2_nix_mc_addr_list_uninstall(eth_dev);
                otx2_flow_free_all_resources(dev);
                oxt2_nix_unregister_queue_irqs(eth_dev);
                if (eth_dev->data->dev_conf.intr_conf.rxq)
@@ -1504,6 +1636,12 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev)
                goto fail_offloads;
        }
 
+       rc = nix_lf_switch_header_type_enable(dev);
+       if (rc) {
+               otx2_err("Failed to enable switch type nix_lf rc=%d", rc);
+               goto free_nix_lf;
+       }
+
        rc = nix_setup_lso_formats(dev);
        if (rc) {
                otx2_err("failed to setup nix lso format fields, rc=%d", rc);
@@ -1571,6 +1709,12 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev)
                goto q_irq_fini;
        }
 
+       rc = otx2_nix_mc_addr_list_install(eth_dev);
+       if (rc < 0) {
+               otx2_err("Failed to install mc address list rc=%d", rc);
+               goto cq_fini;
+       }
+
        /*
         * Restore queue config when reconfigure followed by
         * reconfigure and no queue configure invoked from application case.
@@ -1578,7 +1722,7 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev)
        if (dev->configured == 1) {
                rc = nix_restore_queue_cfg(eth_dev);
                if (rc)
-                       goto cq_fini;
+                       goto uninstall_mc_list;
        }
 
        /* Update the mac address */
@@ -1602,6 +1746,8 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev)
        dev->configured_nb_tx_qs = data->nb_tx_queues;
        return 0;
 
+uninstall_mc_list:
+       otx2_nix_mc_addr_list_uninstall(eth_dev);
 cq_fini:
        oxt2_nix_unregister_cq_irqs(eth_dev);
 q_irq_fini:
@@ -1845,6 +1991,7 @@ static const struct eth_dev_ops otx2_eth_dev_ops = {
        .mac_addr_add             = otx2_nix_mac_addr_add,
        .mac_addr_remove          = otx2_nix_mac_addr_del,
        .mac_addr_set             = otx2_nix_mac_addr_set,
+       .set_mc_addr_list         = otx2_nix_set_mc_addr_list,
        .promiscuous_enable       = otx2_nix_promisc_enable,
        .promiscuous_disable      = otx2_nix_promisc_disable,
        .allmulticast_enable      = otx2_nix_allmulticast_enable,
@@ -1939,6 +2086,15 @@ otx2_eth_dev_lf_detach(struct otx2_mbox *mbox)
        return otx2_mbox_process(mbox);
 }
 
+static bool
+otx2_eth_dev_is_sdp(struct rte_pci_device *pci_dev)
+{
+       if (pci_dev->id.device_id == PCI_DEVID_OCTEONTX2_RVU_SDP_PF ||
+           pci_dev->id.device_id == PCI_DEVID_OCTEONTX2_RVU_SDP_VF)
+               return true;
+       return false;
+}
+
 static int
 otx2_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -1982,6 +2138,10 @@ otx2_eth_dev_init(struct rte_eth_dev *eth_dev)
                        goto error;
                }
        }
+       if (otx2_eth_dev_is_sdp(pci_dev))
+               dev->sdp_link = true;
+       else
+               dev->sdp_link = false;
        /* Device generic callbacks */
        dev->ops = &otx2_dev_ops;
        dev->eth_dev = eth_dev;
@@ -2062,6 +2222,8 @@ otx2_eth_dev_init(struct rte_eth_dev *eth_dev)
        if (rc)
                goto free_mac_addrs;
 
+       otx2_nix_mc_filter_init(dev);
+
        otx2_nix_dbg("Port=%d pf=%d vf=%d ver=%s msix_off=%d hwcap=0x%" PRIx64
                     " rxoffload_capa=0x%" PRIx64 " txoffload_capa=0x%" PRIx64,
                     eth_dev->data->port_id, dev->pf, dev->vf,
@@ -2109,6 +2271,9 @@ otx2_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool mbox_close)
        /* Disable other rte_flow entries */
        otx2_flow_fini(dev);
 
+       /* Free multicast filter list */
+       otx2_nix_mc_filter_fini(dev);
+
        /* Disable PTP if already enabled */
        if (otx2_ethdev_is_ptp_en(dev))
                otx2_nix_timesync_disable(eth_dev);
@@ -2264,6 +2429,14 @@ static const struct rte_pci_id pci_nix_map[] = {
                RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM,
                               PCI_DEVID_OCTEONTX2_RVU_AF_VF)
        },
+       {
+               RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM,
+                              PCI_DEVID_OCTEONTX2_RVU_SDP_PF)
+       },
+       {
+               RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM,
+                              PCI_DEVID_OCTEONTX2_RVU_SDP_VF)
+       },
        {
                .vendor_id = 0,
        },