static int
qed_update_vport(struct ecore_dev *edev, struct qed_update_vport_params *params)
{
	struct ecore_sp_vport_update_params sp_params;
	struct ecore_rss_params sp_rss_params;
	int rc, i;

	memset(&sp_params, 0, sizeof(sp_params));
	memset(&sp_rss_params, 0, sizeof(sp_rss_params));

	/* Translate protocol params into sp params */
	sp_params.vport_id = params->vport_id;
	sp_params.update_vport_active_rx_flg = params->update_vport_active_flg;
	sp_params.update_vport_active_tx_flg = params->update_vport_active_flg;
	sp_params.vport_active_rx_flg = params->vport_active_flg;
	sp_params.vport_active_tx_flg = params->vport_active_flg;
	sp_params.update_inner_vlan_removal_flg =
	    params->update_inner_vlan_removal_flg;
	sp_params.inner_vlan_removal_flg = params->inner_vlan_removal_flg;
	sp_params.update_tx_switching_flg = params->update_tx_switching_flg;
	sp_params.tx_switching_flg = params->tx_switching_flg;
	sp_params.accept_any_vlan = params->accept_any_vlan;
	sp_params.update_accept_any_vlan_flg =
	    params->update_accept_any_vlan_flg;
	sp_params.mtu = params->mtu;

	for_each_hwfn(edev, i) {
		struct ecore_hwfn *p_hwfn = &edev->hwfns[i];

		sp_params.opaque_fid = p_hwfn->hw_info.opaque_fid;
		rc = ecore_sp_vport_update(p_hwfn, &sp_params,
					   ECORE_SPQ_MODE_EBLOCK, NULL);
		if (rc) {
			DP_ERR(edev, "Failed to update VPORT\n");
			return rc;
		}

		DP_VERBOSE(edev, ECORE_MSG_SPQ,
			   "Updated V-PORT %d: active_flag %d [update %d]\n",
			   params->vport_id, params->vport_active_flg,
			   params->update_vport_active_flg);
	}

	return 0;
}
Exemple #2
0
static int
qed_update_vport(struct ecore_dev *edev, struct qed_update_vport_params *params)
{
    struct ecore_sp_vport_update_params sp_params;
    struct ecore_rss_params sp_rss_params;
    int rc, i;

    memset(&sp_params, 0, sizeof(sp_params));
    memset(&sp_rss_params, 0, sizeof(sp_rss_params));

    /* Translate protocol params into sp params */
    sp_params.vport_id = params->vport_id;
    sp_params.update_vport_active_rx_flg = params->update_vport_active_flg;
    sp_params.update_vport_active_tx_flg = params->update_vport_active_flg;
    sp_params.vport_active_rx_flg = params->vport_active_flg;
    sp_params.vport_active_tx_flg = params->vport_active_flg;
    sp_params.update_inner_vlan_removal_flg =
        params->update_inner_vlan_removal_flg;
    sp_params.inner_vlan_removal_flg = params->inner_vlan_removal_flg;
    sp_params.update_tx_switching_flg = params->update_tx_switching_flg;
    sp_params.tx_switching_flg = params->tx_switching_flg;
    sp_params.accept_any_vlan = params->accept_any_vlan;
    sp_params.update_accept_any_vlan_flg =
        params->update_accept_any_vlan_flg;

    /* RSS - is a bit tricky, since upper-layer isn't familiar with hwfns.
     * We need to re-fix the rss values per engine for CMT.
     */

    if (edev->num_hwfns > 1 && params->update_rss_flg) {
        struct qed_update_vport_rss_params *rss = &params->rss_params;
        int k, max = 0;

        /* Find largest entry, since it's possible RSS needs to
         * be disabled [in case only 1 queue per-hwfn]
         */
        for (k = 0; k < ECORE_RSS_IND_TABLE_SIZE; k++)
            max = (max > rss->rss_ind_table[k]) ?
                  max : rss->rss_ind_table[k];

        /* Either fix RSS values or disable RSS */
        if (edev->num_hwfns < max + 1) {
            int divisor = (max + edev->num_hwfns - 1) /
                          edev->num_hwfns;

            DP_VERBOSE(edev, ECORE_MSG_SPQ,
                       "CMT - fixing RSS values (modulo %02x)\n",
                       divisor);

            for (k = 0; k < ECORE_RSS_IND_TABLE_SIZE; k++)
                rss->rss_ind_table[k] =
                    rss->rss_ind_table[k] % divisor;
        } else {
            DP_VERBOSE(edev, ECORE_MSG_SPQ,
                       "CMT - 1 queue per-hwfn; Disabling RSS\n");
            params->update_rss_flg = 0;
        }
    }

    /* Now, update the RSS configuration for actual configuration */
    if (params->update_rss_flg) {
        sp_rss_params.update_rss_config = 1;
        sp_rss_params.rss_enable = 1;
        sp_rss_params.update_rss_capabilities = 1;
        sp_rss_params.update_rss_ind_table = 1;
        sp_rss_params.update_rss_key = 1;
        sp_rss_params.rss_caps = ECORE_RSS_IPV4 | ECORE_RSS_IPV6 |
                                 ECORE_RSS_IPV4_TCP | ECORE_RSS_IPV6_TCP;
        sp_rss_params.rss_table_size_log = 7;	/* 2^7 = 128 */
        rte_memcpy(sp_rss_params.rss_ind_table,
                   params->rss_params.rss_ind_table,
                   ECORE_RSS_IND_TABLE_SIZE * sizeof(uint16_t));
        rte_memcpy(sp_rss_params.rss_key, params->rss_params.rss_key,
                   ECORE_RSS_KEY_SIZE * sizeof(uint32_t));
    }
    sp_params.rss_params = &sp_rss_params;

    for_each_hwfn(edev, i) {
        struct ecore_hwfn *p_hwfn = &edev->hwfns[i];

        sp_params.opaque_fid = p_hwfn->hw_info.opaque_fid;
        rc = ecore_sp_vport_update(p_hwfn, &sp_params,
                                   ECORE_SPQ_MODE_EBLOCK, NULL);
        if (rc) {
            DP_ERR(edev, "Failed to update VPORT\n");
            return rc;
        }

        DP_VERBOSE(edev, ECORE_MSG_SPQ,
                   "Updated V-PORT %d: active_flag %d [update %d]\n",
                   params->vport_id, params->vport_active_flg,
                   params->update_vport_active_flg);
    }

    return 0;
}