| 68 | #endif /* RTE_LIBRTE_DPAA_DEBUG_DRIVER */ |
| 69 | |
| 70 | struct netcfg_info * |
| 71 | netcfg_acquire(void) |
| 72 | { |
| 73 | struct fman_if *__if; |
| 74 | int _errno, idx = 0; |
| 75 | uint8_t num_ports = 0; |
| 76 | uint8_t num_cfg_ports = 0; |
| 77 | size_t size; |
| 78 | |
| 79 | /* Extract dpa configuration from fman driver and FMC configuration |
| 80 | * for command-line interfaces. |
| 81 | */ |
| 82 | |
| 83 | /* Open a basic socket to enable/disable shared |
| 84 | * interfaces. |
| 85 | */ |
| 86 | skfd = socket(AF_PACKET, SOCK_RAW, 0); |
| 87 | if (unlikely(skfd < 0)) { |
| 88 | err(0, "%s(): open(SOCK_RAW)", __func__); |
| 89 | return NULL; |
| 90 | } |
| 91 | |
| 92 | /* Initialise the Fman driver */ |
| 93 | _errno = fman_init(); |
| 94 | if (_errno) { |
| 95 | DPAA_BUS_LOG(ERR, "FMAN driver init failed (%d)", errno); |
| 96 | close(skfd); |
| 97 | skfd = -1; |
| 98 | return NULL; |
| 99 | } |
| 100 | |
| 101 | /* Number of MAC ports */ |
| 102 | list_for_each_entry(__if, fman_if_list, node) |
| 103 | num_ports++; |
| 104 | |
| 105 | if (!num_ports) { |
| 106 | DPAA_BUS_LOG(ERR, "FMAN ports not available"); |
| 107 | return NULL; |
| 108 | } |
| 109 | /* Allocate space for all enabled mac ports */ |
| 110 | size = sizeof(*netcfg) + |
| 111 | (num_ports * sizeof(struct fm_eth_port_cfg)); |
| 112 | |
| 113 | netcfg = rte_calloc(NULL, 1, size, 0); |
| 114 | if (unlikely(netcfg == NULL)) { |
| 115 | DPAA_BUS_LOG(ERR, "Unable to allocat mem for netcfg"); |
| 116 | goto error; |
| 117 | } |
| 118 | |
| 119 | netcfg->num_ethports = num_ports; |
| 120 | |
| 121 | list_for_each_entry(__if, fman_if_list, node) { |
| 122 | struct fm_eth_port_cfg *cfg = &netcfg->port_cfg[idx]; |
| 123 | /* Hook in the fman driver interface */ |
| 124 | cfg->fman_if = __if; |
| 125 | cfg->rx_def = __if->fqid_rx_def; |
| 126 | num_cfg_ports++; |
| 127 | idx++; |
no test coverage detected