/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2017-2019 NXP
+ * Copyright 2017-2019,2021 NXP
*/
/* System headers */
#include <dpaa_flow.h>
#include <rte_dpaa_logs.h>
#include <fmlib/fm_port_ext.h>
+#include <fmlib/fm_vsp_ext.h>
#define DPAA_MAX_NUM_ETH_DEV 8
static struct dpaa_fm_model fm_model;
static const char *fm_log = "/tmp/fmdpdk.bin";
+static inline uint8_t fm_default_vsp_id(struct fman_if *fif)
+{
+ /* Avoid being same as base profile which could be used
+ * for kernel interface of shared mac.
+ */
+ if (fif->base_profile_id)
+ return 0;
+ else
+ return DPAA_DEFAULT_RXQ_VSP_ID;
+}
+
static void fm_prev_cleanup(void)
{
uint32_t fman_id = 0, i = 0, devid;
static int set_scheme_params(ioc_fm_pcd_kg_scheme_params_t *scheme_params,
ioc_fm_pcd_net_env_params_t *dist_units,
struct dpaa_if *dpaa_intf,
- struct fman_if *fif __rte_unused)
+ struct fman_if *fif)
{
int dist_idx, hdr_idx = 0;
PMD_INIT_FUNC_TRACE();
+ if (fif->num_profiles) {
+ scheme_params->param.override_storage_profile = true;
+ scheme_params->param.storage_profile.direct = true;
+ scheme_params->param.storage_profile.profile_select
+ .direct_relative_profile_id = fm_default_vsp_id(fif);
+ }
+
scheme_params->param.use_hash = 1;
scheme_params->param.modify = false;
scheme_params->param.always_direct = false;
if (req_dist_set % 2 != 0) {
dist_field = 1U << loop;
switch (dist_field) {
- case ETH_RSS_L2_PAYLOAD:
+ case RTE_ETH_RSS_L2_PAYLOAD:
if (l2_configured)
break;
= HEADER_TYPE_ETH;
break;
- case ETH_RSS_IPV4:
- case ETH_RSS_FRAG_IPV4:
- case ETH_RSS_NONFRAG_IPV4_OTHER:
+ case RTE_ETH_RSS_IPV4:
+ case RTE_ETH_RSS_FRAG_IPV4:
+ case RTE_ETH_RSS_NONFRAG_IPV4_OTHER:
if (ipv4_configured)
break;
= HEADER_TYPE_IPV4;
break;
- case ETH_RSS_IPV6:
- case ETH_RSS_FRAG_IPV6:
- case ETH_RSS_NONFRAG_IPV6_OTHER:
- case ETH_RSS_IPV6_EX:
+ case RTE_ETH_RSS_IPV6:
+ case RTE_ETH_RSS_FRAG_IPV6:
+ case RTE_ETH_RSS_NONFRAG_IPV6_OTHER:
+ case RTE_ETH_RSS_IPV6_EX:
if (ipv6_configured)
break;
= HEADER_TYPE_IPV6;
break;
- case ETH_RSS_NONFRAG_IPV4_TCP:
- case ETH_RSS_NONFRAG_IPV6_TCP:
- case ETH_RSS_IPV6_TCP_EX:
+ case RTE_ETH_RSS_NONFRAG_IPV4_TCP:
+ case RTE_ETH_RSS_NONFRAG_IPV6_TCP:
+ case RTE_ETH_RSS_IPV6_TCP_EX:
if (tcp_configured)
break;
= HEADER_TYPE_TCP;
break;
- case ETH_RSS_NONFRAG_IPV4_UDP:
- case ETH_RSS_NONFRAG_IPV6_UDP:
- case ETH_RSS_IPV6_UDP_EX:
+ case RTE_ETH_RSS_NONFRAG_IPV4_UDP:
+ case RTE_ETH_RSS_NONFRAG_IPV6_UDP:
+ case RTE_ETH_RSS_IPV6_UDP_EX:
if (udp_configured)
break;
= HEADER_TYPE_UDP;
break;
- case ETH_RSS_NONFRAG_IPV4_SCTP:
- case ETH_RSS_NONFRAG_IPV6_SCTP:
+ case RTE_ETH_RSS_NONFRAG_IPV4_SCTP:
+ case RTE_ETH_RSS_NONFRAG_IPV6_SCTP:
if (sctp_configured)
break;
}
dpaa_intf->netenv_handle = NULL;
+ if (fif && fif->is_shared_mac) {
+ ret = fm_port_enable(dpaa_intf->port_handle);
+ if (ret != E_OK) {
+ DPAA_PMD_ERR("shared mac re-enable failed");
+ return ret;
+ }
+ }
+
/* FM PORT Close */
fm_port_close(dpaa_intf->port_handle);
dpaa_intf->port_handle = NULL;
return -1;
}
+ if (fif->num_profiles) {
+ for (i = 0; i < dpaa_intf->nb_rx_queues; i++)
+ dpaa_intf->rx_queues[i].vsp_id =
+ fm_default_vsp_id(fif);
+
+ i = 0;
+ }
+
/* Set PCD netenv and scheme */
if (req_dist_set) {
ret = set_pcd_netenv_scheme(dpaa_intf, req_dist_set, fif);
}
}
/* Set default netenv and scheme */
- ret = set_default_scheme(dpaa_intf);
- if (ret) {
- DPAA_PMD_ERR("Set PCD NetEnv and Scheme: Failed");
- goto unset_pcd_netenv_scheme1;
+ if (!fif->is_shared_mac) {
+ ret = set_default_scheme(dpaa_intf);
+ if (ret) {
+ DPAA_PMD_ERR("Set PCD NetEnv and Scheme: Failed");
+ goto unset_pcd_netenv_scheme1;
+ }
}
/* Set Port PCD */
}
return 0;
}
+
+static int dpaa_port_vsp_configure(struct dpaa_if *dpaa_intf,
+ uint8_t vsp_id, t_handle fman_handle,
+ struct fman_if *fif)
+{
+ t_fm_vsp_params vsp_params;
+ t_fm_buffer_prefix_content buf_prefix_cont;
+ uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
+ uint8_t idx = mac_idx[fif->mac_idx];
+ int ret;
+
+ if (vsp_id == fif->base_profile_id && fif->is_shared_mac) {
+ /* For shared interface, VSP of base
+ * profile is default pool located in kernel.
+ */
+ dpaa_intf->vsp_bpid[vsp_id] = 0;
+ return 0;
+ }
+
+ if (vsp_id >= DPAA_VSP_PROFILE_MAX_NUM) {
+ DPAA_PMD_ERR("VSP ID %d exceeds MAX number %d",
+ vsp_id, DPAA_VSP_PROFILE_MAX_NUM);
+ return -1;
+ }
+
+ memset(&vsp_params, 0, sizeof(vsp_params));
+ vsp_params.h_fm = fman_handle;
+ vsp_params.relative_profile_id = vsp_id;
+ vsp_params.port_params.port_id = idx;
+ if (fif->mac_type == fman_mac_1g) {
+ vsp_params.port_params.port_type = e_FM_PORT_TYPE_RX;
+ } else if (fif->mac_type == fman_mac_2_5g) {
+ vsp_params.port_params.port_type = e_FM_PORT_TYPE_RX_2_5G;
+ } else if (fif->mac_type == fman_mac_10g) {
+ vsp_params.port_params.port_type = e_FM_PORT_TYPE_RX_10G;
+ } else {
+ DPAA_PMD_ERR("Mac type %d error", fif->mac_type);
+ return -1;
+ }
+ vsp_params.ext_buf_pools.num_of_pools_used = 1;
+ vsp_params.ext_buf_pools.ext_buf_pool[0].id =
+ dpaa_intf->vsp_bpid[vsp_id];
+ vsp_params.ext_buf_pools.ext_buf_pool[0].size =
+ RTE_MBUF_DEFAULT_BUF_SIZE;
+
+ dpaa_intf->vsp_handle[vsp_id] = fm_vsp_config(&vsp_params);
+ if (!dpaa_intf->vsp_handle[vsp_id]) {
+ DPAA_PMD_ERR("fm_vsp_config error for profile %d", vsp_id);
+ return -EINVAL;
+ }
+
+ /* configure the application buffer (structure, size and
+ * content)
+ */
+
+ memset(&buf_prefix_cont, 0, sizeof(buf_prefix_cont));
+
+ buf_prefix_cont.priv_data_size = 16;
+ buf_prefix_cont.data_align = 64;
+ buf_prefix_cont.pass_prs_result = true;
+ buf_prefix_cont.pass_time_stamp = true;
+ buf_prefix_cont.pass_hash_result = false;
+ buf_prefix_cont.pass_all_other_pcdinfo = false;
+ buf_prefix_cont.manip_ext_space =
+ RTE_PKTMBUF_HEADROOM - DPAA_MBUF_HW_ANNOTATION;
+
+ ret = fm_vsp_config_buffer_prefix_content(dpaa_intf->vsp_handle[vsp_id],
+ &buf_prefix_cont);
+ if (ret != E_OK) {
+ DPAA_PMD_ERR("fm_vsp_config_buffer_prefix_content error for profile %d err: %d",
+ vsp_id, ret);
+ return ret;
+ }
+
+ /* initialize the FM VSP module */
+ ret = fm_vsp_init(dpaa_intf->vsp_handle[vsp_id]);
+ if (ret != E_OK) {
+ DPAA_PMD_ERR("fm_vsp_init error for profile %d err:%d",
+ vsp_id, ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int dpaa_port_vsp_update(struct dpaa_if *dpaa_intf,
+ bool fmc_mode, uint8_t vsp_id, uint32_t bpid,
+ struct fman_if *fif)
+{
+ int ret = 0;
+ t_handle fman_handle;
+
+ if (!fif->num_profiles)
+ return 0;
+
+ if (vsp_id >= fif->num_profiles)
+ return 0;
+
+ if (dpaa_intf->vsp_bpid[vsp_id] == bpid)
+ return 0;
+
+ if (dpaa_intf->vsp_handle[vsp_id]) {
+ ret = fm_vsp_free(dpaa_intf->vsp_handle[vsp_id]);
+ if (ret != E_OK) {
+ DPAA_PMD_ERR("Error fm_vsp_free: err %d vsp_handle[%d]",
+ ret, vsp_id);
+ return ret;
+ }
+ dpaa_intf->vsp_handle[vsp_id] = 0;
+ }
+
+ if (fmc_mode)
+ fman_handle = fm_open(0);
+ else
+ fman_handle = fm_info.fman_handle;
+
+ dpaa_intf->vsp_bpid[vsp_id] = bpid;
+
+ return dpaa_port_vsp_configure(dpaa_intf, vsp_id, fman_handle, fif);
+}
+
+int dpaa_port_vsp_cleanup(struct dpaa_if *dpaa_intf, struct fman_if *fif)
+{
+ int idx, ret;
+
+ for (idx = 0; idx < (uint8_t)fif->num_profiles; idx++) {
+ if (dpaa_intf->vsp_handle[idx]) {
+ ret = fm_vsp_free(dpaa_intf->vsp_handle[idx]);
+ if (ret != E_OK) {
+ DPAA_PMD_ERR("Error fm_vsp_free: err %d"
+ " vsp_handle[%d]", ret, idx);
+ return ret;
+ }
+ }
+ }
+
+ return E_OK;
+}