net/qede: refactoring vport handling code
[dpdk.git] / drivers / net / qede / base / ecore_vf.c
index 3182621..f4d331c 100644 (file)
@@ -1132,6 +1132,7 @@ ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn,
        if (p_params->rss_params) {
                struct ecore_rss_params *rss_params = p_params->rss_params;
                struct vfpf_vport_update_rss_tlv *p_rss_tlv;
+               int i, table_size;
 
                size = sizeof(struct vfpf_vport_update_rss_tlv);
                p_rss_tlv = ecore_add_tlv(p_hwfn, &p_iov->offset,
@@ -1153,8 +1154,16 @@ ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn,
                p_rss_tlv->rss_enable = rss_params->rss_enable;
                p_rss_tlv->rss_caps = rss_params->rss_caps;
                p_rss_tlv->rss_table_size_log = rss_params->rss_table_size_log;
-               OSAL_MEMCPY(p_rss_tlv->rss_ind_table, rss_params->rss_ind_table,
-                           sizeof(rss_params->rss_ind_table));
+
+               table_size = OSAL_MIN_T(int, T_ETH_INDIRECTION_TABLE_SIZE,
+                                       1 << p_rss_tlv->rss_table_size_log);
+               for (i = 0; i < table_size; i++) {
+                       struct ecore_queue_cid *p_queue;
+
+                       p_queue = rss_params->rss_ind_table[i];
+                       p_rss_tlv->rss_ind_table[i] = p_queue->rel.queue_id;
+               }
+
                OSAL_MEMCPY(p_rss_tlv->rss_key, rss_params->rss_key,
                            sizeof(rss_params->rss_key));
        }
@@ -1276,8 +1285,8 @@ enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn)
        struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
        struct pfvf_def_resp_tlv *resp;
        struct vfpf_first_tlv *req;
-       enum _ecore_status_t rc;
        u32 size;
+       enum _ecore_status_t rc;
 
        /* clear mailbox and prep first tlv */
        req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_RELEASE, sizeof(*req));
@@ -1415,6 +1424,48 @@ exit:
        return rc;
 }
 
+enum _ecore_status_t
+ecore_vf_pf_set_coalesce(struct ecore_hwfn *p_hwfn, u16 rx_coal, u16 tx_coal,
+                        struct ecore_queue_cid     *p_cid)
+{
+       struct ecore_vf_iov *p_iov = p_hwfn->vf_iov_info;
+       struct vfpf_update_coalesce *req;
+       struct pfvf_def_resp_tlv *resp;
+       enum _ecore_status_t rc;
+
+       /* clear mailbox and prep header tlv */
+       req = ecore_vf_pf_prep(p_hwfn, CHANNEL_TLV_COALESCE_UPDATE,
+                              sizeof(*req));
+
+       req->rx_coal = rx_coal;
+       req->tx_coal = tx_coal;
+       req->qid = p_cid->rel.queue_id;
+
+       DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
+                  "Setting coalesce rx_coal = %d, tx_coal = %d at queue = %d\n",
+                  rx_coal, tx_coal, req->qid);
+
+       /* add list termination tlv */
+       ecore_add_tlv(p_hwfn, &p_iov->offset, CHANNEL_TLV_LIST_END,
+                     sizeof(struct channel_list_end_tlv));
+
+       resp = &p_iov->pf2vf_reply->default_resp;
+       rc = ecore_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
+
+       if (rc != ECORE_SUCCESS)
+               goto exit;
+
+       if (resp->hdr.status != PFVF_STATUS_SUCCESS)
+               goto exit;
+
+       p_hwfn->p_dev->rx_coalesce_usecs = rx_coal;
+       p_hwfn->p_dev->tx_coalesce_usecs = tx_coal;
+
+exit:
+       ecore_vf_pf_req_end(p_hwfn, rc);
+       return rc;
+}
+
 u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn,
                           u16               sb_id)
 {
@@ -1531,6 +1582,12 @@ void ecore_vf_get_num_rxqs(struct ecore_hwfn *p_hwfn, u8 *num_rxqs)
        *num_rxqs = p_hwfn->vf_iov_info->acquire_resp.resc.num_rxqs;
 }
 
+void ecore_vf_get_num_txqs(struct ecore_hwfn *p_hwfn,
+                          u8 *num_txqs)
+{
+       *num_txqs = p_hwfn->vf_iov_info->acquire_resp.resc.num_txqs;
+}
+
 void ecore_vf_get_port_mac(struct ecore_hwfn *p_hwfn, u8 *port_mac)
 {
        OSAL_MEMCPY(port_mac,
@@ -1601,6 +1658,18 @@ bool ecore_vf_bulletin_get_forced_mac(struct ecore_hwfn *hwfn, u8 *dst_mac,
        return true;
 }
 
+void ecore_vf_bulletin_get_udp_ports(struct ecore_hwfn *p_hwfn,
+                                    u16 *p_vxlan_port,
+                                    u16 *p_geneve_port)
+{
+       struct ecore_bulletin_content *p_bulletin;
+
+       p_bulletin = &p_hwfn->vf_iov_info->bulletin_shadow;
+
+       *p_vxlan_port = p_bulletin->vxlan_udp_port;
+       *p_geneve_port = p_bulletin->geneve_udp_port;
+}
+
 bool ecore_vf_bulletin_get_forced_vlan(struct ecore_hwfn *hwfn, u16 *dst_pvid)
 {
        struct ecore_bulletin_content *bulletin;