+static int
+rte_dpaa_bus_parse(const char *name, void *out_name)
+{
+ int i, j;
+ int max_fman = 2, max_macs = 16;
+ char *dup_name;
+ char *sep = NULL;
+
+ /* There are two ways of passing device name, with and without
+ * separator. "dpaa_bus:fm1-mac3" with separator, and "fm1-mac3"
+ * without separator. Both need to be handled.
+ * It is also possible that "name=fm1-mac3" is passed along.
+ */
+ DPAA_BUS_DEBUG("Parse device name (%s)", name);
+
+ /* Check for dpaa_bus:fm1-mac3 style */
+ dup_name = strdup(name);
+ sep = strchr(dup_name, ':');
+ if (!sep)
+ /* If not, check for name=fm1-mac3 style */
+ sep = strchr(dup_name, '=');
+
+ if (sep)
+ /* jump over the seprator */
+ sep = (char *) (sep + 1);
+ else
+ sep = dup_name;
+
+ for (i = 0; i < max_fman; i++) {
+ for (j = 0; j < max_macs; j++) {
+ char fm_name[16];
+ snprintf(fm_name, 16, "fm%d-mac%d", i, j);
+ if (strcmp(fm_name, sep) == 0) {
+ if (out_name)
+ strcpy(out_name, sep);
+ free(dup_name);
+ return 0;
+ }
+ }
+ }
+
+ for (i = 0; i < RTE_LIBRTE_DPAA_MAX_CRYPTODEV; i++) {
+ char sec_name[16];
+
+ snprintf(sec_name, 16, "dpaa_sec-%d", i+1);
+ if (strcmp(sec_name, sep) == 0) {
+ if (out_name)
+ strcpy(out_name, sep);
+ free(dup_name);
+ return 0;
+ }
+ }
+
+ free(dup_name);
+ return -EINVAL;