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

Function pmd_init_internals

dpdk/drivers/net/pcap/pcap_ethdev.c:1197–1263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1195}
1196
1197static int
1198pmd_init_internals(struct rte_vdev_device *vdev,
1199 const unsigned int nb_rx_queues,
1200 const unsigned int nb_tx_queues,
1201 struct pmd_internals **internals,
1202 struct rte_eth_dev **eth_dev)
1203{
1204 struct rte_eth_dev_data *data;
1205 struct pmd_process_private *pp;
1206 unsigned int numa_node = vdev->device.numa_node;
1207
1208 PMD_LOG(INFO, "Creating pcap-backed ethdev on numa socket %d",
1209 numa_node);
1210
1211 pp = (struct pmd_process_private *)
1212 rte_zmalloc(NULL, sizeof(struct pmd_process_private),
1213 RTE_CACHE_LINE_SIZE);
1214
1215 if (pp == NULL) {
1216 PMD_LOG(ERR,
1217 "Failed to allocate memory for process private");
1218 return -1;
1219 }
1220
1221 /* reserve an ethdev entry */
1222 *eth_dev = rte_eth_vdev_allocate(vdev, sizeof(**internals));
1223 if (!(*eth_dev)) {
1224 rte_free(pp);
1225 return -1;
1226 }
1227 (*eth_dev)->process_private = pp;
1228 /* now put it all together
1229 * - store queue data in internals,
1230 * - store numa_node info in eth_dev
1231 * - point eth_dev_data to internals
1232 * - and point eth_dev structure to new eth_dev_data structure
1233 */
1234 *internals = (*eth_dev)->data->dev_private;
1235 /*
1236 * Interface MAC = 02:70:63:61:70:<iface_idx>
1237 * derived from: 'locally administered':'p':'c':'a':'p':'iface_idx'
1238 * where the middle 4 characters are converted to hex.
1239 */
1240 (*internals)->eth_addr = (struct rte_ether_addr) {
1241 .addr_bytes = { 0x02, 0x70, 0x63, 0x61, 0x70, iface_idx++ }
1242 };
1243 (*internals)->phy_mac = 0;
1244 data = (*eth_dev)->data;
1245 data->nb_rx_queues = (uint16_t)nb_rx_queues;
1246 data->nb_tx_queues = (uint16_t)nb_tx_queues;
1247 data->dev_link = pmd_link;
1248 data->mac_addrs = &(*internals)->eth_addr;
1249 data->promiscuous = 1;
1250 data->all_multicast = 1;
1251 data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
1252
1253 /*
1254 * NOTE: we'll replace the data element, of originally allocated

Callers 1

eth_from_pcaps_commonFunction · 0.85

Calls 5

rte_zmallocFunction · 0.85
rte_eth_vdev_allocateFunction · 0.85
rte_freeFunction · 0.85
rte_vdev_device_argsFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected