1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2010-2016 Freescale Semiconductor Inc.
4 * Copyright 2017-2019 NXP
10 #include <sys/ioctl.h>
12 #include <net/if_arp.h>
16 #include <rte_malloc.h>
18 #include <rte_dpaa_logs.h>
21 /* This data structure contaings all configurations information
22 * related to usages of DPA devices.
24 static struct netcfg_info *netcfg;
25 /* fd to open a socket for making ioctl request to disable/enable shared
30 #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
32 dump_netcfg(struct netcfg_info *cfg_ptr)
36 printf(".......... DPAA Configuration ..........\n\n");
38 /* Network interfaces */
39 printf("Network interfaces: %d\n", cfg_ptr->num_ethports);
40 for (i = 0; i < cfg_ptr->num_ethports; i++) {
41 struct fman_if_bpool *bpool;
42 struct fm_eth_port_cfg *p_cfg = &cfg_ptr->port_cfg[i];
43 struct fman_if *__if = p_cfg->fman_if;
45 printf("\n+ Fman %d, MAC %d (%s);\n",
46 __if->fman_idx, __if->mac_idx,
47 (__if->mac_type == fman_mac_1g) ? "1G" :
48 (__if->mac_type == fman_mac_2_5g) ? "2.5G" : "10G");
50 printf("\tmac_addr: %02x:%02x:%02x:%02x:%02x:%02x\n",
51 (&__if->mac_addr)->addr_bytes[0],
52 (&__if->mac_addr)->addr_bytes[1],
53 (&__if->mac_addr)->addr_bytes[2],
54 (&__if->mac_addr)->addr_bytes[3],
55 (&__if->mac_addr)->addr_bytes[4],
56 (&__if->mac_addr)->addr_bytes[5]);
58 printf("\ttx_channel_id: 0x%02x\n",
61 printf("\tfqid_rx_def: 0x%x\n", p_cfg->rx_def);
62 printf("\tfqid_rx_err: 0x%x\n", __if->fqid_rx_err);
64 printf("\tfqid_tx_err: 0x%x\n", __if->fqid_tx_err);
65 printf("\tfqid_tx_confirm: 0x%x\n", __if->fqid_tx_confirm);
66 fman_if_for_each_bpool(bpool, __if)
67 printf("\tbuffer pool: (bpid=%d, count=%"PRId64
68 " size=%"PRId64", addr=0x%"PRIx64")\n",
69 bpool->bpid, bpool->count, bpool->size,
73 #endif /* RTE_LIBRTE_DPAA_DEBUG_DRIVER */
80 uint8_t num_ports = 0;
81 uint8_t num_cfg_ports = 0;
84 /* Extract dpa configuration from fman driver and FMC configuration
85 * for command-line interfaces.
88 /* Open a basic socket to enable/disable shared
91 skfd = socket(AF_PACKET, SOCK_RAW, 0);
92 if (unlikely(skfd < 0)) {
93 error(0, errno, "%s(): open(SOCK_RAW)", __func__);
97 /* Initialise the Fman driver */
100 DPAA_BUS_LOG(ERR, "FMAN driver init failed (%d)", errno);
106 /* Number of MAC ports */
107 list_for_each_entry(__if, fman_if_list, node)
111 DPAA_BUS_LOG(ERR, "FMAN ports not available");
114 /* Allocate space for all enabled mac ports */
115 size = sizeof(*netcfg) +
116 (num_ports * sizeof(struct fm_eth_port_cfg));
118 netcfg = rte_calloc(NULL, 1, size, 0);
119 if (unlikely(netcfg == NULL)) {
120 DPAA_BUS_LOG(ERR, "Unable to allocat mem for netcfg");
124 netcfg->num_ethports = num_ports;
126 list_for_each_entry(__if, fman_if_list, node) {
127 struct fm_eth_port_cfg *cfg = &netcfg->port_cfg[idx];
128 /* Hook in the fman driver interface */
130 cfg->rx_def = __if->fqid_rx_def;
135 if (!num_cfg_ports) {
136 DPAA_BUS_LOG(ERR, "No FMAN ports found");
138 } else if (num_ports != num_cfg_ports)
139 netcfg->num_ethports = num_cfg_ports;
153 netcfg_release(struct netcfg_info *cfg_ptr)
156 /* Close socket for shared interfaces */