net/iavf: support quanta size configuration
[dpdk.git] / drivers / net / iavf / iavf_ethdev.c
index b2b413c..7d093bd 100644 (file)
 #include "iavf_rxtx.h"
 #include "iavf_generic_flow.h"
 #include "rte_pmd_iavf.h"
+#include "iavf_ipsec_crypto.h"
 
 /* devargs */
 #define IAVF_PROTO_XTR_ARG         "proto_xtr"
+#define IAVF_QUANTA_SIZE_ARG       "quanta_size"
 
 static const char * const iavf_valid_args[] = {
        IAVF_PROTO_XTR_ARG,
+       IAVF_QUANTA_SIZE_ARG,
        NULL
 };
 
@@ -71,6 +74,11 @@ static struct iavf_proto_xtr_ol iavf_proto_xtr_params[] = {
        [IAVF_PROTO_XTR_IP_OFFSET] = {
                .param = { .name = "intel_pmd_dynflag_proto_xtr_ip_offset" },
                .ol_flag = &rte_pmd_ifd_dynflag_proto_xtr_ip_offset_mask },
+       [IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID] = {
+               .param = {
+               .name = "intel_pmd_dynflag_proto_xtr_ipsec_crypto_said" },
+               .ol_flag =
+                       &rte_pmd_ifd_dynflag_proto_xtr_ipsec_crypto_said_mask },
 };
 
 static int iavf_dev_configure(struct rte_eth_dev *dev);
@@ -84,6 +92,7 @@ static const uint32_t *iavf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 static int iavf_dev_stats_get(struct rte_eth_dev *dev,
                             struct rte_eth_stats *stats);
 static int iavf_dev_stats_reset(struct rte_eth_dev *dev);
+static int iavf_dev_xstats_reset(struct rte_eth_dev *dev);
 static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
                                 struct rte_eth_xstat *xstats, unsigned int n);
 static int iavf_dev_xstats_get_names(struct rte_eth_dev *dev,
@@ -139,21 +148,37 @@ struct rte_iavf_xstats_name_off {
        unsigned int offset;
 };
 
+#define _OFF_OF(a) offsetof(struct iavf_eth_xstats, a)
 static const struct rte_iavf_xstats_name_off rte_iavf_stats_strings[] = {
-       {"rx_bytes", offsetof(struct iavf_eth_stats, rx_bytes)},
-       {"rx_unicast_packets", offsetof(struct iavf_eth_stats, rx_unicast)},
-       {"rx_multicast_packets", offsetof(struct iavf_eth_stats, rx_multicast)},
-       {"rx_broadcast_packets", offsetof(struct iavf_eth_stats, rx_broadcast)},
-       {"rx_dropped_packets", offsetof(struct iavf_eth_stats, rx_discards)},
+       {"rx_bytes", _OFF_OF(eth_stats.rx_bytes)},
+       {"rx_unicast_packets", _OFF_OF(eth_stats.rx_unicast)},
+       {"rx_multicast_packets", _OFF_OF(eth_stats.rx_multicast)},
+       {"rx_broadcast_packets", _OFF_OF(eth_stats.rx_broadcast)},
+       {"rx_dropped_packets", _OFF_OF(eth_stats.rx_discards)},
        {"rx_unknown_protocol_packets", offsetof(struct iavf_eth_stats,
                rx_unknown_protocol)},
-       {"tx_bytes", offsetof(struct iavf_eth_stats, tx_bytes)},
-       {"tx_unicast_packets", offsetof(struct iavf_eth_stats, tx_unicast)},
-       {"tx_multicast_packets", offsetof(struct iavf_eth_stats, tx_multicast)},
-       {"tx_broadcast_packets", offsetof(struct iavf_eth_stats, tx_broadcast)},
-       {"tx_dropped_packets", offsetof(struct iavf_eth_stats, tx_discards)},
-       {"tx_error_packets", offsetof(struct iavf_eth_stats, tx_errors)},
+       {"tx_bytes", _OFF_OF(eth_stats.tx_bytes)},
+       {"tx_unicast_packets", _OFF_OF(eth_stats.tx_unicast)},
+       {"tx_multicast_packets", _OFF_OF(eth_stats.tx_multicast)},
+       {"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)},
+       {"tx_dropped_packets", _OFF_OF(eth_stats.tx_discards)},
+       {"tx_error_packets", _OFF_OF(eth_stats.tx_errors)},
+
+       {"inline_ipsec_crypto_ipackets", _OFF_OF(ips_stats.icount)},
+       {"inline_ipsec_crypto_ibytes", _OFF_OF(ips_stats.ibytes)},
+       {"inline_ipsec_crypto_ierrors", _OFF_OF(ips_stats.ierrors.count)},
+       {"inline_ipsec_crypto_ierrors_sad_lookup",
+                       _OFF_OF(ips_stats.ierrors.sad_miss)},
+       {"inline_ipsec_crypto_ierrors_not_processed",
+                       _OFF_OF(ips_stats.ierrors.not_processed)},
+       {"inline_ipsec_crypto_ierrors_icv_fail",
+                       _OFF_OF(ips_stats.ierrors.icv_check)},
+       {"inline_ipsec_crypto_ierrors_length",
+                       _OFF_OF(ips_stats.ierrors.ipsec_length)},
+       {"inline_ipsec_crypto_ierrors_misc",
+                       _OFF_OF(ips_stats.ierrors.misc)},
 };
+#undef _OFF_OF
 
 #define IAVF_NB_XSTATS (sizeof(rte_iavf_stats_strings) / \
                sizeof(rte_iavf_stats_strings[0]))
@@ -171,7 +196,7 @@ static const struct eth_dev_ops iavf_eth_dev_ops = {
        .stats_reset                = iavf_dev_stats_reset,
        .xstats_get                 = iavf_dev_xstats_get,
        .xstats_get_names           = iavf_dev_xstats_get_names,
-       .xstats_reset               = iavf_dev_stats_reset,
+       .xstats_reset               = iavf_dev_xstats_reset,
        .promiscuous_enable         = iavf_dev_promiscuous_enable,
        .promiscuous_disable        = iavf_dev_promiscuous_disable,
        .allmulticast_enable        = iavf_dev_allmulticast_enable,
@@ -217,6 +242,91 @@ iavf_tm_ops_get(struct rte_eth_dev *dev __rte_unused,
        return 0;
 }
 
+__rte_unused
+static int
+iavf_vfr_inprogress(struct iavf_hw *hw)
+{
+       int inprogress = 0;
+
+       if ((IAVF_READ_REG(hw, IAVF_VFGEN_RSTAT) &
+               IAVF_VFGEN_RSTAT_VFR_STATE_MASK) ==
+               VIRTCHNL_VFR_INPROGRESS)
+               inprogress = 1;
+
+       if (inprogress)
+               PMD_DRV_LOG(INFO, "Watchdog detected VFR in progress");
+
+       return inprogress;
+}
+
+__rte_unused
+static void
+iavf_dev_watchdog(void *cb_arg)
+{
+       struct iavf_adapter *adapter = cb_arg;
+       struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter);
+       int vfr_inprogress = 0, rc = 0;
+
+       /* check if watchdog has been disabled since last call */
+       if (!adapter->vf.watchdog_enabled)
+               return;
+
+       /* If in reset then poll vfr_inprogress register for completion */
+       if (adapter->vf.vf_reset) {
+               vfr_inprogress = iavf_vfr_inprogress(hw);
+
+               if (!vfr_inprogress) {
+                       PMD_DRV_LOG(INFO, "VF \"%s\" reset has completed",
+                               adapter->vf.eth_dev->data->name);
+                       adapter->vf.vf_reset = false;
+               }
+       /* If not in reset then poll vfr_inprogress register for VFLR event */
+       } else {
+               vfr_inprogress = iavf_vfr_inprogress(hw);
+
+               if (vfr_inprogress) {
+                       PMD_DRV_LOG(INFO,
+                               "VF \"%s\" reset event detected by watchdog",
+                               adapter->vf.eth_dev->data->name);
+
+                       /* enter reset state with VFLR event */
+                       adapter->vf.vf_reset = true;
+
+                       rte_eth_dev_callback_process(adapter->vf.eth_dev,
+                               RTE_ETH_EVENT_INTR_RESET, NULL);
+               }
+       }
+
+       /* re-alarm watchdog */
+       rc = rte_eal_alarm_set(IAVF_DEV_WATCHDOG_PERIOD,
+                       &iavf_dev_watchdog, cb_arg);
+
+       if (rc)
+               PMD_DRV_LOG(ERR, "Failed \"%s\" to reset device watchdog alarm",
+                       adapter->vf.eth_dev->data->name);
+}
+
+static void
+iavf_dev_watchdog_enable(struct iavf_adapter *adapter __rte_unused)
+{
+#if (IAVF_DEV_WATCHDOG_PERIOD > 0)
+       PMD_DRV_LOG(INFO, "Enabling device watchdog");
+       adapter->vf.watchdog_enabled = true;
+       if (rte_eal_alarm_set(IAVF_DEV_WATCHDOG_PERIOD,
+                       &iavf_dev_watchdog, (void *)adapter))
+               PMD_DRV_LOG(ERR, "Failed to enabled device watchdog");
+#endif
+}
+
+static void
+iavf_dev_watchdog_disable(struct iavf_adapter *adapter __rte_unused)
+{
+#if (IAVF_DEV_WATCHDOG_PERIOD > 0)
+       PMD_DRV_LOG(INFO, "Disabling device watchdog");
+       adapter->vf.watchdog_enabled = false;
+#endif
+}
+
 static int
 iavf_set_mc_addr_list(struct rte_eth_dev *dev,
                        struct rte_ether_addr *mc_addrs,
@@ -408,7 +518,7 @@ iavf_init_rss(struct iavf_adapter *adapter)
                        j = 0;
                vf->rss_lut[i] = j;
        }
-       /* send virtchnnl ops to configure rss*/
+       /* send virtchnl ops to configure RSS */
        ret = iavf_configure_rss_lut(adapter);
        if (ret)
                return ret;
@@ -646,17 +756,16 @@ static int iavf_config_rx_queues_irqs(struct rte_eth_dev *dev,
                        return -1;
        }
 
-       if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
-               intr_handle->intr_vec =
-                       rte_zmalloc("intr_vec",
-                                   dev->data->nb_rx_queues * sizeof(int), 0);
-               if (!intr_handle->intr_vec) {
+       if (rte_intr_dp_is_en(intr_handle)) {
+               if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
+                                                   dev->data->nb_rx_queues)) {
                        PMD_DRV_LOG(ERR, "Failed to allocate %d rx intr_vec",
                                    dev->data->nb_rx_queues);
                        return -1;
                }
        }
 
