X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fdpaa%2Fdpaa_flow.c;h=a0087df670f07a511affa69efcb507603a1a28ad;hb=05b405d581486651305551a9f7295f40388d95db;hp=d24cd856c00fa8a3d45f88f968e318301c4aafab;hpb=133332f01d91aef2056cbdc407f3fd3d61b24b83;p=dpdk.git diff --git a/drivers/net/dpaa/dpaa_flow.c b/drivers/net/dpaa/dpaa_flow.c index d24cd856c0..a0087df670 100644 --- a/drivers/net/dpaa/dpaa_flow.c +++ b/drivers/net/dpaa/dpaa_flow.c @@ -12,6 +12,7 @@ #include #include #include +#include #define DPAA_MAX_NUM_ETH_DEV 8 @@ -47,6 +48,17 @@ static struct dpaa_fm_info fm_info; 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; @@ -300,11 +312,18 @@ set_hash_params_sctp(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx) 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; @@ -784,6 +803,14 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t req_dist_set) 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); @@ -909,3 +936,138 @@ int dpaa_fm_term(void) } 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; + 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; +}