MCPcopy Create free account
hub / github.com/F-Stack/f-stack / setup_ports

Function setup_ports

dpdk/examples/ethtool/ethtool-app/main.c:89–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89static void setup_ports(struct app_config *app_cfg, int cnt_ports)
90{
91 int idx_port;
92 int size_pktpool;
93 struct rte_eth_conf cfg_port;
94 struct rte_eth_dev_info dev_info;
95 char str_name[16];
96 uint16_t nb_rxd = PORT_RX_QUEUE_SIZE;
97 uint16_t nb_txd = PORT_TX_QUEUE_SIZE;
98 int ret;
99
100 memset(&cfg_port, 0, sizeof(cfg_port));
101 cfg_port.txmode.mq_mode = RTE_ETH_MQ_TX_NONE;
102
103 for (idx_port = 0; idx_port < cnt_ports; idx_port++) {
104 struct app_port *ptr_port = &app_cfg->ports[idx_port];
105
106 ret = rte_eth_dev_info_get(idx_port, &dev_info);
107 if (ret != 0)
108 rte_exit(EXIT_FAILURE,
109 "Error during getting device (port %u) info: %s\n",
110 idx_port, strerror(-ret));
111
112 size_pktpool = dev_info.rx_desc_lim.nb_max +
113 dev_info.tx_desc_lim.nb_max + PKTPOOL_EXTRA_SIZE;
114
115 snprintf(str_name, 16, "pkt_pool%i", idx_port);
116 ptr_port->pkt_pool = rte_pktmbuf_pool_create(
117 str_name,
118 size_pktpool, PKTPOOL_CACHE,
119 0,
120 RTE_MBUF_DEFAULT_BUF_SIZE,
121 rte_socket_id()
122 );
123 if (ptr_port->pkt_pool == NULL)
124 rte_exit(EXIT_FAILURE,
125 "rte_pktmbuf_pool_create failed"
126 );
127
128 printf("Init port %i..\n", idx_port);
129 ptr_port->port_active = 1;
130 ptr_port->port_dirty = 0;
131 ptr_port->idx_port = idx_port;
132
133 if (rte_eth_dev_configure(idx_port, 1, 1, &cfg_port) < 0)
134 rte_exit(EXIT_FAILURE,
135 "rte_eth_dev_configure failed");
136 if (rte_eth_dev_adjust_nb_rx_tx_desc(idx_port, &nb_rxd,
137 &nb_txd) < 0)
138 rte_exit(EXIT_FAILURE,
139 "rte_eth_dev_adjust_nb_rx_tx_desc failed");
140
141 if (rte_eth_rx_queue_setup(
142 idx_port, 0, nb_rxd,
143 rte_eth_dev_socket_id(idx_port), NULL,
144 ptr_port->pkt_pool) < 0)
145 rte_exit(EXIT_FAILURE,
146 "rte_eth_rx_queue_setup failed"

Callers 1

mainFunction · 0.85

Calls 15

memsetFunction · 0.85
rte_eth_dev_info_getFunction · 0.85
rte_exitFunction · 0.85
snprintfFunction · 0.85
rte_pktmbuf_pool_createFunction · 0.85
rte_socket_idFunction · 0.85
rte_eth_dev_configureFunction · 0.85
rte_eth_rx_queue_setupFunction · 0.85
rte_eth_dev_socket_idFunction · 0.85
rte_eth_tx_queue_setupFunction · 0.85
rte_eth_dev_startFunction · 0.85

Tested by

no test coverage detected