netmap_pipe.c (261909) | netmap_pipe.c (267128) |
---|---|
1/* 2 * Copyright (C) 2014 Giuseppe Lettieri. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 9 unchanged lines hidden (view full) --- 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 | 1/* 2 * Copyright (C) 2014 Giuseppe Lettieri. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 9 unchanged lines hidden (view full) --- 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 |
26/* $FreeBSD: head/sys/dev/netmap/netmap_pipe.c 261909 2014-02-15 04:53:04Z luigi $ */ | 26/* $FreeBSD: head/sys/dev/netmap/netmap_pipe.c 267128 2014-06-05 21:12:41Z luigi $ */ |
27 28#if defined(__FreeBSD__) 29#include <sys/cdefs.h> /* prerequisite */ 30 31#include <sys/types.h> 32#include <sys/errno.h> 33#include <sys/param.h> /* defines used in kernel.h */ 34#include <sys/kernel.h> /* types used in module initialization */ --- 351 unchanged lines hidden (view full) --- 386 netmap_krings_delete(na); 387err: 388 return error; 389} 390 391/* netmap_pipe_reg. 392 * 393 * There are two cases on registration (onoff==1) | 27 28#if defined(__FreeBSD__) 29#include <sys/cdefs.h> /* prerequisite */ 30 31#include <sys/types.h> 32#include <sys/errno.h> 33#include <sys/param.h> /* defines used in kernel.h */ 34#include <sys/kernel.h> /* types used in module initialization */ --- 351 unchanged lines hidden (view full) --- 386 netmap_krings_delete(na); 387err: 388 return error; 389} 390 391/* netmap_pipe_reg. 392 * 393 * There are two cases on registration (onoff==1) |
394 * | 394 * |
395 * 1.a) state is 396 * 397 * usr1 --> e1 --> e2 398 * 399 * and we are e1. Nothing special to do. 400 * 401 * 1.b) state is 402 * 403 * usr1 --> e1 --> e2 <-- usr2 404 * 405 * and we are e2. Drop the ref e1 is holding. | 395 * 1.a) state is 396 * 397 * usr1 --> e1 --> e2 398 * 399 * and we are e1. Nothing special to do. 400 * 401 * 1.b) state is 402 * 403 * usr1 --> e1 --> e2 <-- usr2 404 * 405 * and we are e2. Drop the ref e1 is holding. |
406 * | 406 * |
407 * There are two additional cases on unregister (onoff==0) 408 * 409 * 2.a) state is 410 * 411 * usr1 --> e1 --> e2 412 * 413 * and we are e1. Nothing special to do, e2 will 414 * be cleaned up by the destructor of e1. --- 42 unchanged lines hidden (view full) --- 457} 458 459/* netmap_pipe_krings_delete. 460 * 461 * There are two cases: 462 * 463 * 1) state is 464 * | 407 * There are two additional cases on unregister (onoff==0) 408 * 409 * 2.a) state is 410 * 411 * usr1 --> e1 --> e2 412 * 413 * and we are e1. Nothing special to do, e2 will 414 * be cleaned up by the destructor of e1. --- 42 unchanged lines hidden (view full) --- 457} 458 459/* netmap_pipe_krings_delete. 460 * 461 * There are two cases: 462 * 463 * 1) state is 464 * |
465 * usr1 --> e1 --> e2 | 465 * usr1 --> e1 --> e2 |
466 * | 466 * |
467 * and we are e1 (e2 is not registered, so krings_delete cannot be | 467 * and we are e1 (e2 is not registered, so krings_delete cannot be |
468 * called on it); 469 * 470 * 2) state is 471 * | 468 * called on it); 469 * 470 * 2) state is 471 * |
472 * usr1 --> e1 e2 <-- usr2 | 472 * usr1 --> e1 e2 <-- usr2 |
473 * 474 * and we are either e1 or e2. 475 * 476 * In the former case we have to also delete the krings of e2; 477 * in the latter case we do nothing (note that our krings 478 * have already been hidden in the unregister callback). 479 */ 480static void --- 33 unchanged lines hidden (view full) --- 514 struct netmap_pipe_adapter *pna = 515 (struct netmap_pipe_adapter *)na; 516 ND("%p", na); 517 if (pna->peer_ref) { 518 ND("%p: clean up peer", na); 519 pna->peer_ref = 0; 520 netmap_adapter_put(&pna->peer->up); 521 } | 473 * 474 * and we are either e1 or e2. 475 * 476 * In the former case we have to also delete the krings of e2; 477 * in the latter case we do nothing (note that our krings 478 * have already been hidden in the unregister callback). 479 */ 480static void --- 33 unchanged lines hidden (view full) --- 514 struct netmap_pipe_adapter *pna = 515 (struct netmap_pipe_adapter *)na; 516 ND("%p", na); 517 if (pna->peer_ref) { 518 ND("%p: clean up peer", na); 519 pna->peer_ref = 0; 520 netmap_adapter_put(&pna->peer->up); 521 } |
522 if (pna->role == NR_REG_PIPE_MASTER) | 522 if (pna->role == NR_REG_PIPE_MASTER) |
523 netmap_pipe_remove(pna->parent, pna); 524 netmap_adapter_put(pna->parent); 525 free(na->ifp, M_DEVBUF); 526 na->ifp = NULL; 527 pna->parent = NULL; 528} 529 530int --- 51 unchanged lines hidden (view full) --- 582 netmap_adapter_put(pna); 583 goto found; 584 } 585 ND("pipe %d not found, create %d", pipe_id, create); 586 if (!create) { 587 error = ENODEV; 588 goto put_out; 589 } | 523 netmap_pipe_remove(pna->parent, pna); 524 netmap_adapter_put(pna->parent); 525 free(na->ifp, M_DEVBUF); 526 na->ifp = NULL; 527 pna->parent = NULL; 528} 529 530int --- 51 unchanged lines hidden (view full) --- 582 netmap_adapter_put(pna); 583 goto found; 584 } 585 ND("pipe %d not found, create %d", pipe_id, create); 586 if (!create) { 587 error = ENODEV; 588 goto put_out; 589 } |
590 /* we create both master and slave. | 590 /* we create both master and slave. |
591 * The endpoint we were asked for holds a reference to 592 * the other one. 593 */ 594 ifp = malloc(sizeof(*ifp), M_DEVBUF, M_NOWAIT | M_ZERO); 595 if (!ifp) { 596 error = ENOMEM; 597 goto put_out; 598 } --- 113 unchanged lines hidden --- | 591 * The endpoint we were asked for holds a reference to 592 * the other one. 593 */ 594 ifp = malloc(sizeof(*ifp), M_DEVBUF, M_NOWAIT | M_ZERO); 595 if (!ifp) { 596 error = ENOMEM; 597 goto put_out; 598 } --- 113 unchanged lines hidden --- |