net/ark: fix kvargs memory leak
[dpdk.git] / drivers / net / qede / base / ecore_sriov.c
index 280c992..db2873e 100644 (file)
@@ -52,6 +52,7 @@ const char *ecore_channel_tlvs_string[] = {
        "CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN",
        "CHANNEL_TLV_VPORT_UPDATE_SGE_TPA",
        "CHANNEL_TLV_UPDATE_TUNN_PARAM",
+       "CHANNEL_TLV_COALESCE_UPDATE",
        "CHANNEL_TLV_MAX"
 };
 
@@ -191,28 +192,90 @@ struct ecore_vf_info *ecore_iov_get_vf_info(struct ecore_hwfn *p_hwfn,
        return vf;
 }
 
+static struct ecore_queue_cid *
+ecore_iov_get_vf_rx_queue_cid(struct ecore_hwfn *p_hwfn,
+                             struct ecore_vf_info *p_vf,
+                             struct ecore_vf_queue *p_queue)
+{
+       int i;
+
+       for (i = 0; i < MAX_QUEUES_PER_QZONE; i++) {
+               if (p_queue->cids[i].p_cid &&
+                   !p_queue->cids[i].b_is_tx)
+                       return p_queue->cids[i].p_cid;
+       }
+
+       return OSAL_NULL;
+}
+
+enum ecore_iov_validate_q_mode {
+       ECORE_IOV_VALIDATE_Q_NA,
+       ECORE_IOV_VALIDATE_Q_ENABLE,
+       ECORE_IOV_VALIDATE_Q_DISABLE,
+};
+
+static bool ecore_iov_validate_queue_mode(struct ecore_hwfn *p_hwfn,
+                                         struct ecore_vf_info *p_vf,
+                                         u16 qid,
+                                         enum ecore_iov_validate_q_mode mode,
+                                         bool b_is_tx)
+{
+       int i;
+
+       if (mode == ECORE_IOV_VALIDATE_Q_NA)
+               return true;
+
+       for (i = 0; i < MAX_QUEUES_PER_QZONE; i++) {
+               struct ecore_vf_queue_cid *p_qcid;
+
+               p_qcid = &p_vf->vf_queues[qid].cids[i];
+
+               if (p_qcid->p_cid == OSAL_NULL)
+                       continue;
+
+               if (p_qcid->b_is_tx != b_is_tx)
+                       continue;
+
+               /* Found. It's enabled. */
+               return (mode == ECORE_IOV_VALIDATE_Q_ENABLE);
+       }
+
+       /* In case we haven't found any valid cid, then its disabled */
+       return (mode == ECORE_IOV_VALIDATE_Q_DISABLE);
+}
+
 static bool ecore_iov_validate_rxq(struct ecore_hwfn *p_hwfn,
                                   struct ecore_vf_info *p_vf,
-                                  u16 rx_qid)
+                                  u16 rx_qid,
+                                  enum ecore_iov_validate_q_mode mode)
 {
-       if (rx_qid >= p_vf->num_rxqs)
+       if (rx_qid >= p_vf->num_rxqs) {
                DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
                           "VF[0x%02x] - can't touch Rx queue[%04x];"
                           " Only 0x%04x are allocated\n",
                           p_vf->abs_vf_id, rx_qid, p_vf->num_rxqs);
-       return rx_qid < p_vf->num_rxqs;
+               return false;
+       }
+
+       return ecore_iov_validate_queue_mode(p_hwfn, p_vf, rx_qid,
+                                            mode, false);
 }
 
 static bool ecore_iov_validate_txq(struct ecore_hwfn *p_hwfn,
                                   struct ecore_vf_info *p_vf,
-                                  u16 tx_qid)
+                                  u16 tx_qid,
+                                  enum ecore_iov_validate_q_mode mode)
 {
-       if (tx_qid >= p_vf->num_txqs)
+       if (tx_qid >= p_vf->num_txqs) {
                DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
                           "VF[0x%02x] - can't touch Tx queue[%04x];"
                           " Only 0x%04x are allocated\n",
                           p_vf->abs_vf_id, tx_qid, p_vf->num_txqs);
-       return tx_qid < p_vf->num_txqs;
+               return false;
+       }
+
+       return ecore_iov_validate_queue_mode(p_hwfn, p_vf, tx_qid,
+                                            mode, true);
 }
 
 static bool ecore_iov_validate_sb(struct ecore_hwfn *p_hwfn,
@@ -233,13 +296,16 @@ static bool ecore_iov_validate_sb(struct ecore_hwfn *p_hwfn,
        return false;
 }
 
+/* Is there at least 1 queue open? */
 static bool ecore_iov_validate_active_rxq(struct ecore_hwfn *p_hwfn,
                                          struct ecore_vf_info *p_vf)
 {
        u8 i;
 
        for (i = 0; i < p_vf->num_rxqs; i++)
-               if (p_vf->vf_queues[i].p_rx_cid)
+               if (ecore_iov_validate_queue_mode(p_hwfn, p_vf, i,
+                                                 ECORE_IOV_VALIDATE_Q_ENABLE,
+                                                 false))
                        return true;
 
        return false;
@@ -250,8 +316,10 @@ static bool ecore_iov_validate_active_txq(struct ecore_hwfn *p_hwfn,
 {
        u8 i;
 
-       for (i = 0; i < p_vf->num_rxqs; i++)
-               if (p_vf->vf_queues[i].p_tx_cid)
+       for (i = 0; i < p_vf->num_txqs; i++)
+               if (ecore_iov_validate_queue_mode(p_hwfn, p_vf, i,
+                                                 ECORE_IOV_VALIDATE_Q_ENABLE,
+                                                 true))
                        return true;
 
        return false;
@@ -425,8 +493,6 @@ static void ecore_iov_setup_vfdb(struct ecore_hwfn *p_hwfn)
                return;
        }
 
-       p_iov_info->base_vport_id = 1;  /* @@@TBD resource allocation */
-
        for (idx = 0; idx < p_iov->total_vfs; idx++) {
                struct ecore_vf_info *vf = &p_iov_info->vfs_array[idx];
                u32 concrete;
@@ -455,8 +521,6 @@ static void ecore_iov_setup_vfdb(struct ecore_hwfn *p_hwfn)
                /* TODO - need to devise a better way of getting opaque */
                vf->opaque_fid = (p_hwfn->hw_info.opaque_fid & 0xff) |
                    (vf->abs_vf_id << 8);
-               /* @@TBD MichalK - add base vport_id of VFs to equation */
-               vf->vport_id = p_iov_info->base_vport_id + idx;
 
                vf->num_mac_filters = ECORE_ETH_VF_NUM_MAC_FILTERS;
                vf->num_vlan_filters = ECORE_ETH_VF_NUM_VLAN_FILTERS;
@@ -954,11 +1018,51 @@ static void ecore_iov_free_vf_igu_sbs(struct ecore_hwfn *p_hwfn,
        vf->num_sbs = 0;
 }
 
+void ecore_iov_set_link(struct ecore_hwfn *p_hwfn,
+                       u16 vfid,
+                       struct ecore_mcp_link_params *params,
+                       struct ecore_mcp_link_state *link,
+                       struct ecore_mcp_link_capabilities *p_caps)
+{
+       struct ecore_vf_info *p_vf = ecore_iov_get_vf_info(p_hwfn, vfid, false);
+       struct ecore_bulletin_content *p_bulletin;
+
+       if (!p_vf)
+               return;
+
+       p_bulletin = p_vf->bulletin.p_virt;
+       p_bulletin->req_autoneg = params->speed.autoneg;
+       p_bulletin->req_adv_speed = params->speed.advertised_speeds;
+       p_bulletin->req_forced_speed = params->speed.forced_speed;
+       p_bulletin->req_autoneg_pause = params->pause.autoneg;
+       p_bulletin->req_forced_rx = params->pause.forced_rx;
+       p_bulletin->req_forced_tx = params->pause.forced_tx;
+       p_bulletin->req_loopback = params->loopback_mode;
+
+       p_bulletin->link_up = link->link_up;
+       p_bulletin->speed = link->speed;
+       p_bulletin->full_duplex = link->full_duplex;
+       p_bulletin->autoneg = link->an;
+       p_bulletin->autoneg_complete = link->an_complete;
+       p_bulletin->parallel_detection = link->parallel_detection;
+       p_bulletin->pfc_enabled = link->pfc_enabled;
+       p_bulletin->partner_adv_speed = link->partner_adv_speed;
+       p_bulletin->partner_tx_flow_ctrl_en = link->partner_tx_flow_ctrl_en;
+       p_bulletin->partner_rx_flow_ctrl_en = link->partner_rx_flow_ctrl_en;
+       p_bulletin->partner_adv_pause = link->partner_adv_pause;
+       p_bulletin->sfp_tx_fault = link->sfp_tx_fault;
+
+       p_bulletin->capability_speed = p_caps->speed_capabilities;
+}
+
 enum _ecore_status_t
 ecore_iov_init_hw_for_vf(struct ecore_hwfn *p_hwfn,
                         struct ecore_ptt *p_ptt,
                         struct ecore_iov_vf_init_params *p_params)
 {
+       struct ecore_mcp_link_capabilities link_caps;
+       struct ecore_mcp_link_params link_params;
+       struct ecore_mcp_link_state link_state;
        u8 num_of_vf_available_chains  = 0;
        struct ecore_vf_info *vf = OSAL_NULL;
        u16 qid, num_irqs;
@@ -978,6 +1082,34 @@ ecore_iov_init_hw_for_vf(struct ecore_hwfn *p_hwfn,
                return ECORE_INVAL;
        }
 
+       /* Perform sanity checking on the requested vport/rss */
+       if (p_params->vport_id >= RESC_NUM(p_hwfn, ECORE_VPORT)) {
+               DP_NOTICE(p_hwfn, true, "VF[%d] - can't use VPORT %02x\n",
+                         p_params->rel_vf_id, p_params->vport_id);
+               return ECORE_INVAL;
+       }
+
+       if ((p_params->num_queues > 1) &&
+           (p_params->rss_eng_id >= RESC_NUM(p_hwfn, ECORE_RSS_ENG))) {
+               DP_NOTICE(p_hwfn, true, "VF[%d] - can't use RSS_ENG %02x\n",
+                         p_params->rel_vf_id, p_params->rss_eng_id);
+               return ECORE_INVAL;
+       }
+
+       /* TODO - remove this once we get confidence of change */
+       if (!p_params->vport_id) {
+               DP_NOTICE(p_hwfn, false,
+                         "VF[%d] - Unlikely that VF uses vport0. Forgotten?\n",
+                         p_params->rel_vf_id);
+       }
+       if ((!p_params->rss_eng_id) && (p_params->num_queues > 1)) {
+               DP_NOTICE(p_hwfn, false,
+                         "VF[%d] - Unlikely that VF uses RSS_eng0. Forgotten?\n",
+                         p_params->rel_vf_id);
+       }
+       vf->vport_id = p_params->vport_id;
+       vf->rss_eng_id = p_params->rss_eng_id;
+
        /* Perform sanity checking on the requested queue_id */
        for (i = 0; i < p_params->num_queues; i++) {
                u16 min_vf_qzone = (u16)FEAT_NUM(p_hwfn, ECORE_PF_L2_QUE);
@@ -1030,21 +1162,28 @@ ecore_iov_init_hw_for_vf(struct ecore_hwfn *p_hwfn,
        vf->num_txqs = num_of_vf_available_chains;
 
        for (i = 0; i < vf->num_rxqs; i++) {
-               struct ecore_vf_q_info *p_queue = &vf->vf_queues[i];
+               struct ecore_vf_queue *p_queue = &vf->vf_queues[i];
 
                p_queue->fw_rx_qid = p_params->req_rx_queue[i];
                p_queue->fw_tx_qid = p_params->req_tx_queue[i];
 
-               /* CIDs are per-VF, so no problem having them 0-based. */
-               p_queue->fw_cid = i;
-
                DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
-                          "VF[%d] - Q[%d] SB %04x, qid [Rx %04x Tx %04x]  CID %04x\n",
+                          "VF[%d] - Q[%d] SB %04x, qid [Rx %04x Tx %04x]\n",
                           vf->relative_vf_id, i, vf->igu_sbs[i],
-                          p_queue->fw_rx_qid, p_queue->fw_tx_qid,
-                          p_queue->fw_cid);
+                          p_queue->fw_rx_qid, p_queue->fw_tx_qid);
        }
 
+       /* Update the link configuration in bulletin.
+        */
+       OSAL_MEMCPY(&link_params, ecore_mcp_get_link_params(p_hwfn),
+                   sizeof(link_params));
+       OSAL_MEMCPY(&link_state, ecore_mcp_get_link_state(p_hwfn),
+                   sizeof(link_state));
+       OSAL_MEMCPY(&link_caps, ecore_mcp_get_link_capabilities(p_hwfn),
+                   sizeof(link_caps));
+       ecore_iov_set_link(p_hwfn, p_params->rel_vf_id,
+                          &link_params, &link_state, &link_caps);
+
        rc = ecore_iov_enable_vf_access(p_hwfn, p_ptt, vf);
 
        if (rc == ECORE_SUCCESS) {
@@ -1059,43 +1198,6 @@ ecore_iov_init_hw_for_vf(struct ecore_hwfn *p_hwfn,
        return rc;
 }
 
-void ecore_iov_set_link(struct ecore_hwfn *p_hwfn,
-                       u16 vfid,
-                       struct ecore_mcp_link_params *params,
-                       struct ecore_mcp_link_state *link,
-                       struct ecore_mcp_link_capabilities *p_caps)
-{
-       struct ecore_vf_info *p_vf = ecore_iov_get_vf_info(p_hwfn, vfid, false);
-       struct ecore_bulletin_content *p_bulletin;
-
-       if (!p_vf)
-               return;
-
-       p_bulletin = p_vf->bulletin.p_virt;
-       p_bulletin->req_autoneg = params->speed.autoneg;
-       p_bulletin->req_adv_speed = params->speed.advertised_speeds;
-       p_bulletin->req_forced_speed = params->speed.forced_speed;
-       p_bulletin->req_autoneg_pause = params->pause.autoneg;
-       p_bulletin->req_forced_rx = params->pause.forced_rx;
-       p_bulletin->req_forced_tx = params->pause.forced_tx;
-       p_bulletin->req_loopback = params->loopback_mode;
-
-       p_bulletin->link_up = link->link_up;
-       p_bulletin->speed = link->speed;
-       p_bulletin->full_duplex = link->full_duplex;
-       p_bulletin->autoneg = link->an;
-       p_bulletin->autoneg_complete = link->an_complete;
-       p_bulletin->parallel_detection = link->parallel_detection;
-       p_bulletin->pfc_enabled = link->pfc_enabled;
-       p_bulletin->partner_adv_speed = link->partner_adv_speed;
-       p_bulletin->partner_tx_flow_ctrl_en = link->partner_tx_flow_ctrl_en;
-       p_bulletin->partner_rx_flow_ctrl_en = link->partner_rx_flow_ctrl_en;
-       p_bulletin->partner_adv_pause = link->partner_adv_pause;
-       p_bulletin->sfp_tx_fault = link->sfp_tx_fault;
-
-       p_bulletin->capability_speed = p_caps->speed_capabilities;
-}
-
 enum _ecore_status_t ecore_iov_release_hw_for_vf(struct ecore_hwfn *p_hwfn,
                                                 struct ecore_ptt *p_ptt,
                                                 u16 rel_vf_id)
@@ -1404,7 +1506,7 @@ struct ecore_public_vf_info
 static void ecore_iov_vf_cleanup(struct ecore_hwfn *p_hwfn,
                                 struct ecore_vf_info *p_vf)
 {
-       u32 i;
+       u32 i, j;
        p_vf->vf_bulletin = 0;
        p_vf->vport_instance = 0;
        p_vf->configured_features = 0;
@@ -1416,18 +1518,15 @@ static void ecore_iov_vf_cleanup(struct ecore_hwfn *p_hwfn,
        p_vf->num_active_rxqs = 0;
 
        for (i = 0; i < ECORE_MAX_VF_CHAINS_PER_PF; i++) {
-               struct ecore_vf_q_info *p_queue = &p_vf->vf_queues[i];
+               struct ecore_vf_queue *p_queue = &p_vf->vf_queues[i];
 
-               if (p_queue->p_rx_cid) {
-                       ecore_eth_queue_cid_release(p_hwfn,
-                                                   p_queue->p_rx_cid);
-                       p_queue->p_rx_cid = OSAL_NULL;
-               }
+               for (j = 0; j < MAX_QUEUES_PER_QZONE; j++) {
+                       if (!p_queue->cids[j].p_cid)
+                               continue;
 
-               if (p_queue->p_tx_cid) {
                        ecore_eth_queue_cid_release(p_hwfn,
-                                                   p_queue->p_tx_cid);
-                       p_queue->p_tx_cid = OSAL_NULL;
+                                                   p_queue->cids[j].p_cid);
+                       p_queue->cids[j].p_cid = OSAL_NULL;
                }
        }
 
@@ -1442,7 +1541,7 @@ static u8 ecore_iov_vf_mbx_acquire_resc(struct ecore_hwfn *p_hwfn,
                                        struct vf_pf_resc_request *p_req,
                                        struct pf_vf_resc *p_resp)
 {
-       int i;
+       u8 i;
 
        /* Queue related information */
        p_resp->num_rxqs = p_vf->num_rxqs;
@@ -1463,7 +1562,7 @@ static u8 ecore_iov_vf_mbx_acquire_resc(struct ecore_hwfn *p_hwfn,
        for (i = 0; i < p_resp->num_rxqs; i++) {
                ecore_fw_l2_queue(p_hwfn, p_vf->vf_queues[i].fw_rx_qid,
                                  (u16 *)&p_resp->hw_qid[i]);
-               p_resp->cid[i] = p_vf->vf_queues[i].fw_cid;
+               p_resp->cid[i] = i;
        }
 
        /* Filter related information */
@@ -1866,9 +1965,12 @@ ecore_iov_configure_vport_forced(struct ecore_hwfn *p_hwfn,
 
                /* Update all the Rx queues */
                for (i = 0; i < ECORE_MAX_VF_CHAINS_PER_PF; i++) {
-                       struct ecore_queue_cid *p_cid;
+                       struct ecore_vf_queue *p_queue = &p_vf->vf_queues[i];
+                       struct ecore_queue_cid *p_cid = OSAL_NULL;
 
-                       p_cid = p_vf->vf_queues[i].p_rx_cid;
+                       /* There can be at most 1 Rx queue on qzone. Find it */
+                       p_cid = ecore_iov_get_vf_rx_queue_cid(p_hwfn, p_vf,
+                                                             p_queue);
                        if (p_cid == OSAL_NULL)
                                continue;
 
@@ -1925,6 +2027,8 @@ static void ecore_iov_vf_mbx_start_vport(struct ecore_hwfn *p_hwfn,
        vf->state = VF_ENABLED;
        start = &mbx->req_virt->start_vport;
 
+       ecore_iov_enable_vf_traffic(p_hwfn, p_ptt, vf);
+
        /* Initialize Status block in CAU */
        for (sb_id = 0; sb_id < vf->num_sbs; sb_id++) {
                if (!start->sb_addr[sb_id]) {
@@ -1939,7 +2043,6 @@ static void ecore_iov_vf_mbx_start_vport(struct ecore_hwfn *p_hwfn,
                                      vf->igu_sbs[sb_id],
                                      vf->abs_vf_id, 1);
        }
-       ecore_iov_enable_vf_traffic(p_hwfn, p_ptt, vf);
 
        vf->mtu = start->mtu;
        vf->shadow_config.inner_vlan_removal = start->inner_vlan_removal;
@@ -2073,19 +2176,32 @@ static void ecore_iov_vf_mbx_start_rxq(struct ecore_hwfn *p_hwfn,
                                       struct ecore_vf_info *vf)
 {
        struct ecore_queue_start_common_params params;
+       struct ecore_queue_cid_vf_params vf_params;
        struct ecore_iov_vf_mbx *mbx = &vf->vf_mbx;
        u8 status = PFVF_STATUS_NO_RESOURCE;
-       struct ecore_vf_q_info *p_queue;
+       struct ecore_vf_queue *p_queue;
        struct vfpf_start_rxq_tlv *req;
+       struct ecore_queue_cid *p_cid;
        bool b_legacy_vf = false;
+       u8 qid_usage_idx;
        enum _ecore_status_t rc;
 
        req = &mbx->req_virt->start_rxq;
 
-       if (!ecore_iov_validate_rxq(p_hwfn, vf, req->rx_qid) ||
+       if (!ecore_iov_validate_rxq(p_hwfn, vf, req->rx_qid,
+                                   ECORE_IOV_VALIDATE_Q_DISABLE) ||
            !ecore_iov_validate_sb(p_hwfn, vf, req->hw_sb))
                goto out;
 
+       /* Legacy VFs made assumptions on the CID their queues connected to,
+        * assuming queue X used CID X.
+        * TODO - need to validate that there was no official release post
+        * the current legacy scheme that still made that assumption.
+        */
+       if (vf->acquire.vfdev_info.eth_fp_hsi_minor ==
+           ETH_HSI_VER_NO_PKT_LEN_TUNN)
+               b_legacy_vf = true;
+
        /* Acquire a new queue-cid */
        p_queue = &vf->vf_queues[req->rx_qid];
 
@@ -2096,39 +2212,42 @@ static void ecore_iov_vf_mbx_start_rxq(struct ecore_hwfn *p_hwfn,
        params.sb = req->hw_sb;
        params.sb_idx = req->sb_index;
 
-       p_queue->p_rx_cid = _ecore_eth_queue_to_cid(p_hwfn,
-                                                   vf->opaque_fid,
-                                                   p_queue->fw_cid,
-                                                   (u8)req->rx_qid,
-                                                   &params);
-       if (p_queue->p_rx_cid == OSAL_NULL)
+       /* TODO - set qid_usage_idx according to extended TLV. For now, use
+        * '0' for Rx.
+        */
+       qid_usage_idx = 0;
+
+       OSAL_MEM_ZERO(&vf_params, sizeof(vf_params));
+       vf_params.vfid = vf->relative_vf_id;
+       vf_params.vf_qid = (u8)req->rx_qid;
+       vf_params.b_legacy = b_legacy_vf;
+       vf_params.qid_usage_idx = qid_usage_idx;
+
+       p_cid = ecore_eth_queue_to_cid(p_hwfn, vf->opaque_fid,
+                                      &params, &vf_params);
+       if (p_cid == OSAL_NULL)
                goto out;
 
        /* Legacy VFs have their Producers in a different location, which they
         * calculate on their own and clean the producer prior to this.
         */
-       if (vf->acquire.vfdev_info.eth_fp_hsi_minor ==
-           ETH_HSI_VER_NO_PKT_LEN_TUNN)
-               b_legacy_vf = true;
-       else
+       if (!b_legacy_vf)
                REG_WR(p_hwfn,
                       GTT_BAR0_MAP_REG_MSDM_RAM +
                       MSTORM_ETH_VF_PRODS_OFFSET(vf->abs_vf_id, req->rx_qid),
                       0);
-       p_queue->p_rx_cid->b_legacy_vf = b_legacy_vf;
-
 
-       rc = ecore_eth_rxq_start_ramrod(p_hwfn,
-                                       p_queue->p_rx_cid,
+       rc = ecore_eth_rxq_start_ramrod(p_hwfn, p_cid,
                                        req->bd_max_bytes,
                                        req->rxq_addr,
                                        req->cqe_pbl_addr,
                                        req->cqe_pbl_size);
        if (rc != ECORE_SUCCESS) {
                status = PFVF_STATUS_FAILURE;
-               ecore_eth_queue_cid_release(p_hwfn, p_queue->p_rx_cid);
-               p_queue->p_rx_cid = OSAL_NULL;
+               ecore_eth_queue_cid_release(p_hwfn, p_cid);
        } else {
+               p_queue->cids[qid_usage_idx].p_cid = p_cid;
+               p_queue->cids[qid_usage_idx].b_is_tx = false;
                status = PFVF_STATUS_SUCCESS;
                vf->num_active_rxqs++;
        }
@@ -2213,6 +2332,7 @@ static void ecore_iov_vf_mbx_update_tunn_param(struct ecore_hwfn *p_hwfn,
        bool b_update_required = false;
        struct ecore_tunnel_info tunn;
        u16 tunn_feature_mask = 0;
+       int i;
 
        mbx->offset = (u8 *)mbx->reply_virt;
 
@@ -2260,11 +2380,20 @@ static void ecore_iov_vf_mbx_update_tunn_param(struct ecore_hwfn *p_hwfn,
 
        /* If ECORE client is willing to update anything ? */
        if (b_update_required) {
+               u16 geneve_port;
+
                rc = ecore_sp_pf_update_tunn_cfg(p_hwfn, &tunn,
                                                 ECORE_SPQ_MODE_EBLOCK,
                                                 OSAL_NULL);
                if (rc != ECORE_SUCCESS)
                        status = PFVF_STATUS_FAILURE;
+
+               geneve_port = p_tun->geneve_port.port;
+               ecore_for_each_vf(p_hwfn, i) {
+                       ecore_iov_bulletin_set_udp_ports(p_hwfn, i,
+                                                        p_tun->vxlan_port.port,
+                                                        geneve_port);
+               }
        }
 
 send_resp:
@@ -2281,6 +2410,7 @@ send_resp:
 static void ecore_iov_vf_mbx_start_txq_resp(struct ecore_hwfn *p_hwfn,
                                            struct ecore_ptt *p_ptt,
                                            struct ecore_vf_info *p_vf,
+                                           u32 cid,
                                            u8 status)
 {
        struct ecore_iov_vf_mbx *mbx = &p_vf->vf_mbx;
@@ -2309,12 +2439,8 @@ static void ecore_iov_vf_mbx_start_txq_resp(struct ecore_hwfn *p_hwfn,
                      sizeof(struct channel_list_end_tlv));
 
        /* Update the TLV with the response */
-       if ((status == PFVF_STATUS_SUCCESS) && !b_legacy) {
-               u16 qid = mbx->req_virt->start_txq.tx_qid;
-
-               p_tlv->offset = DB_ADDR_VF(p_vf->vf_queues[qid].fw_cid,
-                                          DQ_DEMS_LEGACY);
-       }
+       if ((status == PFVF_STATUS_SUCCESS) && !b_legacy)
+               p_tlv->offset = DB_ADDR_VF(cid, DQ_DEMS_LEGACY);
 
        ecore_iov_send_response(p_hwfn, p_ptt, p_vf, length, status);
 }
@@ -2324,20 +2450,34 @@ static void ecore_iov_vf_mbx_start_txq(struct ecore_hwfn *p_hwfn,
                                       struct ecore_vf_info *vf)
 {
        struct ecore_queue_start_common_params params;
+       struct ecore_queue_cid_vf_params vf_params;
        struct ecore_iov_vf_mbx *mbx = &vf->vf_mbx;
        u8 status = PFVF_STATUS_NO_RESOURCE;
-       struct ecore_vf_q_info *p_queue;
+       struct ecore_vf_queue *p_queue;
        struct vfpf_start_txq_tlv *req;
+       struct ecore_queue_cid *p_cid;
+       bool b_legacy_vf = false;
+       u8 qid_usage_idx;
+       u32 cid = 0;
        enum _ecore_status_t rc;
        u16 pq;
 
        OSAL_MEMSET(&params, 0, sizeof(params));
        req = &mbx->req_virt->start_txq;
 
-       if (!ecore_iov_validate_txq(p_hwfn, vf, req->tx_qid) ||
+       if (!ecore_iov_validate_txq(p_hwfn, vf, req->tx_qid,
+                                   ECORE_IOV_VALIDATE_Q_NA) ||
            !ecore_iov_validate_sb(p_hwfn, vf, req->hw_sb))
                goto out;
 
+       /* In case this is a legacy VF - need to know to use the right cids.
+        * TODO - need to validate that there was no official release post
+        * the current legacy scheme that still made that assumption.
+        */
+       if (vf->acquire.vfdev_info.eth_fp_hsi_minor ==
+           ETH_HSI_VER_NO_PKT_LEN_TUNN)
+               b_legacy_vf = true;
+
        /* Acquire a new queue-cid */
        p_queue = &vf->vf_queues[req->tx_qid];
 
@@ -2347,29 +2487,42 @@ static void ecore_iov_vf_mbx_start_txq(struct ecore_hwfn *p_hwfn,
        params.sb = req->hw_sb;
        params.sb_idx = req->sb_index;
 
-       p_queue->p_tx_cid = _ecore_eth_queue_to_cid(p_hwfn,
-                                                   vf->opaque_fid,
-                                                   p_queue->fw_cid,
-                                                   (u8)req->tx_qid,
-                                                   &params);
-       if (p_queue->p_tx_cid == OSAL_NULL)
+       /* TODO - set qid_usage_idx according to extended TLV. For now, use
+        * '1' for Tx.
+        */
+       qid_usage_idx = 1;
+
+       if (p_queue->cids[qid_usage_idx].p_cid)
+               goto out;
+
+       OSAL_MEM_ZERO(&vf_params, sizeof(vf_params));
+       vf_params.vfid = vf->relative_vf_id;
+       vf_params.vf_qid = (u8)req->tx_qid;
+       vf_params.b_legacy = b_legacy_vf;
+       vf_params.qid_usage_idx = qid_usage_idx;
+
+       p_cid = ecore_eth_queue_to_cid(p_hwfn, vf->opaque_fid,
+                                      &params, &vf_params);
+       if (p_cid == OSAL_NULL)
                goto out;
 
        pq = ecore_get_cm_pq_idx_vf(p_hwfn,
                                    vf->relative_vf_id);
-       rc = ecore_eth_txq_start_ramrod(p_hwfn, p_queue->p_tx_cid,
+       rc = ecore_eth_txq_start_ramrod(p_hwfn, p_cid,
                                        req->pbl_addr, req->pbl_size, pq);
        if (rc != ECORE_SUCCESS) {
                status = PFVF_STATUS_FAILURE;
-               ecore_eth_queue_cid_release(p_hwfn,
-                                           p_queue->p_tx_cid);
-               p_queue->p_tx_cid = OSAL_NULL;
+               ecore_eth_queue_cid_release(p_hwfn, p_cid);
        } else {
                status = PFVF_STATUS_SUCCESS;
+               p_queue->cids[qid_usage_idx].p_cid = p_cid;
+               p_queue->cids[qid_usage_idx].b_is_tx = true;
+               cid = p_cid->cid;
        }
 
 out:
-       ecore_iov_vf_mbx_start_txq_resp(p_hwfn, p_ptt, vf, status);
+       ecore_iov_vf_mbx_start_txq_resp(p_hwfn, p_ptt, vf,
+                                       cid, status);
 }
 
 static enum _ecore_status_t ecore_iov_vf_stop_rxqs(struct ecore_hwfn *p_hwfn,
@@ -2378,26 +2531,38 @@ static enum _ecore_status_t ecore_iov_vf_stop_rxqs(struct ecore_hwfn *p_hwfn,
                                                   u8 num_rxqs,
                                                   bool cqe_completion)
 {
-       struct ecore_vf_q_info *p_queue;
        enum _ecore_status_t rc = ECORE_SUCCESS;
-       int qid;
+       int qid, i;
 
+       /* TODO - improve validation [wrap around] */
        if (rxq_id + num_rxqs > OSAL_ARRAY_SIZE(vf->vf_queues))
                return ECORE_INVAL;
 
        for (qid = rxq_id; qid < rxq_id + num_rxqs; qid++) {
-               p_queue = &vf->vf_queues[qid];
-
-               if (!p_queue->p_rx_cid)
+               struct ecore_vf_queue *p_queue = &vf->vf_queues[qid];
+               struct ecore_queue_cid **pp_cid = OSAL_NULL;
+
+               /* There can be at most a single Rx per qzone. Find it */
+               for (i = 0; i < MAX_QUEUES_PER_QZONE; i++) {
+                       if (p_queue->cids[i].p_cid &&
+                           !p_queue->cids[i].b_is_tx) {
+                               pp_cid = &p_queue->cids[i].p_cid;
+                               break;
+                       }
+               }
+               if (pp_cid == OSAL_NULL) {
+                       DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
+                                  "Ignoring VF[%02x] request of closing Rx queue %04x - closed\n",
+                                  vf->relative_vf_id, qid);
                        continue;
+               }
 
-               rc = ecore_eth_rx_queue_stop(p_hwfn,
-                                            p_queue->p_rx_cid,
+               rc = ecore_eth_rx_queue_stop(p_hwfn, *pp_cid,
                                             false, cqe_completion);
                if (rc != ECORE_SUCCESS)
                        return rc;
 
-               vf->vf_queues[qid].p_rx_cid = OSAL_NULL;
+               *pp_cid = OSAL_NULL;
                vf->num_active_rxqs--;
        }
 
@@ -2409,24 +2574,33 @@ static enum _ecore_status_t ecore_iov_vf_stop_txqs(struct ecore_hwfn *p_hwfn,
                                                   u16 txq_id, u8 num_txqs)
 {
        enum _ecore_status_t rc = ECORE_SUCCESS;
-       struct ecore_vf_q_info *p_queue;
-       int qid;
+       struct ecore_vf_queue *p_queue;
+       int qid, j;
 
-       if (txq_id + num_txqs > OSAL_ARRAY_SIZE(vf->vf_queues))
+       if (!ecore_iov_validate_txq(p_hwfn, vf, txq_id,
+                                   ECORE_IOV_VALIDATE_Q_NA) ||
+           !ecore_iov_validate_txq(p_hwfn, vf, txq_id + num_txqs,
+                                   ECORE_IOV_VALIDATE_Q_NA))
                return ECORE_INVAL;
 
        for (qid = txq_id; qid < txq_id + num_txqs; qid++) {
                p_queue = &vf->vf_queues[qid];
-               if (!p_queue->p_tx_cid)
-                       continue;
+               for (j = 0; j < MAX_QUEUES_PER_QZONE; j++) {
+                       if (p_queue->cids[j].p_cid == OSAL_NULL)
+                               continue;
 
-               rc = ecore_eth_tx_queue_stop(p_hwfn,
-                                            p_queue->p_tx_cid);
-               if (rc != ECORE_SUCCESS)
-                       return rc;
+                       if (!p_queue->cids[j].b_is_tx)
+                               continue;
 
-               p_queue->p_tx_cid = OSAL_NULL;
+                       rc = ecore_eth_tx_queue_stop(p_hwfn,
+                                                    p_queue->cids[j].p_cid);
+                       if (rc != ECORE_SUCCESS)
+                               return rc;
+
+                       p_queue->cids[j].p_cid = OSAL_NULL;
+               }
        }
+
        return rc;
 }
 
@@ -2488,33 +2662,32 @@ static void ecore_iov_vf_mbx_update_rxqs(struct ecore_hwfn *p_hwfn,
        u8 status = PFVF_STATUS_FAILURE;
        u8 complete_event_flg;
        u8 complete_cqe_flg;
-       u16 qid;
        enum _ecore_status_t rc;
-       u8 i;
+       u16 i;
 
        req = &mbx->req_virt->update_rxq;
        complete_cqe_flg = !!(req->flags & VFPF_RXQ_UPD_COMPLETE_CQE_FLAG);
        complete_event_flg = !!(req->flags & VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG);
 
-       /* Validaute inputs */
-       if (req->num_rxqs + req->rx_qid > ECORE_MAX_VF_CHAINS_PER_PF ||
-           !ecore_iov_validate_rxq(p_hwfn, vf, req->rx_qid)) {
-               DP_INFO(p_hwfn, "VF[%d]: Incorrect Rxqs [%04x, %02x]\n",
-                       vf->relative_vf_id, req->rx_qid, req->num_rxqs);
-               goto out;
+       /* Validate inputs */
+       for (i = req->rx_qid; i < req->rx_qid + req->num_rxqs; i++) {
+               if (!ecore_iov_validate_rxq(p_hwfn, vf, i,
+                                           ECORE_IOV_VALIDATE_Q_ENABLE)) {
+                       DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
+                                  "VF[%d]: Incorrect Rxqs [%04x, %02x]\n",
+                                  vf->relative_vf_id, req->rx_qid,
+                                  req->num_rxqs);
+                       goto out;
+               }
        }
 
        for (i = 0; i < req->num_rxqs; i++) {
-               qid = req->rx_qid + i;
-
-               if (!vf->vf_queues[qid].p_rx_cid) {
-                       DP_INFO(p_hwfn,
-                               "VF[%d] rx_qid = %d isn`t active!\n",
-                               vf->relative_vf_id, qid);
-                       goto out;
-               }
+               struct ecore_vf_queue *p_queue;
+               u16 qid = req->rx_qid + i;
 
-               handlers[i] = vf->vf_queues[qid].p_rx_cid;
+               p_queue = &vf->vf_queues[qid];
+               handlers[i] = ecore_iov_get_vf_rx_queue_cid(p_hwfn, vf,
+                                                           p_queue);
        }
 
        rc = ecore_sp_eth_rx_queues_update(p_hwfn, (void **)&handlers,
@@ -2736,7 +2909,7 @@ ecore_iov_vp_update_rss_param(struct ecore_hwfn *p_hwfn,
                VFPF_UPDATE_RSS_KEY_FLAG);
 
        p_rss->rss_enable = p_rss_tlv->rss_enable;
-       p_rss->rss_eng_id = vf->relative_vf_id + 1;
+       p_rss->rss_eng_id = vf->rss_eng_id;
        p_rss->rss_caps = p_rss_tlv->rss_caps;
        p_rss->rss_table_size_log = p_rss_tlv->rss_table_size_log;
        OSAL_MEMCPY(p_rss->rss_key, p_rss_tlv->rss_key,
@@ -2746,8 +2919,11 @@ ecore_iov_vp_update_rss_param(struct ecore_hwfn *p_hwfn,
                                (1 << p_rss_tlv->rss_table_size_log));
 
        for (i = 0; i < table_size; i++) {
+               struct ecore_queue_cid *p_cid;
+
                q_idx = p_rss_tlv->rss_ind_table[i];
-               if (!ecore_iov_validate_rxq(p_hwfn, vf, q_idx)) {
+               if (!ecore_iov_validate_rxq(p_hwfn, vf, q_idx,
+                                           ECORE_IOV_VALIDATE_Q_ENABLE)) {
                        DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
                                   "VF[%d]: Omitting RSS due to wrong queue %04x\n",
                                   vf->relative_vf_id, q_idx);
@@ -2755,15 +2931,9 @@ ecore_iov_vp_update_rss_param(struct ecore_hwfn *p_hwfn,
                        goto out;
                }
 
-               if (!vf->vf_queues[q_idx].p_rx_cid) {
-                       DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
-                                  "VF[%d]: Omitting RSS due to inactive queue %08x\n",
-                                  vf->relative_vf_id, q_idx);
-                       b_reject = true;
-                       goto out;
-               }
-
-               p_rss->rss_ind_table[i] = vf->vf_queues[q_idx].p_rx_cid;
+               p_cid = ecore_iov_get_vf_rx_queue_cid(p_hwfn, vf,
+                                                     &vf->vf_queues[q_idx]);
+               p_rss->rss_ind_table[i] = p_cid;
        }
 
        p_data->rss_params = p_rss;
@@ -2845,7 +3015,7 @@ static void ecore_iov_vf_mbx_vport_update(struct ecore_hwfn *p_hwfn,
                goto out;
        }
 
-       p_rss_params = OSAL_VALLOC(p_hwfn->p_dev, sizeof(*p_rss_params));
+       p_rss_params = OSAL_VZALLOC(p_hwfn->p_dev, sizeof(*p_rss_params));
        if (p_rss_params == OSAL_NULL) {
                status = PFVF_STATUS_FAILURE;
                goto out;
@@ -3212,6 +3382,88 @@ static void ecore_iov_vf_mbx_release(struct ecore_hwfn *p_hwfn,
                               length, status);
 }
 
+static void ecore_iov_vf_pf_set_coalesce(struct ecore_hwfn *p_hwfn,
+                                        struct ecore_ptt *p_ptt,
+                                        struct ecore_vf_info *vf)
+{
+       struct ecore_iov_vf_mbx *mbx = &vf->vf_mbx;
+       enum _ecore_status_t rc = ECORE_SUCCESS;
+       struct vfpf_update_coalesce *req;
+       u8 status = PFVF_STATUS_FAILURE;
+       struct ecore_queue_cid *p_cid;
+       u16 rx_coal, tx_coal;
+       u16 qid;
+       int i;
+
+       req = &mbx->req_virt->update_coalesce;
+
+       rx_coal = req->rx_coal;
+       tx_coal = req->tx_coal;
+       qid = req->qid;
+
+       if (!ecore_iov_validate_rxq(p_hwfn, vf, qid,
+                                   ECORE_IOV_VALIDATE_Q_ENABLE) &&
+           rx_coal) {
+               DP_ERR(p_hwfn, "VF[%d]: Invalid Rx queue_id = %d\n",
+                      vf->abs_vf_id, qid);
+               goto out;
+       }
+
+       if (!ecore_iov_validate_txq(p_hwfn, vf, qid,
+                                   ECORE_IOV_VALIDATE_Q_ENABLE) &&
+           tx_coal) {
+               DP_ERR(p_hwfn, "VF[%d]: Invalid Tx queue_id = %d\n",
+                      vf->abs_vf_id, qid);
+               goto out;
+       }
+
+       DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
+                  "VF[%d]: Setting coalesce for VF rx_coal = %d, tx_coal = %d at queue = %d\n",
+                  vf->abs_vf_id, rx_coal, tx_coal, qid);
+
+       if (rx_coal) {
+               p_cid = ecore_iov_get_vf_rx_queue_cid(p_hwfn, vf,
+                                                     &vf->vf_queues[qid]);
+
+               rc = ecore_set_rxq_coalesce(p_hwfn, p_ptt, rx_coal, p_cid);
+               if (rc != ECORE_SUCCESS) {
+                       DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
+                                  "VF[%d]: Unable to set rx queue = %d coalesce\n",
+                                  vf->abs_vf_id, vf->vf_queues[qid].fw_rx_qid);
+                       goto out;
+               }
+       }
+
+       /* TODO - in future, it might be possible to pass this in a per-cid
+        * granularity. For now, do this for all Tx queues.
+        */
+       if (tx_coal) {
+               struct ecore_vf_queue *p_queue = &vf->vf_queues[qid];
+
+               for (i = 0; i < MAX_QUEUES_PER_QZONE; i++) {
+                       if (p_queue->cids[i].p_cid == OSAL_NULL)
+                               continue;
+
+                       if (!p_queue->cids[i].b_is_tx)
+                               continue;
+
+                       rc = ecore_set_txq_coalesce(p_hwfn, p_ptt, tx_coal,
+                                                   p_queue->cids[i].p_cid);
+                       if (rc != ECORE_SUCCESS) {
+                               DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
+                                          "VF[%d]: Unable to set tx queue coalesce\n",
+                                          vf->abs_vf_id);
+                               goto out;
+                       }
+               }
+       }
+
+       status = PFVF_STATUS_SUCCESS;
+out:
+       ecore_iov_prepare_resp(p_hwfn, p_ptt, vf, CHANNEL_TLV_COALESCE_UPDATE,
+                              sizeof(struct pfvf_def_resp_tlv), status);
+}
+
 static enum _ecore_status_t
 ecore_iov_vf_flr_poll_dorq(struct ecore_hwfn *p_hwfn,
                           struct ecore_vf_info *p_vf, struct ecore_ptt *p_ptt)
@@ -3565,6 +3817,9 @@ void ecore_iov_process_mbx_req(struct ecore_hwfn *p_hwfn,
                case CHANNEL_TLV_UPDATE_TUNN_PARAM:
                        ecore_iov_vf_mbx_update_tunn_param(p_hwfn, p_ptt, p_vf);
                        break;
+               case CHANNEL_TLV_COALESCE_UPDATE:
+                       ecore_iov_vf_pf_set_coalesce(p_hwfn, p_ptt, p_vf);
+                       break;
                }
        } else if (ecore_iov_tlv_supported(mbx->first_tlv.tl.type)) {
                /* If we've received a message from a VF we consider malicious
@@ -3896,18 +4151,6 @@ void ecore_iov_get_vfs_opaque_fid(struct ecore_hwfn *p_hwfn, int vfid,
        *opaque_fid = vf_info->opaque_fid;
 }
 
-void ecore_iov_get_vfs_vport_id(struct ecore_hwfn *p_hwfn, int vfid,
-                               u8 *p_vort_id)
-{
-       struct ecore_vf_info *vf_info;
-
-       vf_info = ecore_iov_get_vf_info(p_hwfn, (u16)vfid, true);
-       if (!vf_info)
-               return;
-
-       *p_vort_id = vf_info->vport_id;
-}
-
 void ecore_iov_bulletin_set_forced_vlan(struct ecore_hwfn *p_hwfn,
                                        u16 pvid, int vfid)
 {
@@ -3938,6 +4181,29 @@ void ecore_iov_bulletin_set_forced_vlan(struct ecore_hwfn *p_hwfn,
        ecore_iov_configure_vport_forced(p_hwfn, vf_info, feature);
 }
 
+void ecore_iov_bulletin_set_udp_ports(struct ecore_hwfn *p_hwfn,
+                                     int vfid, u16 vxlan_port, u16 geneve_port)
+{
+       struct ecore_vf_info *vf_info;
+
+       vf_info = ecore_iov_get_vf_info(p_hwfn, (u16)vfid, true);
+       if (!vf_info) {
+               DP_NOTICE(p_hwfn->p_dev, true,
+                         "Can not set udp ports, invalid vfid [%d]\n", vfid);
+               return;
+       }
+
+       if (vf_info->b_malicious) {
+               DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
+                          "Can not set udp ports to malicious VF [%d]\n",
+                          vfid);
+               return;
+       }
+
+       vf_info->bulletin.p_virt->vxlan_udp_port = vxlan_port;
+       vf_info->bulletin.p_virt->geneve_udp_port = geneve_port;
+}
+
 bool ecore_iov_vf_has_vport_instance(struct ecore_hwfn *p_hwfn, int vfid)
 {
        struct ecore_vf_info *p_vf_info;
@@ -4120,30 +4386,6 @@ enum _ecore_status_t ecore_iov_configure_tx_rate(struct ecore_hwfn *p_hwfn,
        return ecore_init_vport_rl(p_hwfn, p_ptt, abs_vp_id, (u32)val);
 }
 
-enum _ecore_status_t ecore_iov_configure_min_tx_rate(struct ecore_dev *p_dev,
-                                                    int vfid, u32 rate)
-{
-       struct ecore_vf_info *vf;
-       u8 vport_id;
-       int i;
-
-       for_each_hwfn(p_dev, i) {
-               struct ecore_hwfn *p_hwfn = &p_dev->hwfns[i];
-
-               if (!ecore_iov_pf_sanity_check(p_hwfn, vfid)) {
-                       DP_NOTICE(p_hwfn, true,
-                                 "SR-IOV sanity check failed,"
-                                 " can't set min rate\n");
-                       return ECORE_INVAL;
-               }
-       }
-
-       vf = ecore_iov_get_vf_info(ECORE_LEADING_HWFN(p_dev), (u16)vfid, true);
-       vport_id = vf->vport_id;
-
-       return ecore_configure_vport_wfq(p_dev, vport_id, rate);
-}
-
 enum _ecore_status_t ecore_iov_get_vf_stats(struct ecore_hwfn *p_hwfn,
                                            struct ecore_ptt *p_ptt,
                                            int vfid,