+
        qv_map = rte_zmalloc("qv_map",
                dev->data->nb_rx_queues * sizeof(struct iavf_qv_map), 0);
        if (!qv_map) {
@@ -716,24 +825,27 @@ static int iavf_config_rx_queues_irqs(struct rte_eth_dev *dev,
                        for (i = 0; i < dev->data->nb_rx_queues; i++) {
                                qv_map[i].queue_id = i;
                                qv_map[i].vector_id = vf->msix_base;
-                               intr_handle->intr_vec[i] = IAVF_MISC_VEC_ID;
+                               rte_intr_vec_list_index_set(intr_handle,
+                                                       i, IAVF_MISC_VEC_ID);
                        }
                        vf->qv_map = qv_map;
                        PMD_DRV_LOG(DEBUG,
                                    "vector %u are mapping to all Rx queues",
                                    vf->msix_base);
                } else {
-                       /* If Rx interrupt is reuquired, and we can use
+                       /* If Rx interrupt is required, and we can use
                         * multi interrupts, then the vec is from 1
                         */
-                       vf->nb_msix = RTE_MIN(intr_handle->nb_efd,
-                                (uint16_t)(vf->vf_res->max_vectors - 1));
+                       vf->nb_msix =
+                               RTE_MIN(rte_intr_nb_efd_get(intr_handle),
+                               (uint16_t)(vf->vf_res->max_vectors - 1));
                        vf->msix_base = IAVF_RX_VEC_START;
                        vec = IAVF_RX_VEC_START;
                        for (i = 0; i < dev->data->nb_rx_queues; i++) {
                                qv_map[i].queue_id = i;
                                qv_map[i].vector_id = vec;
-                               intr_handle->intr_vec[i] = vec++;
+                               rte_intr_vec_list_index_set(intr_handle,
+                                                                  i, vec++);
                                if (vec >= vf->nb_msix + IAVF_RX_VEC_START)
                                        vec = IAVF_RX_VEC_START;
                        }
@@ -775,8 +887,7 @@ config_irq_map_err:
        vf->qv_map = NULL;
 
 qv_map_alloc_err:
-       rte_free(intr_handle->intr_vec);
-       intr_handle->intr_vec = NULL;
+       rte_intr_vec_list_free(intr_handle);
 
        return -1;
 }
@@ -841,6 +952,9 @@ iavf_dev_start(struct rte_eth_dev *dev)
                return -1;
        }
 
