xref: /freebsd/sys/fs/p9fs/p9_transport.c (revision e97ad33a89a78f55280b0485b3249ee9b907a718)
1*e97ad33aSDoug Rabson /*-
2*e97ad33aSDoug Rabson  * Copyright (c) 2022-present Doug Rabson
3*e97ad33aSDoug Rabson  * All rights reserved.
4*e97ad33aSDoug Rabson  *
5*e97ad33aSDoug Rabson  * Redistribution and use in source and binary forms, with or without
6*e97ad33aSDoug Rabson  * modification, are permitted provided that the following conditions
7*e97ad33aSDoug Rabson  * are met:
8*e97ad33aSDoug Rabson  * 1. Redistributions of source code must retain the above copyright
9*e97ad33aSDoug Rabson  *    notice, this list of conditions and the following disclaimer.
10*e97ad33aSDoug Rabson  * 2. Redistributions in binary form must reproduce the above copyright
11*e97ad33aSDoug Rabson  *    notice, this list of conditions and the following disclaimer in the
12*e97ad33aSDoug Rabson  *    documentation and/or other materials provided with the distribution.
13*e97ad33aSDoug Rabson  *
14*e97ad33aSDoug Rabson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*e97ad33aSDoug Rabson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*e97ad33aSDoug Rabson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*e97ad33aSDoug Rabson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*e97ad33aSDoug Rabson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*e97ad33aSDoug Rabson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*e97ad33aSDoug Rabson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*e97ad33aSDoug Rabson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*e97ad33aSDoug Rabson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*e97ad33aSDoug Rabson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*e97ad33aSDoug Rabson  * SUCH DAMAGE.
25*e97ad33aSDoug Rabson  */
26*e97ad33aSDoug Rabson 
27*e97ad33aSDoug Rabson #include <sys/param.h>
28*e97ad33aSDoug Rabson #include <sys/kernel.h>
29*e97ad33aSDoug Rabson #include <sys/kassert.h>
30*e97ad33aSDoug Rabson #include <sys/libkern.h>
31*e97ad33aSDoug Rabson 
32*e97ad33aSDoug Rabson #include <fs/p9fs/p9_transport.h>
33*e97ad33aSDoug Rabson 
34*e97ad33aSDoug Rabson TAILQ_HEAD(, p9_trans_module) transports;
35*e97ad33aSDoug Rabson 
36*e97ad33aSDoug Rabson static void
p9_transport_init(void)37*e97ad33aSDoug Rabson p9_transport_init(void)
38*e97ad33aSDoug Rabson {
39*e97ad33aSDoug Rabson 
40*e97ad33aSDoug Rabson         TAILQ_INIT(&transports);
41*e97ad33aSDoug Rabson }
42*e97ad33aSDoug Rabson 
43*e97ad33aSDoug Rabson SYSINIT(p9_transport, SI_SUB_DRIVERS, SI_ORDER_FIRST, p9_transport_init, NULL);
44*e97ad33aSDoug Rabson 
45*e97ad33aSDoug Rabson void
p9_register_trans(struct p9_trans_module * m)46*e97ad33aSDoug Rabson p9_register_trans(struct p9_trans_module *m)
47*e97ad33aSDoug Rabson {
48*e97ad33aSDoug Rabson 
49*e97ad33aSDoug Rabson         TAILQ_INSERT_TAIL(&transports, m, link);
50*e97ad33aSDoug Rabson }
51*e97ad33aSDoug Rabson 
52*e97ad33aSDoug Rabson void
p9_unregister_trans(struct p9_trans_module * m)53*e97ad33aSDoug Rabson p9_unregister_trans(struct p9_trans_module *m)
54*e97ad33aSDoug Rabson {
55*e97ad33aSDoug Rabson 
56*e97ad33aSDoug Rabson         TAILQ_REMOVE(&transports, m, link);
57*e97ad33aSDoug Rabson }
58*e97ad33aSDoug Rabson 
59*e97ad33aSDoug Rabson struct p9_trans_module *
p9_get_trans_by_name(char * name)60*e97ad33aSDoug Rabson p9_get_trans_by_name(char *name)
61*e97ad33aSDoug Rabson {
62*e97ad33aSDoug Rabson         struct p9_trans_module *m;
63*e97ad33aSDoug Rabson 
64*e97ad33aSDoug Rabson         TAILQ_FOREACH(m, &transports, link) {
65*e97ad33aSDoug Rabson                 if (strcmp(m->name, name) == 0)
66*e97ad33aSDoug Rabson                         return (m);
67*e97ad33aSDoug Rabson         }
68*e97ad33aSDoug Rabson         return (NULL);
69*e97ad33aSDoug Rabson }
70*e97ad33aSDoug Rabson 
71