net/dpaa: support firmware version get API
[dpdk.git] / drivers / net / dpaa / dpaa_ethdev.c
index a11edeb..8e51fe6 100644 (file)
@@ -112,6 +112,28 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
        return 0;
 }
 
+static const uint32_t *
+dpaa_supported_ptypes_get(struct rte_eth_dev *dev)
+{
+       static const uint32_t ptypes[] = {
+               /*todo -= add more types */
+               RTE_PTYPE_L2_ETHER,
+               RTE_PTYPE_L3_IPV4,
+               RTE_PTYPE_L3_IPV4_EXT,
+               RTE_PTYPE_L3_IPV6,
+               RTE_PTYPE_L3_IPV6_EXT,
+               RTE_PTYPE_L4_TCP,
+               RTE_PTYPE_L4_UDP,
+               RTE_PTYPE_L4_SCTP
+       };
+
+       PMD_INIT_FUNC_TRACE();
+
+       if (dev->rx_pkt_burst == dpaa_eth_queue_rx)
+               return ptypes;
+       return NULL;
+}
+
 static int dpaa_eth_dev_start(struct rte_eth_dev *dev)
 {
        struct dpaa_if *dpaa_intf = dev->data->dev_private;
@@ -142,6 +164,41 @@ static void dpaa_eth_dev_close(struct rte_eth_dev *dev)
        dpaa_eth_dev_stop(dev);
 }
 
+static int
+dpaa_fw_version_get(struct rte_eth_dev *dev __rte_unused,
+                    char *fw_version,
+                    size_t fw_size)
+{
+       int ret;
+       FILE *svr_file = NULL;
+       unsigned int svr_ver = 0;
+
+       PMD_INIT_FUNC_TRACE();
+
+       svr_file = fopen(DPAA_SOC_ID_FILE, "r");
+       if (!svr_file) {
+               DPAA_PMD_ERR("Unable to open SoC device");
+               return -ENOTSUP; /* Not supported on this infra */
+       }
+
+       ret = fscanf(svr_file, "svr:%x", &svr_ver);
+       if (ret <= 0) {
+               DPAA_PMD_ERR("Unable to read SoC device");
+               return -ENOTSUP; /* Not supported on this infra */
+       }
+
+       ret = snprintf(fw_version, fw_size,
+                      "svr:%x-fman-v%x",
+                      svr_ver,
+                      fman_ip_rev);
+
+       ret += 1; /* add the size of '\0' */
+       if (fw_size < (uint32_t)ret)
+               return ret;
+       else
+               return 0;
+}
+
 static void dpaa_eth_dev_info(struct rte_eth_dev *dev,
                              struct rte_eth_dev_info *dev_info)
 {
@@ -160,6 +217,14 @@ static void dpaa_eth_dev_info(struct rte_eth_dev *dev,
        dev_info->flow_type_rss_offloads = DPAA_RSS_OFFLOAD_ALL;
        dev_info->speed_capa = (ETH_LINK_SPEED_1G |
                                ETH_LINK_SPEED_10G);
+       dev_info->rx_offload_capa =
+               (DEV_RX_OFFLOAD_IPV4_CKSUM |
+               DEV_RX_OFFLOAD_UDP_CKSUM   |
+               DEV_RX_OFFLOAD_TCP_CKSUM);
+       dev_info->tx_offload_capa =
+               (DEV_TX_OFFLOAD_IPV4_CKSUM  |
+               DEV_TX_OFFLOAD_UDP_CKSUM   |
+               DEV_TX_OFFLOAD_TCP_CKSUM);
 }
 
 static int dpaa_eth_link_update(struct rte_eth_dev *dev,
@@ -458,6 +523,7 @@ static struct eth_dev_ops dpaa_devops = {
        .dev_stop                 = dpaa_eth_dev_stop,
        .dev_close                = dpaa_eth_dev_close,
        .dev_infos_get            = dpaa_eth_dev_info,
+       .dev_supported_ptypes_get = dpaa_supported_ptypes_get,
 
        .rx_queue_setup           = dpaa_eth_rx_queue_setup,
        .tx_queue_setup           = dpaa_eth_tx_queue_setup,
@@ -481,6 +547,7 @@ static struct eth_dev_ops dpaa_devops = {
        .mac_addr_remove          = dpaa_dev_remove_mac_addr,
        .mac_addr_set             = dpaa_dev_set_mac_addr,
 
+       .fw_version_get           = dpaa_fw_version_get,
 };
 
 static int dpaa_fc_set_default(struct dpaa_if *dpaa_intf)
@@ -587,6 +654,39 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
        return ret;
 }
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+/* Initialise a DEBUG FQ ([rt]x_error, rx_default). */
+static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
+{
+       struct qm_mcc_initfq opts;
+       int ret;
+
+       PMD_INIT_FUNC_TRACE();
+
+       ret = qman_reserve_fqid(fqid);
+       if (ret) {
+               DPAA_PMD_ERR("Reserve debug fqid %d failed with ret: %d",
+                       fqid, ret);
+               return -EINVAL;
+       }
+       /* "map" this Rx FQ to one of the interfaces Tx FQID */
+       DPAA_PMD_DEBUG("Creating debug fq %p, fqid %d", fq, fqid);
+       ret = qman_create_fq(fqid, QMAN_FQ_FLAG_NO_ENQUEUE, fq);
+       if (ret) {
+               DPAA_PMD_ERR("create debug fqid %d failed with ret: %d",
+                       fqid, ret);
+               return ret;
+       }
+       opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_FQCTRL;
+       opts.fqd.dest.wq = DPAA_IF_DEBUG_PRIORITY;
+       ret = qman_init_fq(fq, 0, &opts);
+       if (ret)
+               DPAA_PMD_ERR("init debug fqid %d failed with ret: %d",
+                           fqid, ret);
+       return ret;
+}
+#endif
+
 /* Initialise a network interface */
 static int
 dpaa_dev_init(struct rte_eth_dev *eth_dev)
@@ -661,6 +761,15 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
        }
        dpaa_intf->nb_tx_queues = num_cores;
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+       dpaa_debug_queue_init(&dpaa_intf->debug_queues[
+               DPAA_DEBUG_FQ_RX_ERROR], fman_intf->fqid_rx_err);
+       dpaa_intf->debug_queues[DPAA_DEBUG_FQ_RX_ERROR].dpaa_intf = dpaa_intf;
+       dpaa_debug_queue_init(&dpaa_intf->debug_queues[
+               DPAA_DEBUG_FQ_TX_ERROR], fman_intf->fqid_tx_err);
+       dpaa_intf->debug_queues[DPAA_DEBUG_FQ_TX_ERROR].dpaa_intf = dpaa_intf;
+#endif
+
        DPAA_PMD_DEBUG("All frame queues created");
 
        /* Get the initial configuration for flow control */