+       if (iavf_set_vf_quanta_size(adapter, index, num_queue_pairs) != 0)
+               PMD_DRV_LOG(WARNING, "configure quanta size failed");
+
        /* If needed, send configure queues msg multiple times to make the
         * adminq buffer length smaller than the 4K limitation.
         */
@@ -912,10 +1026,7 @@ iavf_dev_stop(struct rte_eth_dev *dev)
        /* Disable the interrupt for Rx */
        rte_intr_efd_disable(intr_handle);
        /* Rx interrupt vector mapping free */
-       if (intr_handle->intr_vec) {
-               rte_free(intr_handle->intr_vec);
-               intr_handle->intr_vec = NULL;
-       }
+       rte_intr_vec_list_free(intr_handle);
 
        /* remove all mac addrs */
        iavf_add_del_all_mac_addr(adapter, false);
@@ -924,6 +1035,9 @@ iavf_dev_stop(struct rte_eth_dev *dev)
        iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf->mc_addrs_num,
                                  false);
 
+       /* free iAVF security device context all related resources */
+       iavf_security_ctx_destroy(adapter);
+
        adapter->stopped = 1;
        dev->data->dev_started = 0;
 
@@ -933,7 +1047,9 @@ iavf_dev_stop(struct rte_eth_dev *dev)
 static int
 iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-       struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+       struct iavf_adapter *adapter =
+               IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+       struct iavf_info *vf = &adapter->vf;
 
        dev_info->max_rx_queues = IAVF_MAX_NUM_QUEUES_LV;
        dev_info->max_tx_queues = IAVF_MAX_NUM_QUEUES_LV;
@@ -945,6 +1061,7 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        dev_info->reta_size = vf->vf_res->rss_lut_size;
        dev_info->flow_type_rss_offloads = IAVF_RSS_OFFLOAD_ALL;
        dev_info->max_mac_addrs = IAVF_NUM_MACADDR_MAX;
+       dev_info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP;
        dev_info->rx_offload_capa =
                RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
                RTE_ETH_RX_OFFLOAD_QINQ_STRIP |
@@ -975,6 +1092,11 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_CRC)
                dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_KEEP_CRC;
 
+       if (iavf_ipsec_crypto_supported(adapter)) {
+               dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_SECURITY;
+               dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_SECURITY;
+       }
+
        dev_info->default_rxconf = (struct rte_eth_rxconf) {
                .rx_free_thresh = IAVF_DEFAULT_RX_FREE_THRESH,
                .rx_drop_en = 0,
@@ -1303,7 +1425,7 @@ iavf_dev_rss_reta_update(struct rte_eth_dev *dev,
        }
 
        rte_memcpy(vf->rss_lut, lut, reta_size);
-       /* send virtchnnl ops to configure rss*/
+       /* send virtchnl ops to configure RSS */
        ret = iavf_configure_rss_lut(adapter);
        if (ret) /* revert back */
                rte_memcpy(vf->rss_lut, lut, reta_size);
@@ -1513,7 +1635,7 @@ iavf_stat_update_32(uint64_t *offset, uint64_t *stat)
 static void
 iavf_update_stats(struct iavf_vsi *vsi, struct virtchnl_eth_stats *nes)
 {
-       struct virtchnl_eth_stats *oes = &vsi->eth_stats_offset;
+       struct virtchnl_eth_stats *oes = &vsi->eth_stats_offset.eth_stats;
 
        iavf_stat_update_48(&oes->rx_bytes, &nes->rx_bytes);
        iavf_stat_update_48(&oes->rx_unicast, &nes->rx_unicast);
@@ -1575,11 +1697,21 @@ iavf_dev_stats_reset(struct rte_eth_dev *dev)
                return ret;
 
        /* set stats offset base on current values */
-       vsi->eth_stats_offset = *pstats;
+       vsi->eth_stats_offset.eth_stats = *pstats;
 
        return 0;
 }
 
+static int
+iavf_dev_xstats_reset(struct rte_eth_dev *dev)
+{
+       struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+       iavf_dev_stats_reset(dev);
+       memset(&vf->vsi.eth_stats_offset.ips_stats, 0,
+                       sizeof(struct iavf_ipsec_crypto_stats));
+       return 0;
+}
+
 static int iavf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
                                      struct rte_eth_xstat_name *xstats_names,
                                      __rte_unused unsigned int limit)
@@ -1595,6 +1727,27 @@ static int iavf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
        return IAVF_NB_XSTATS;
 }
 
