* Create private device structure. * * @param dev_name * Pointer to the port name passed in the initialization parameters. * * @return * Pointer to the newly allocated private device structure. */
| 3058 | * Pointer to the newly allocated private device structure. |
| 3059 | */ |
| 3060 | static struct mrvl_priv * |
| 3061 | mrvl_priv_create(const char *dev_name) |
| 3062 | { |
| 3063 | struct pp2_bpool_params bpool_params; |
| 3064 | char match[MRVL_MATCH_LEN]; |
| 3065 | struct mrvl_priv *priv; |
| 3066 | uint16_t max_frame_size; |
| 3067 | int ret, bpool_bit; |
| 3068 | |
| 3069 | priv = rte_zmalloc_socket(dev_name, sizeof(*priv), 0, rte_socket_id()); |
| 3070 | if (!priv) |
| 3071 | return NULL; |
| 3072 | |
| 3073 | ret = pp2_netdev_get_ppio_info((char *)(uintptr_t)dev_name, |
| 3074 | &priv->pp_id, &priv->ppio_id); |
| 3075 | if (ret) |
| 3076 | goto out_free_priv; |
| 3077 | |
| 3078 | ret = pp2_ppio_get_l4_cksum_max_frame_size(priv->pp_id, priv->ppio_id, |
| 3079 | &max_frame_size); |
| 3080 | if (ret) |
| 3081 | goto out_free_priv; |
| 3082 | |
| 3083 | priv->max_mtu = max_frame_size + RTE_ETHER_CRC_LEN - |
| 3084 | MRVL_PP2_ETH_HDRS_LEN; |
| 3085 | |
| 3086 | bpool_bit = mrvl_reserve_bit(&used_bpools[priv->pp_id], |
| 3087 | PP2_BPOOL_NUM_POOLS); |
| 3088 | if (bpool_bit < 0) |
| 3089 | goto out_free_priv; |
| 3090 | priv->bpool_bit = bpool_bit; |
| 3091 | |
| 3092 | snprintf(match, sizeof(match), "pool-%d:%d", priv->pp_id, |
| 3093 | priv->bpool_bit); |
| 3094 | memset(&bpool_params, 0, sizeof(bpool_params)); |
| 3095 | bpool_params.match = match; |
| 3096 | bpool_params.buff_len = MRVL_PKT_SIZE_MAX + MRVL_PKT_EFFEC_OFFS; |
| 3097 | ret = pp2_bpool_init(&bpool_params, &priv->bpool); |
| 3098 | if (ret) |
| 3099 | goto out_clear_bpool_bit; |
| 3100 | |
| 3101 | priv->ppio_params.type = PP2_PPIO_T_NIC; |
| 3102 | rte_spinlock_init(&priv->lock); |
| 3103 | |
| 3104 | return priv; |
| 3105 | out_clear_bpool_bit: |
| 3106 | used_bpools[priv->pp_id] &= ~(1 << priv->bpool_bit); |
| 3107 | out_free_priv: |
| 3108 | rte_free(priv); |
| 3109 | return NULL; |
| 3110 | } |
| 3111 | |
| 3112 | /** |
| 3113 | * Create device representing Ethernet port. |
no test coverage detected