net/qede/base: add mailbox for resource allocation
[dpdk.git] / drivers / net / qede / base / ecore_sriov.c
index aab9925..4ffa8d0 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"
 };
 
@@ -954,11 +955,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;
@@ -1045,6 +1086,17 @@ ecore_iov_init_hw_for_vf(struct ecore_hwfn *p_hwfn,
                           p_queue->fw_cid);
        }
 
+       /* 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 +1111,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)
@@ -1925,6 +1940,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 +1956,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;
@@ -3212,6 +3228,65 @@ 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;
+
+       req = &mbx->req_virt->update_coalesce;
+
+       rx_coal = req->rx_coal;
+       tx_coal = req->tx_coal;
+       qid = req->qid;
+       p_cid = vf->vf_queues[qid].p_rx_cid;
+
+       if (!ecore_iov_validate_rxq(p_hwfn, vf, qid)) {
+               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)) {
+               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) {
+               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;
+               }
+       }
+       if (tx_coal) {
+               rc =  ecore_set_txq_coalesce(p_hwfn, p_ptt, tx_coal, p_cid);
+               if (rc != ECORE_SUCCESS) {
+                       DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
+                                  "VF[%d]: Unable to set tx queue = %d coalesce\n",
+                                  vf->abs_vf_id, vf->vf_queues[qid].fw_tx_qid);
+                       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 +3640,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