]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netinet/toedev.h
This commit was generated by cvs2svn to compensate for changes in r178843,
[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         int     (*tod_open)(struct toedev *dev);
82         int     (*tod_close)(struct toedev *dev);
83         int     (*tod_can_offload)(struct toedev *dev, struct socket *so);
84         int     (*tod_connect)(struct toedev *dev, struct socket *so,
85                 struct rtentry *rt, struct sockaddr *nam);
86         int     (*tod_send)(struct toedev *dev, struct mbuf *m);
87         int     (*tod_recv)(struct toedev *dev, struct mbuf **m, int n);
88         int     (*tod_ctl)(struct toedev *dev, unsigned int req, void *data);
89         void    (*tod_arp_update)(struct toedev *dev, struct rtentry *neigh);
90         void    (*tod_failover)(struct toedev *dev, struct ifnet *bond_ifp,
91                          struct ifnet *ndev, int event);
92         void    *tod_priv;                      /* driver private data */
93         void    *tod_l2opt;                     /* optional layer 2 data */
94         void    *tod_l3opt;                     /* optional layer 3 data */
95         void    *tod_l4opt;                     /* optional layer 4 data */
96         void    *tod_ulp;                       /* upper lever protocol */
97 };
98
99 struct tom_info {
100         TAILQ_ENTRY(tom_info)   entry;
101         int             (*ti_attach)(struct toedev *dev,
102                                      const struct offload_id *entry);
103         int             (*ti_detach)(struct toedev *dev);
104         const char      *ti_name;
105         const struct offload_id *ti_id_table;
106 };
107
108 static __inline void
109 init_offload_dev(struct toedev *dev)
110 {
111 }
112
113 int     register_tom(struct tom_info *t);
114 int     unregister_tom(struct tom_info *t);
115 int     register_toedev(struct toedev *dev, const char *name);
116 int     unregister_toedev(struct toedev *dev);
117 int     activate_offload(struct toedev *dev);
118 int     toe_send(struct toedev *dev, struct mbuf *m);
119 void    toe_arp_update(struct rtentry *rt);
120 struct ifnet    *offload_get_phys_egress(struct ifnet *ifp,
121         struct socket *so, int context);
122 int     toe_receive_mbuf(struct toedev *dev, struct mbuf **m, int n);
123
124 static __inline void
125 toe_neigh_update(struct ifnet *ifp)
126 {
127 }
128
129 static __inline void
130 toe_failover(struct ifnet *bond_ifp, struct ifnet *fail_ifp, int event)
131 {
132 }
133
134 static __inline int
135 toe_enslave(struct ifnet *bond_ifp, struct ifnet *slave_ifp)
136 {
137         return (0);
138 }
139
140 #endif /* _NETINET_TOEDEV_H_ */