+static void
+iavf_dev_update_ipsec_xstats(struct rte_eth_dev *ethdev,
+               struct iavf_ipsec_crypto_stats *ips)
+{
+       uint16_t idx;
+       for (idx = 0; idx < ethdev->data->nb_rx_queues; idx++) {
+               struct iavf_rx_queue *rxq;
+               struct iavf_ipsec_crypto_stats *stats;
+               rxq = (struct iavf_rx_queue *)ethdev->data->rx_queues[idx];
+               stats = &rxq->stats.ipsec_crypto;
+               ips->icount += stats->icount;
+               ips->ibytes += stats->ibytes;
+               ips->ierrors.count += stats->ierrors.count;
+               ips->ierrors.sad_miss += stats->ierrors.sad_miss;
+               ips->ierrors.not_processed += stats->ierrors.not_processed;
+               ips->ierrors.icv_check += stats->ierrors.icv_check;
+               ips->ierrors.ipsec_length += stats->ierrors.ipsec_length;
+               ips->ierrors.misc += stats->ierrors.misc;
+       }
+}
+
 static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
                                 struct rte_eth_xstat *xstats, unsigned int n)
 {
@@ -1605,6 +1758,7 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
        struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
        struct iavf_vsi *vsi = &vf->vsi;
        struct virtchnl_eth_stats *pstats = NULL;
+       struct iavf_eth_xstats iavf_xtats = {{0}};
 
        if (n < IAVF_NB_XSTATS)
                return IAVF_NB_XSTATS;
@@ -1617,11 +1771,15 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
                return 0;
 
        iavf_update_stats(vsi, pstats);
+       iavf_xtats.eth_stats = *pstats;
+
+       if (iavf_ipsec_crypto_supported(adapter))
+               iavf_dev_update_ipsec_xstats(dev, &iavf_xtats.ips_stats);
 
        /* loop over xstats array and values from pstats */
        for (i = 0; i < IAVF_NB_XSTATS; i++) {
                xstats[i].id = i;
-               xstats[i].value = *(uint64_t *)(((char *)pstats) +
+               xstats[i].value = *(uint64_t *)(((char *)&iavf_xtats) +
                        rte_iavf_stats_strings[i].offset);
        }
 
@@ -1639,7 +1797,8 @@ iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
        struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
        uint16_t msix_intr;
 
-       msix_intr = pci_dev->intr_handle.intr_vec[queue_id];
+       msix_intr = rte_intr_vec_list_index_get(pci_dev->intr_handle,
+                                                      queue_id);
        if (msix_intr == IAVF_MISC_VEC_ID) {
                PMD_DRV_LOG(INFO, "MISC is also enabled for control");
                IAVF_WRITE_REG(hw, IAVF_VFINT_DYN_CTL01,
@@ -1658,7 +1817,7 @@ iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
        IAVF_WRITE_FLUSH(hw);
 
        if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR)
-               rte_intr_ack(&pci_dev->intr_handle);
+               rte_intr_ack(pci_dev->intr_handle);
 
        return 0;
 }
@@ -1670,7 +1829,8 @@ iavf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
        struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        uint16_t msix_intr;
 
-       msix_intr = pci_dev->intr_handle.intr_vec[queue_id];
+       msix_intr = rte_intr_vec_list_index_get(pci_dev->intr_handle,
+                                                      queue_id);
        if (msix_intr == IAVF_MISC_VEC_ID) {
                PMD_DRV_LOG(ERR, "MISC is used for control, cannot disable it");
                return -EIO;
@@ -1718,6 +1878,7 @@ iavf_lookup_proto_xtr_type(const char *flex_name)
                { "ipv6_flow", IAVF_PROTO_XTR_IPV6_FLOW },
                { "tcp",       IAVF_PROTO_XTR_TCP       },
                { "ip_offset", IAVF_PROTO_XTR_IP_OFFSET },
+               { "ipsec_crypto_said", IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID },
        };
        uint32_t i;
 
@@ -1726,8 +1887,8 @@ iavf_lookup_proto_xtr_type(const char *flex_name)
                        return xtr_type_map[i].type;
        }
 
-       PMD_DRV_LOG(ERR, "wrong proto_xtr type, "
-                   "it should be: vlan|ipv4|ipv6|ipv6_flow|tcp|ip_offset");
+       PMD_DRV_LOG(ERR, "wrong proto_xtr type, it should be: "
+                       "vlan|ipv4|ipv6|ipv6_flow|tcp|ip_offset|ipsec_crypto_said");
 
        return -1;
 }
@@ -1936,6 +2097,25 @@ iavf_handle_proto_xtr_arg(__rte_unused const char *key, const char *value,
        return 0;
 }
 
+static int
+parse_u16(__rte_unused const char *key, const char *value, void *args)
+{
+       u16 *num = (u16 *)args;
+       u16 tmp;
+
+       errno = 0;
+       tmp = strtoull(value, NULL, 10);
+       if (errno || !tmp) {
+               PMD_DRV_LOG(WARNING, "%s: \"%s\" is not a valid u16",
+                           key, value);
+               return -1;
+       }
+
+       *num = tmp;
+
+       return 0;
+}
+
 static int iavf_parse_devargs(struct rte_eth_dev *dev)
 {
        struct iavf_adapter *ad =
@@ -1962,6 +2142,20 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
        if (ret)
                goto bail;
 
+       ret = rte_kvargs_process(kvlist, IAVF_QUANTA_SIZE_ARG,
+                                &parse_u16, &ad->devargs.quanta_size);
+       if (ret)
+               goto bail;
+
+       if (ad->devargs.quanta_size == 0)
+               ad->devargs.quanta_size = 1024;
+
+       if (ad->devargs.quanta_size < 256 || ad->devargs.quanta_size > 4096 ||
+           ad->devargs.quanta_size & 0x40) {
+               PMD_INIT_LOG(ERR, "invalid quanta size\n");
+               return -EINVAL;
+       }
+
 bail:
        rte_kvargs_free(kvlist);
        return ret;
@@ -2122,6 +2316,9 @@ iavf_init_vf(struct rte_eth_dev *dev)
                }
        }
 
+       if (vf->vsi_res->num_queue_pairs > IAVF_MAX_NUM_QUEUES_DFLT)
+               vf->lv_enabled = true;
+
        if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC) {
                if (iavf_get_supported_rxdid(adapter) != 0) {
                        PMD_INIT_LOG(ERR, "failed to do get supported rxdid");
@@ -2332,7 +2529,7 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
        }
 
        /* set default ptype table */
-       adapter->ptype_tbl = iavf_get_default_ptype_table();
+       iavf_set_default_ptype_table(eth_dev);
 
        /* copy mac addr */
        eth_dev->data->mac_addrs = rte_zmalloc(
@@ -2355,12 +2552,12 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
 
        if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) {
                /* register callback func to eal lib */
-               rte_intr_callback_register(&pci_dev->intr_handle,
+               rte_intr_callback_register(pci_dev->intr_handle,
                                           iavf_dev_interrupt_handler,
                                           (void *)eth_dev);
 
                /* enable uio intr after callback register */
-               rte_intr_enable(&pci_dev->intr_handle);
+               rte_intr_enable(pci_dev->intr_handle);
        } else {
                rte_eal_alarm_set(IAVF_ALARM_INTERVAL,
                                  iavf_dev_alarm_handler, eth_dev);
@@ -2375,8 +2572,31 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
                goto flow_init_err;
        }
 
+       /** Check if the IPsec Crypto offload is supported and create
+        *  security_ctx if it is.
+        */
+       if (iavf_ipsec_crypto_supported(adapter)) {
+               /* Initialize security_ctx only for primary process*/
+               ret = iavf_security_ctx_create(adapter);
+               if (ret) {
+                       PMD_INIT_LOG(ERR, "failed to create ipsec crypto security instance");
+                       return ret;
+               }
+
+               ret = iavf_security_init(adapter);
+               if (ret) {
+                       PMD_INIT_LOG(ERR, "failed to initialized ipsec crypto resources");
+                       return ret;
+               }
+       }
+
        iavf_default_rss_disable(adapter);
 
+
+       /* Start device watchdog */
+       iavf_dev_watchdog_enable(adapter);
+
+
        return 0;
 
 flow_init_err:
@@ -2394,7 +2614,7 @@ iavf_dev_close(struct rte_eth_dev *dev)
 {
        struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
-       struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+       struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
        struct iavf_adapter *adapter =
                IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
        struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
@@ -2460,6 +2680,9 @@ iavf_dev_close(struct rte_eth_dev *dev)
        if (vf->vf_reset && !rte_pci_set_bus_master(pci_dev, true))
                vf->vf_reset = false;
 
+       /* disable watchdog */
+       iavf_dev_watchdog_disable(adapter);
+
        return ret;
 }