xref: /f-stack/dpdk/drivers/net/ring/rte_eth_ring.c (revision 819aafb6)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2015 Intel Corporation
3  */
4 
5 #include "rte_eth_ring.h"
6 #include <rte_mbuf.h>
7 #include <rte_ethdev_driver.h>
8 #include <rte_malloc.h>
9 #include <rte_memcpy.h>
10 #include <rte_string_fns.h>
11 #include <rte_bus_vdev.h>
12 #include <rte_kvargs.h>
13 #include <rte_errno.h>
14 
15 #define ETH_RING_NUMA_NODE_ACTION_ARG	"nodeaction"
16 #define ETH_RING_ACTION_CREATE		"CREATE"
17 #define ETH_RING_ACTION_ATTACH		"ATTACH"
18 #define ETH_RING_INTERNAL_ARG		"internal"
19 
20 static const char *valid_arguments[] = {
21 	ETH_RING_NUMA_NODE_ACTION_ARG,
22 	ETH_RING_INTERNAL_ARG,
23 	NULL
24 };
25 
26 struct ring_internal_args {
27 	struct rte_ring * const *rx_queues;
28 	const unsigned int nb_rx_queues;
29 	struct rte_ring * const *tx_queues;
30 	const unsigned int nb_tx_queues;
31 	const unsigned int numa_node;
32 	void *addr; /* self addr for sanity check */
33 };
34 
35 enum dev_action {
36 	DEV_CREATE,
37 	DEV_ATTACH
38 };
39 
40 struct ring_queue {
41 	struct rte_ring *rng;
42 	rte_atomic64_t rx_pkts;
43 	rte_atomic64_t tx_pkts;
44 	rte_atomic64_t err_pkts;
45 };
46 
47 struct pmd_internals {
48 	unsigned int max_rx_queues;
49 	unsigned int max_tx_queues;
50 
51 	struct ring_queue rx_ring_queues[RTE_PMD_RING_MAX_RX_RINGS];
52 	struct ring_queue tx_ring_queues[RTE_PMD_RING_MAX_TX_RINGS];
53 
54 	struct ether_addr address;
55 	enum dev_action action;
56 };
57 
58 static struct rte_eth_link pmd_link = {
59 	.link_speed = ETH_SPEED_NUM_10G,
60 	.link_duplex = ETH_LINK_FULL_DUPLEX,
61 	.link_status = ETH_LINK_DOWN,
62 	.link_autoneg = ETH_LINK_FIXED,
63 };
64 
65 static int eth_ring_logtype;
66 
67 #define PMD_LOG(level, fmt, args...) \
68 	rte_log(RTE_LOG_ ## level, eth_ring_logtype, \
69 		"%s(): " fmt "\n", __func__, ##args)
70 
71 static uint16_t
72 eth_ring_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
73 {
74 	void **ptrs = (void *)&bufs[0];
75 	struct ring_queue *r = q;
76 	const uint16_t nb_rx = (uint16_t)rte_ring_dequeue_burst(r->rng,
77 			ptrs, nb_bufs, NULL);
78 	if (r->rng->flags & RING_F_SC_DEQ)
79 		r->rx_pkts.cnt += nb_rx;
80 	else
81 		rte_atomic64_add(&(r->rx_pkts), nb_rx);
82 	return nb_rx;
83 }
84 
85 static uint16_t
86 eth_ring_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
87 {
88 	void **ptrs = (void *)&bufs[0];
89 	struct ring_queue *r = q;
90 	const uint16_t nb_tx = (uint16_t)rte_ring_enqueue_burst(r->rng,
91 			ptrs, nb_bufs, NULL);
92 	if (r->rng->flags & RING_F_SP_ENQ) {
93 		r->tx_pkts.cnt += nb_tx;
94 		r->err_pkts.cnt += nb_bufs - nb_tx;
95 	} else {
96 		rte_atomic64_add(&(r->tx_pkts), nb_tx);
97 		rte_atomic64_add(&(r->err_pkts), nb_bufs - nb_tx);
98 	}
99 	return nb_tx;
100 }
101 
102 static int
103 eth_dev_configure(struct rte_eth_dev *dev __rte_unused) { return 0; }
104 
105 static int
106 eth_dev_start(struct rte_eth_dev *dev)
107 {
108 	dev->data->dev_link.link_status = ETH_LINK_UP;
109 	return 0;
110 }
111 
112 static void
113 eth_dev_stop(struct rte_eth_dev *dev)
114 {
115 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
116 }
117 
118 static int
119 eth_dev_set_link_down(struct rte_eth_dev *dev)
120 {
121 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
122 	return 0;
123 }
124 
125 static int
126 eth_dev_set_link_up(struct rte_eth_dev *dev)
127 {
128 	dev->data->dev_link.link_status = ETH_LINK_UP;
129 	return 0;
130 }
131 
132 static int
133 eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
134 				    uint16_t nb_rx_desc __rte_unused,
135 				    unsigned int socket_id __rte_unused,
136 				    const struct rte_eth_rxconf *rx_conf __rte_unused,
137 				    struct rte_mempool *mb_pool __rte_unused)
138 {
139 	struct pmd_internals *internals = dev->data->dev_private;
140 
141 	dev->data->rx_queues[rx_queue_id] = &internals->rx_ring_queues[rx_queue_id];
142 	return 0;
143 }
144 
145 static int
146 eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
147 				    uint16_t nb_tx_desc __rte_unused,
148 				    unsigned int socket_id __rte_unused,
149 				    const struct rte_eth_txconf *tx_conf __rte_unused)
150 {
151 	struct pmd_internals *internals = dev->data->dev_private;
152 
153 	dev->data->tx_queues[tx_queue_id] = &internals->tx_ring_queues[tx_queue_id];
154 	return 0;
155 }
156 
157 
158 static void
159 eth_dev_info(struct rte_eth_dev *dev,
160 	     struct rte_eth_dev_info *dev_info)
161 {
162 	struct pmd_internals *internals = dev->data->dev_private;
163 
164 	dev_info->max_mac_addrs = 1;
165 	dev_info->max_rx_pktlen = (uint32_t)-1;
166 	dev_info->max_rx_queues = (uint16_t)internals->max_rx_queues;
167 	dev_info->max_tx_queues = (uint16_t)internals->max_tx_queues;
168 	dev_info->min_rx_bufsize = 0;
169 }
170 
171 static int
172 eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
173 {
174 	unsigned int i;
175 	unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;
176 	const struct pmd_internals *internal = dev->data->dev_private;
177 
178 	for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
179 			i < dev->data->nb_rx_queues; i++) {
180 		stats->q_ipackets[i] = internal->rx_ring_queues[i].rx_pkts.cnt;
181 		rx_total += stats->q_ipackets[i];
182 	}
183 
184 	for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
185 			i < dev->data->nb_tx_queues; i++) {
186 		stats->q_opackets[i] = internal->tx_ring_queues[i].tx_pkts.cnt;
187 		stats->q_errors[i] = internal->tx_ring_queues[i].err_pkts.cnt;
188 		tx_total += stats->q_opackets[i];
189 		tx_err_total += stats->q_errors[i];
190 	}
191 
192 	stats->ipackets = rx_total;
193 	stats->opackets = tx_total;
194 	stats->oerrors = tx_err_total;
195 
196 	return 0;
197 }
198 
199 static void
200 eth_stats_reset(struct rte_eth_dev *dev)
201 {
202 	unsigned int i;
203 	struct pmd_internals *internal = dev->data->dev_private;
204 
205 	for (i = 0; i < dev->data->nb_rx_queues; i++)
206 		internal->rx_ring_queues[i].rx_pkts.cnt = 0;
207 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
208 		internal->tx_ring_queues[i].tx_pkts.cnt = 0;
209 		internal->tx_ring_queues[i].err_pkts.cnt = 0;
210 	}
211 }
212 
213 static void
214 eth_mac_addr_remove(struct rte_eth_dev *dev __rte_unused,
215 	uint32_t index __rte_unused)
216 {
217 }
218 
219 static int
220 eth_mac_addr_add(struct rte_eth_dev *dev __rte_unused,
221 	struct ether_addr *mac_addr __rte_unused,
222 	uint32_t index __rte_unused,
223 	uint32_t vmdq __rte_unused)
224 {
225 	return 0;
226 }
227 
228 static void
229 eth_queue_release(void *q __rte_unused) { ; }
230 static int
231 eth_link_update(struct rte_eth_dev *dev __rte_unused,
232 		int wait_to_complete __rte_unused) { return 0; }
233 
234 static const struct eth_dev_ops ops = {
235 	.dev_start = eth_dev_start,
236 	.dev_stop = eth_dev_stop,
237 	.dev_set_link_up = eth_dev_set_link_up,
238 	.dev_set_link_down = eth_dev_set_link_down,
239 	.dev_configure = eth_dev_configure,
240 	.dev_infos_get = eth_dev_info,
241 	.rx_queue_setup = eth_rx_queue_setup,
242 	.tx_queue_setup = eth_tx_queue_setup,
243 	.rx_queue_release = eth_queue_release,
244 	.tx_queue_release = eth_queue_release,
245 	.link_update = eth_link_update,
246 	.stats_get = eth_stats_get,
247 	.stats_reset = eth_stats_reset,
248 	.mac_addr_remove = eth_mac_addr_remove,
249 	.mac_addr_add = eth_mac_addr_add,
250 };
251 
252 static int
253 do_eth_dev_ring_create(const char *name,
254 		struct rte_ring * const rx_queues[],
255 		const unsigned int nb_rx_queues,
256 		struct rte_ring *const tx_queues[],
257 		const unsigned int nb_tx_queues,
258 		const unsigned int numa_node, enum dev_action action,
259 		struct rte_eth_dev **eth_dev_p)
260 {
261 	struct rte_eth_dev_data *data = NULL;
262 	struct pmd_internals *internals = NULL;
263 	struct rte_eth_dev *eth_dev = NULL;
264 	void **rx_queues_local = NULL;
265 	void **tx_queues_local = NULL;
266 	unsigned int i;
267 
268 	PMD_LOG(INFO, "Creating rings-backed ethdev on numa socket %u",
269 			numa_node);
270 
271 	rx_queues_local = rte_calloc_socket(name, nb_rx_queues,
272 					    sizeof(void *), 0, numa_node);
273 	if (rx_queues_local == NULL) {
274 		rte_errno = ENOMEM;
275 		goto error;
276 	}
277 
278 	tx_queues_local = rte_calloc_socket(name, nb_tx_queues,
279 					    sizeof(void *), 0, numa_node);
280 	if (tx_queues_local == NULL) {
281 		rte_errno = ENOMEM;
282 		goto error;
283 	}
284 
285 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
286 	if (internals == NULL) {
287 		rte_errno = ENOMEM;
288 		goto error;
289 	}
290 
291 	/* reserve an ethdev entry */
292 	eth_dev = rte_eth_dev_allocate(name);
293 	if (eth_dev == NULL) {
294 		rte_errno = ENOSPC;
295 		goto error;
296 	}
297 
298 	/* now put it all together
299 	 * - store queue data in internals,
300 	 * - store numa_node info in eth_dev_data
301 	 * - point eth_dev_data to internals
302 	 * - and point eth_dev structure to new eth_dev_data structure
303 	 */
304 
305 	data = eth_dev->data;
306 	data->rx_queues = rx_queues_local;
307 	data->tx_queues = tx_queues_local;
308 
309 	internals->action = action;
310 	internals->max_rx_queues = nb_rx_queues;
311 	internals->max_tx_queues = nb_tx_queues;
312 	for (i = 0; i < nb_rx_queues; i++) {
313 		internals->rx_ring_queues[i].rng = rx_queues[i];
314 		data->rx_queues[i] = &internals->rx_ring_queues[i];
315 	}
316 	for (i = 0; i < nb_tx_queues; i++) {
317 		internals->tx_ring_queues[i].rng = tx_queues[i];
318 		data->tx_queues[i] = &internals->tx_ring_queues[i];
319 	}
320 
321 	data->dev_private = internals;
322 	data->nb_rx_queues = (uint16_t)nb_rx_queues;
323 	data->nb_tx_queues = (uint16_t)nb_tx_queues;
324 	data->dev_link = pmd_link;
325 	data->mac_addrs = &internals->address;
326 
327 	eth_dev->dev_ops = &ops;
328 	data->kdrv = RTE_KDRV_NONE;
329 	data->numa_node = numa_node;
330 
331 	/* finally assign rx and tx ops */
332 	eth_dev->rx_pkt_burst = eth_ring_rx;
333 	eth_dev->tx_pkt_burst = eth_ring_tx;
334 
335 	rte_eth_dev_probing_finish(eth_dev);
336 	*eth_dev_p = eth_dev;
337 
338 	return data->port_id;
339 
340 error:
341 	rte_free(rx_queues_local);
342 	rte_free(tx_queues_local);
343 	rte_free(internals);
344 
345 	return -1;
346 }
347 
348 int
349 rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
350 		const unsigned int nb_rx_queues,
351 		struct rte_ring *const tx_queues[],
352 		const unsigned int nb_tx_queues,
353 		const unsigned int numa_node)
354 {
355 	struct ring_internal_args args = {
356 		.rx_queues = rx_queues,
357 		.nb_rx_queues = nb_rx_queues,
358 		.tx_queues = tx_queues,
359 		.nb_tx_queues = nb_tx_queues,
360 		.numa_node = numa_node,
361 		.addr = &args,
362 	};
363 	char args_str[32];
364 	char ring_name[RTE_RING_NAMESIZE];
365 	uint16_t port_id = RTE_MAX_ETHPORTS;
366 	int ret;
367 
368 	/* do some parameter checking */
369 	if (rx_queues == NULL && nb_rx_queues > 0) {
370 		rte_errno = EINVAL;
371 		return -1;
372 	}
373 	if (tx_queues == NULL && nb_tx_queues > 0) {
374 		rte_errno = EINVAL;
375 		return -1;
376 	}
377 	if (nb_rx_queues > RTE_PMD_RING_MAX_RX_RINGS) {
378 		rte_errno = EINVAL;
379 		return -1;
380 	}
381 
382 	snprintf(args_str, sizeof(args_str), "%s=%p",
383 		 ETH_RING_INTERNAL_ARG, &args);
384 
385 	ret = snprintf(ring_name, sizeof(ring_name), "net_ring_%s", name);
386 	if (ret >= (int)sizeof(ring_name)) {
387 		rte_errno = ENAMETOOLONG;
388 		return -1;
389 	}
390 
391 	ret = rte_vdev_init(ring_name, args_str);
392 	if (ret) {
393 		rte_errno = EINVAL;
394 		return -1;
395 	}
396 
397 	ret = rte_eth_dev_get_port_by_name(ring_name, &port_id);
398 	if (ret) {
399 		rte_errno = ENODEV;
400 		return -1;
401 	}
402 
403 	return port_id;
404 }
405 
406 int
407 rte_eth_from_ring(struct rte_ring *r)
408 {
409 	return rte_eth_from_rings(r->name, &r, 1, &r, 1,
410 			r->memzone ? r->memzone->socket_id : SOCKET_ID_ANY);
411 }
412 
413 static int
414 eth_dev_ring_create(const char *name, const unsigned int numa_node,
415 		enum dev_action action, struct rte_eth_dev **eth_dev)
416 {
417 	/* rx and tx are so-called from point of view of first port.
418 	 * They are inverted from the point of view of second port
419 	 */
420 	struct rte_ring *rxtx[RTE_PMD_RING_MAX_RX_RINGS];
421 	unsigned int i;
422 	char rng_name[RTE_RING_NAMESIZE];
423 	unsigned int num_rings = RTE_MIN(RTE_PMD_RING_MAX_RX_RINGS,
424 			RTE_PMD_RING_MAX_TX_RINGS);
425 
426 	for (i = 0; i < num_rings; i++) {
427 		int cc;
428 
429 		cc = snprintf(rng_name, sizeof(rng_name),
430 			      "ETH_RXTX%u_%s", i, name);
431 		if (cc >= (int)sizeof(rng_name)) {
432 			rte_errno = ENAMETOOLONG;
433 			return -1;
434 		}
435 
436 		rxtx[i] = (action == DEV_CREATE) ?
437 				rte_ring_create(rng_name, 1024, numa_node,
438 						RING_F_SP_ENQ|RING_F_SC_DEQ) :
439 				rte_ring_lookup(rng_name);
440 		if (rxtx[i] == NULL)
441 			return -1;
442 	}
443 
444 	if (do_eth_dev_ring_create(name, rxtx, num_rings, rxtx, num_rings,
445 		numa_node, action, eth_dev) < 0)
446 		return -1;
447 
448 	return 0;
449 }
450 
451 struct node_action_pair {
452 	char name[PATH_MAX];
453 	unsigned int node;
454 	enum dev_action action;
455 };
456 
457 struct node_action_list {
458 	unsigned int total;
459 	unsigned int count;
460 	struct node_action_pair *list;
461 };
462 
463 static int parse_kvlist(const char *key __rte_unused,
464 			const char *value, void *data)
465 {
466 	struct node_action_list *info = data;
467 	int ret;
468 	char *name;
469 	char *action;
470 	char *node;
471 	char *end;
472 
473 	name = strdup(value);
474 
475 	ret = -EINVAL;
476 
477 	if (!name) {
478 		PMD_LOG(WARNING, "command line parameter is empty for ring pmd!");
479 		goto out;
480 	}
481 
482 	node = strchr(name, ':');
483 	if (!node) {
484 		PMD_LOG(WARNING, "could not parse node value from %s",
485 			name);
486 		goto out;
487 	}
488 
489 	*node = '\0';
490 	node++;
491 
492 	action = strchr(node, ':');
493 	if (!action) {
494 		PMD_LOG(WARNING, "could not parse action value from %s",
495 			node);
496 		goto out;
497 	}
498 
499 	*action = '\0';
500 	action++;
501 
502 	/*
503 	 * Need to do some sanity checking here
504 	 */
505 
506 	if (strcmp(action, ETH_RING_ACTION_ATTACH) == 0)
507 		info->list[info->count].action = DEV_ATTACH;
508 	else if (strcmp(action, ETH_RING_ACTION_CREATE) == 0)
509 		info->list[info->count].action = DEV_CREATE;
510 	else
511 		goto out;
512 
513 	errno = 0;
514 	info->list[info->count].node = strtol(node, &end, 10);
515 
516 	if ((errno != 0) || (*end != '\0')) {
517 		PMD_LOG(WARNING,
518 			"node value %s is unparseable as a number", node);
519 		goto out;
520 	}
521 
522 	snprintf(info->list[info->count].name, sizeof(info->list[info->count].name), "%s", name);
523 
524 	info->count++;
525 
526 	ret = 0;
527 out:
528 	free(name);
529 	return ret;
530 }
531 
532 static int
533 parse_internal_args(const char *key __rte_unused, const char *value,
534 		void *data)
535 {
536 	struct ring_internal_args **internal_args = data;
537 	void *args;
538 
539 	sscanf(value, "%p", &args);
540 
541 	*internal_args = args;
542 
543 	if ((*internal_args)->addr != args)
544 		return -1;
545 
546 	return 0;
547 }
548 
549 static int
550 rte_pmd_ring_probe(struct rte_vdev_device *dev)
551 {
552 	const char *name, *params;
553 	struct rte_kvargs *kvlist = NULL;
554 	int ret = 0;
555 	struct node_action_list *info = NULL;
556 	struct rte_eth_dev *eth_dev = NULL;
557 	struct ring_internal_args *internal_args;
558 
559 	name = rte_vdev_device_name(dev);
560 	params = rte_vdev_device_args(dev);
561 
562 	PMD_LOG(INFO, "Initializing pmd_ring for %s", name);
563 
564 	if (params == NULL || params[0] == '\0') {
565 		ret = eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE,
566 				&eth_dev);
567 		if (ret == -1) {
568 			PMD_LOG(INFO,
569 				"Attach to pmd_ring for %s", name);
570 			ret = eth_dev_ring_create(name, rte_socket_id(),
571 						  DEV_ATTACH, &eth_dev);
572 		}
573 	} else {
574 		kvlist = rte_kvargs_parse(params, valid_arguments);
575 
576 		if (!kvlist) {
577 			PMD_LOG(INFO,
578 				"Ignoring unsupported parameters when creatingrings-backed ethernet device");
579 			ret = eth_dev_ring_create(name, rte_socket_id(),
580 						  DEV_CREATE, &eth_dev);
581 			if (ret == -1) {
582 				PMD_LOG(INFO,
583 					"Attach to pmd_ring for %s",
584 					name);
585 				ret = eth_dev_ring_create(name, rte_socket_id(),
586 							  DEV_ATTACH, &eth_dev);
587 			}
588 
589 			if (eth_dev)
590 				eth_dev->device = &dev->device;
591 
592 			return ret;
593 		}
594 
595 		if (rte_kvargs_count(kvlist, ETH_RING_INTERNAL_ARG) == 1) {
596 			ret = rte_kvargs_process(kvlist, ETH_RING_INTERNAL_ARG,
597 						 parse_internal_args,
598 						 &internal_args);
599 			if (ret < 0)
600 				goto out_free;
601 
602 			ret = do_eth_dev_ring_create(name,
603 				internal_args->rx_queues,
604 				internal_args->nb_rx_queues,
605 				internal_args->tx_queues,
606 				internal_args->nb_tx_queues,
607 				internal_args->numa_node,
608 				DEV_ATTACH,
609 				&eth_dev);
610 			if (ret >= 0)
611 				ret = 0;
612 		} else {
613 			ret = rte_kvargs_count(kvlist, ETH_RING_NUMA_NODE_ACTION_ARG);
614 			info = rte_zmalloc("struct node_action_list",
615 					   sizeof(struct node_action_list) +
616 					   (sizeof(struct node_action_pair) * ret),
617 					   0);
618 			if (!info)
619 				goto out_free;
620 
621 			info->total = ret;
622 			info->list = (struct node_action_pair *)(info + 1);
623 
624 			ret = rte_kvargs_process(kvlist, ETH_RING_NUMA_NODE_ACTION_ARG,
625 						 parse_kvlist, info);
626 
627 			if (ret < 0)
628 				goto out_free;
629 
630 			for (info->count = 0; info->count < info->total; info->count++) {
631 				ret = eth_dev_ring_create(info->list[info->count].name,
632 							  info->list[info->count].node,
633 							  info->list[info->count].action,
634 							  &eth_dev);
635 				if ((ret == -1) &&
636 				    (info->list[info->count].action == DEV_CREATE)) {
637 					PMD_LOG(INFO,
638 						"Attach to pmd_ring for %s",
639 						name);
640 					ret = eth_dev_ring_create(name,
641 							info->list[info->count].node,
642 							DEV_ATTACH,
643 							&eth_dev);
644 				}
645 			}
646 		}
647 	}
648 
649 	if (eth_dev)
650 		eth_dev->device = &dev->device;
651 
652 out_free:
653 	rte_kvargs_free(kvlist);
654 	rte_free(info);
655 	return ret;
656 }
657 
658 static int
659 rte_pmd_ring_remove(struct rte_vdev_device *dev)
660 {
661 	const char *name = rte_vdev_device_name(dev);
662 	struct rte_eth_dev *eth_dev = NULL;
663 	struct pmd_internals *internals = NULL;
664 	struct ring_queue *r = NULL;
665 	uint16_t i;
666 
667 	PMD_LOG(INFO, "Un-Initializing pmd_ring for %s", name);
668 
669 	if (name == NULL)
670 		return -EINVAL;
671 
672 	/* find an ethdev entry */
673 	eth_dev = rte_eth_dev_allocated(name);
674 	if (eth_dev == NULL)
675 		return -ENODEV;
676 
677 	eth_dev_stop(eth_dev);
678 
679 	internals = eth_dev->data->dev_private;
680 	if (internals->action == DEV_CREATE) {
681 		/*
682 		 * it is only necessary to delete the rings in rx_queues because
683 		 * they are the same used in tx_queues
684 		 */
685 		for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
686 			r = eth_dev->data->rx_queues[i];
687 			rte_ring_free(r->rng);
688 		}
689 	}
690 
691 	/* mac_addrs must not be freed alone because part of dev_private */
692 	eth_dev->data->mac_addrs = NULL;
693 	rte_eth_dev_release_port(eth_dev);
694 	return 0;
695 }
696 
697 static struct rte_vdev_driver pmd_ring_drv = {
698 	.probe = rte_pmd_ring_probe,
699 	.remove = rte_pmd_ring_remove,
700 };
701 
702 RTE_PMD_REGISTER_VDEV(net_ring, pmd_ring_drv);
703 RTE_PMD_REGISTER_ALIAS(net_ring, eth_ring);
704 RTE_PMD_REGISTER_PARAM_STRING(net_ring,
705 	ETH_RING_NUMA_NODE_ACTION_ARG "=name:node:action(ATTACH|CREATE)");
706 
707 RTE_INIT(eth_ring_init_log)
708 {
709 	eth_ring_logtype = rte_log_register("pmd.net.ring");
710 	if (eth_ring_logtype >= 0)
711 		rte_log_set_level(eth_ring_logtype, RTE_LOG_NOTICE);
712 }
713