net/dpaa2: support Rx packet parsing
[dpdk.git] / drivers / net / dpaa2 / dpaa2_ethdev.c
index f4565b6..c92b865 100644 (file)
@@ -310,6 +310,28 @@ dpaa2_dev_tx_queue_release(void *q __rte_unused)
        PMD_INIT_FUNC_TRACE();
 }
 
+static const uint32_t *
+dpaa2_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,
+               RTE_PTYPE_L4_ICMP,
+               RTE_PTYPE_UNKNOWN
+       };
+
+       if (dev->rx_pkt_burst == dpaa2_dev_rx)
+               return ptypes;
+       return NULL;
+}
+
 static int
 dpaa2_dev_start(struct rte_eth_dev *dev)
 {
@@ -437,12 +459,88 @@ dpaa2_dev_close(struct rte_eth_dev *dev)
        }
 }
 
+static void
+dpaa2_dev_promiscuous_enable(
+               struct rte_eth_dev *dev)
+{
+       int ret;
+       struct dpaa2_dev_priv *priv = dev->data->dev_private;
+       struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
+
+       PMD_INIT_FUNC_TRACE();
+
+       if (dpni == NULL) {
+               RTE_LOG(ERR, PMD, "dpni is NULL");
+               return;
+       }
+
+       ret = dpni_set_unicast_promisc(dpni, CMD_PRI_LOW, priv->token, true);
+       if (ret < 0)
+               RTE_LOG(ERR, PMD, "Unable to enable promiscuous mode %d", ret);
+}
+
+static void
+dpaa2_dev_promiscuous_disable(
+               struct rte_eth_dev *dev)
+{
+       int ret;
+       struct dpaa2_dev_priv *priv = dev->data->dev_private;
+       struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
+
+       PMD_INIT_FUNC_TRACE();
+
+       if (dpni == NULL) {
+               RTE_LOG(ERR, PMD, "dpni is NULL");
+               return;
+       }
+
+       ret = dpni_set_unicast_promisc(dpni, CMD_PRI_LOW, priv->token, false);
+       if (ret < 0)
+               RTE_LOG(ERR, PMD, "Unable to disable promiscuous mode %d", ret);
+}
+
+static int
+dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+       int ret;
+       struct dpaa2_dev_priv *priv = dev->data->dev_private;
+       struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
+       uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+       PMD_INIT_FUNC_TRACE();
+
+       if (dpni == NULL) {
+               RTE_LOG(ERR, PMD, "dpni is NULL");
+               return -EINVAL;
+       }
+
+       /* check that mtu is within the allowed range */
+       if ((mtu < ETHER_MIN_MTU) || (frame_size > DPAA2_MAX_RX_PKT_LEN))
+               return -EINVAL;
+
+       /* Set the Max Rx frame length as 'mtu' +
+        * Maximum Ethernet header length
+        */
+       ret = dpni_set_max_frame_length(dpni, CMD_PRI_LOW, priv->token,
+                                       mtu + ETH_VLAN_HLEN);
+       if (ret) {
+               PMD_DRV_LOG(ERR, "setting the max frame length failed");
+               return -1;
+       }
+       PMD_DRV_LOG(INFO, "MTU is configured %d for the device\n", mtu);
+       return 0;
+}
+
 static struct eth_dev_ops dpaa2_ethdev_ops = {
        .dev_configure    = dpaa2_eth_dev_configure,
        .dev_start            = dpaa2_dev_start,
        .dev_stop             = dpaa2_dev_stop,
        .dev_close            = dpaa2_dev_close,
+       .promiscuous_enable   = dpaa2_dev_promiscuous_enable,
+       .promiscuous_disable  = dpaa2_dev_promiscuous_disable,
        .dev_infos_get     = dpaa2_dev_info_get,
+       .dev_supported_ptypes_get = dpaa2_supported_ptypes_get,
+       .mtu_set           = dpaa2_dev_mtu_set,
        .rx_queue_setup    = dpaa2_dev_rx_queue_setup,
        .rx_queue_release  = dpaa2_dev_rx_queue_release,
        .tx_queue_setup    = dpaa2_dev_tx_queue_setup,
@@ -604,6 +702,8 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
        eth_dev->dev_ops = &dpaa2_ethdev_ops;
        eth_dev->data->drv_name = rte_dpaa2_pmd.driver.name;
 
+       eth_dev->rx_pkt_burst = dpaa2_dev_rx;
+       eth_dev->tx_pkt_burst = dpaa2_dev_tx;
        return 0;
 }
 
@@ -657,6 +757,8 @@ dpaa2_dev_uninit(struct rte_eth_dev *eth_dev)
        free(dpni);
 
        eth_dev->dev_ops = NULL;
+       eth_dev->rx_pkt_burst = NULL;
+       eth_dev->tx_pkt_burst = NULL;
 
        return 0;
 }