| 127 | } |
| 128 | |
| 129 | static int |
| 130 | scan_one_fslmc_device(char *dev_name) |
| 131 | { |
| 132 | char *dup_dev_name, *t_ptr; |
| 133 | struct rte_dpaa2_device *dev = NULL; |
| 134 | int ret = -1; |
| 135 | |
| 136 | if (!dev_name) |
| 137 | return ret; |
| 138 | |
| 139 | /* Creating a temporary copy to perform cut-parse over string */ |
| 140 | dup_dev_name = strdup(dev_name); |
| 141 | if (!dup_dev_name) { |
| 142 | DPAA2_BUS_ERR("Unable to allocate device name memory"); |
| 143 | return -ENOMEM; |
| 144 | } |
| 145 | |
| 146 | /* For all other devices, we allocate rte_dpaa2_device. |
| 147 | * For those devices where there is no driver, probe would release |
| 148 | * the memory associated with the rte_dpaa2_device after necessary |
| 149 | * initialization. |
| 150 | */ |
| 151 | dev = calloc(1, sizeof(struct rte_dpaa2_device)); |
| 152 | if (!dev) { |
| 153 | DPAA2_BUS_ERR("Unable to allocate device object"); |
| 154 | free(dup_dev_name); |
| 155 | return -ENOMEM; |
| 156 | } |
| 157 | |
| 158 | dev->device.bus = &rte_fslmc_bus.bus; |
| 159 | dev->device.numa_node = SOCKET_ID_ANY; |
| 160 | |
| 161 | /* Allocate interrupt instance */ |
| 162 | dev->intr_handle = |
| 163 | rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE); |
| 164 | if (dev->intr_handle == NULL) { |
| 165 | DPAA2_BUS_ERR("Failed to allocate intr handle"); |
| 166 | ret = -ENOMEM; |
| 167 | goto cleanup; |
| 168 | } |
| 169 | |
| 170 | /* Parse the device name and ID */ |
| 171 | t_ptr = strtok(dup_dev_name, "."); |
| 172 | if (!t_ptr) { |
| 173 | DPAA2_BUS_ERR("Invalid device found: (%s)", dup_dev_name); |
| 174 | ret = -EINVAL; |
| 175 | goto cleanup; |
| 176 | } |
| 177 | if (!strncmp("dpni", t_ptr, 4)) |
| 178 | dev->dev_type = DPAA2_ETH; |
| 179 | else if (!strncmp("dpseci", t_ptr, 6)) |
| 180 | dev->dev_type = DPAA2_CRYPTO; |
| 181 | else if (!strncmp("dpcon", t_ptr, 5)) |
| 182 | dev->dev_type = DPAA2_CON; |
| 183 | else if (!strncmp("dpbp", t_ptr, 4)) |
| 184 | dev->dev_type = DPAA2_BPOOL; |
| 185 | else if (!strncmp("dpio", t_ptr, 4)) |
| 186 | dev->dev_type = DPAA2_IO; |
no test coverage detected