1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2010-2016 Freescale Semiconductor Inc.
10 #include <sys/ioctl.h>
12 #include <net/if_arp.h>
16 #include <rte_malloc.h>
18 #include <rte_dpaa_logs.h>
21 /* Structure contains information about all the interfaces given by user
24 struct netcfg_interface *netcfg_interface;
26 /* This data structure contaings all configurations information
27 * related to usages of DPA devices.
29 struct netcfg_info *netcfg;
30 /* fd to open a socket for making ioctl request to disable/enable shared
35 #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
37 dump_netcfg(struct netcfg_info *cfg_ptr)
41 printf(".......... DPAA Configuration ..........\n\n");
43 /* Network interfaces */
44 printf("Network interfaces: %d\n", cfg_ptr->num_ethports);
45 for (i = 0; i < cfg_ptr->num_ethports; i++) {
46 struct fman_if_bpool *bpool;
47 struct fm_eth_port_cfg *p_cfg = &cfg_ptr->port_cfg[i];
48 struct fman_if *__if = p_cfg->fman_if;
50 printf("\n+ Fman %d, MAC %d (%s);\n",
51 __if->fman_idx, __if->mac_idx,
52 (__if->mac_type == fman_mac_1g) ? "1G" : "10G");
54 printf("\tmac_addr: %02x:%02x:%02x:%02x:%02x:%02x\n",
55 (&__if->mac_addr)->addr_bytes[0],
56 (&__if->mac_addr)->addr_bytes[1],
57 (&__if->mac_addr)->addr_bytes[2],
58 (&__if->mac_addr)->addr_bytes[3],
59 (&__if->mac_addr)->addr_bytes[4],
60 (&__if->mac_addr)->addr_bytes[5]);
62 printf("\ttx_channel_id: 0x%02x\n",
65 printf("\tfqid_rx_def: 0x%x\n", p_cfg->rx_def);
66 printf("\tfqid_rx_err: 0x%x\n", __if->fqid_rx_err);
68 printf("\tfqid_tx_err: 0x%x\n", __if->fqid_tx_err);
69 printf("\tfqid_tx_confirm: 0x%x\n", __if->fqid_tx_confirm);
70 fman_if_for_each_bpool(bpool, __if)
71 printf("\tbuffer pool: (bpid=%d, count=%"PRId64
72 " size=%"PRId64", addr=0x%"PRIx64")\n",
73 bpool->bpid, bpool->count, bpool->size,
77 #endif /* RTE_LIBRTE_DPAA_DEBUG_DRIVER */
80 get_num_netcfg_interfaces(char *str)
87 pch = strtok(str, ",");
90 pch = strtok(NULL, ",");
100 uint8_t num_ports = 0;
101 uint8_t num_cfg_ports = 0;
104 /* Extract dpa configuration from fman driver and FMC configuration
105 * for command-line interfaces.
108 /* Open a basic socket to enable/disable shared
111 skfd = socket(AF_PACKET, SOCK_RAW, 0);
112 if (unlikely(skfd < 0)) {
113 error(0, errno, "%s(): open(SOCK_RAW)", __func__);
117 /* Initialise the Fman driver */
118 _errno = fman_init();
120 DPAA_BUS_LOG(ERR, "FMAN driver init failed (%d)", errno);
126 /* Number of MAC ports */
127 list_for_each_entry(__if, fman_if_list, node)
131 DPAA_BUS_LOG(ERR, "FMAN ports not available");
134 /* Allocate space for all enabled mac ports */
135 size = sizeof(*netcfg) +
136 (num_ports * sizeof(struct fm_eth_port_cfg));
138 netcfg = calloc(1, size);
139 if (unlikely(netcfg == NULL)) {
140 DPAA_BUS_LOG(ERR, "Unable to allocat mem for netcfg");
144 netcfg->num_ethports = num_ports;
146 list_for_each_entry(__if, fman_if_list, node) {
147 struct fm_eth_port_cfg *cfg = &netcfg->port_cfg[idx];
148 /* Hook in the fman driver interface */
150 cfg->rx_def = __if->fqid_rx_def;
155 if (!num_cfg_ports) {
156 DPAA_BUS_LOG(ERR, "No FMAN ports found");
158 } else if (num_ports != num_cfg_ports)
159 netcfg->num_ethports = num_cfg_ports;
173 netcfg_release(struct netcfg_info *cfg_ptr)
176 /* Close socket for shared interfaces */