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

Function init_port

dpdk/examples/server_node_efd/efd_server/init.c:93–164  ·  view source on GitHub ↗

* Initialise an individual port: * - configure number of rx and tx rings * - set up each rx ring, to pull from the main mbuf pool * - set up each tx ring * - start the port and report its status to stdout */

Source from the content-addressed store, hash-verified

91 * - start the port and report its status to stdout
92 */
93static int
94init_port(uint16_t port_num)
95{
96 /* for port configuration all features are off by default */
97 struct rte_eth_conf port_conf = {
98 .rxmode = {
99 .mq_mode = RTE_ETH_MQ_RX_RSS,
100 },
101 };
102 const uint16_t rx_rings = 1, tx_rings = num_nodes;
103 uint16_t rx_ring_size = RTE_MP_RX_DESC_DEFAULT;
104 uint16_t tx_ring_size = RTE_MP_TX_DESC_DEFAULT;
105 struct rte_eth_dev_info dev_info;
106 struct rte_eth_txconf txconf;
107
108 uint16_t q;
109 int retval;
110
111 printf("Port %u init ... ", port_num);
112 fflush(stdout);
113
114 retval = rte_eth_dev_info_get(port_num, &dev_info);
115 if (retval != 0)
116 return retval;
117
118 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)
119 port_conf.txmode.offloads |=
120 RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
121
122 /*
123 * Standard DPDK port initialisation - config port, then set up
124 * rx and tx rings.
125 */
126 retval = rte_eth_dev_configure(port_num, rx_rings, tx_rings, &port_conf);
127 if (retval != 0)
128 return retval;
129
130 retval = rte_eth_dev_adjust_nb_rx_tx_desc(port_num, &rx_ring_size,
131 &tx_ring_size);
132 if (retval != 0)
133 return retval;
134
135 for (q = 0; q < rx_rings; q++) {
136 retval = rte_eth_rx_queue_setup(port_num, q, rx_ring_size,
137 rte_eth_dev_socket_id(port_num),
138 NULL, pktmbuf_pool);
139 if (retval < 0)
140 return retval;
141 }
142
143 txconf = dev_info.default_txconf;
144 txconf.offloads = port_conf.txmode.offloads;
145 for (q = 0; q < tx_rings; q++) {
146 retval = rte_eth_tx_queue_setup(port_num, q, tx_ring_size,
147 rte_eth_dev_socket_id(port_num),
148 &txconf);
149 if (retval < 0)
150 return retval;

Callers 1

initFunction · 0.70

Calls 9

rte_eth_dev_info_getFunction · 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
printfFunction · 0.50

Tested by

no test coverage detected