]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netinet/toedev.h
Fix a panic in MAC kernels that was a result of un-initialized label
[FreeBSD/FreeBSD.git] / sys / netinet / toedev.h
1 /*-
2  * Copyright (c) 2007, Chelsio Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  *    this list of conditions and the following disclaimer.
10  *
11  * 2. Neither the name of the Chelsio Corporation nor the names of its
12  *    contributors may be used to endorse or promote products derived from
13  *    this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  *
27  * $FreeBSD$
28  */
29
30 #ifndef _NETINET_TOEDEV_H_
31 #define _NETINET_TOEDEV_H_
32
33 #ifndef _KERNEL
34 #error "no user-serviceable parts inside"
35 #endif
36
37 /* Parameter values for offload_get_phys_egress(). */
38 enum {
39         TOE_OPEN,
40         TOE_FAILOVER,
41 };
42
43 /* Parameter values for toe_failover(). */
44 enum {
45         TOE_ACTIVE_SLAVE,
46         TOE_LINK_DOWN,
47         TOE_LINK_UP,
48         TOE_RELEASE,
49         TOE_RELEASE_ALL,
50 };
51
52 #define TOENAMSIZ       16
53
54 /* Get the toedev associated with a ifnet. */
55 #define TOEDEV(ifp)     ((ifp)->if_llsoftc)
56
57 struct offload_id {
58         unsigned int    id;
59         unsigned long   data;
60 };
61
62 struct ifnet;
63 struct rt_entry;
64 struct tom_info;
65 struct sysctl_oid;
66 struct socket;
67 struct mbuf;
68
69 struct toedev {
70         TAILQ_ENTRY(toedev) entry;  
71         char            tod_name[TOENAMSIZ];    /* TOE device name */
72         unsigned int    tod_ttid;               /* TOE type id */
73         unsigned long   tod_flags;              /* device flags */
74         unsigned int    tod_mtu;                /* max TX offloaded data */
75         unsigned int    tod_nconn;              /* max # of offloaded
76                                                  * connections
77                                                  */
78         struct ifnet    *tod_lldev;             /* first interface */
79         const struct tom_info *tod_offload_mod; /* TCP offload module */
80
81         /*
82          * This TOE device is capable of offloading the connection for socket so
83          */
84         int     (*tod_can_offload)(struct toedev *dev, struct socket *so);
85
86         /*
87          * Establish a connection to nam using the TOE device dev
88          */
89         int     (*tod_connect)(struct toedev *dev, struct socket *so,
90                 struct rtentry *rt, struct sockaddr *nam);
91         /*
92          * Send an mbuf down to the toe device 
93          */
94         int     (*tod_send)(struct toedev *dev, struct mbuf *m);
95         /*
96          * Receive an array of mbufs from the TOE device dev 
97          */
98         int     (*tod_recv)(struct toedev *dev, struct mbuf **m, int n);
99         /*
100          * Device specific ioctl interface
101          */
102         int     (*tod_ctl)(struct toedev *dev, unsigned int req, void *data);
103         /*
104          * Update L2 entry in toedev 
105          */
106         void    (*tod_arp_update)(struct toedev *dev, struct rtentry *neigh);
107         /*
108          * Failover from one toe device to another
109          */
110         void    (*tod_failover)(struct toedev *dev, struct ifnet *bond_ifp,
111                          struct ifnet *ndev, int event);
112         void    *tod_priv;                      /* driver private data */
113         void    *tod_l2opt;                     /* optional layer 2 data */
114         void    *tod_l3opt;                     /* optional layer 3 data */
115         void    *tod_l4opt;                     /* optional layer 4 data */
116         void    *tod_ulp;                       /* upper lever protocol */
117 };
118
119 struct tom_info {
120         TAILQ_ENTRY(tom_info)   entry;
121         int             (*ti_attach)(struct toedev *dev,
122                                      const struct offload_id *entry);
123         int             (*ti_detach)(struct toedev *dev);
124         const char      *ti_name;
125         const struct offload_id *ti_id_table;
126 };
127
128 static __inline void
129 init_offload_dev(struct toedev *dev)
130 {
131 }
132
133 int     register_tom(struct tom_info *t);
134 int     unregister_tom(struct tom_info *t);
135 int     register_toedev(struct toedev *dev, const char *name);
136 int     unregister_toedev(struct toedev *dev);
137 int     activate_offload(struct toedev *dev);
138 int     toe_send(struct toedev *dev, struct mbuf *m);
139 void    toe_arp_update(struct rtentry *rt);
140 struct ifnet    *offload_get_phys_egress(struct ifnet *ifp,
141         struct socket *so, int context);
142 int     toe_receive_mbuf(struct toedev *dev, struct mbuf **m, int n);
143
144 static __inline void
145 toe_neigh_update(struct ifnet *ifp)
146 {
147 }
148
149 static __inline void
150 toe_failover(struct ifnet *bond_ifp, struct ifnet *fail_ifp, int event)
151 {
152 }
153
154 static __inline int
155 toe_enslave(struct ifnet *bond_ifp, struct ifnet *slave_ifp)
156 {
157         return (0);
158 }
159
160 #endif /* _NETINET_TOEDEV_H_ */