]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - 6/sys/dev/cxgb/ulp/toecore/toedev.h
Clone Kip's Xen on stable/6 tree so that I can work on improving FreeBSD/amd64
[FreeBSD/FreeBSD.git] / 6 / sys / dev / cxgb / ulp / toecore / toedev.h
1
2 /**************************************************************************
3
4 Copyright (c) 2007, Chelsio Inc.
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10  1. Redistributions of source code must retain the above copyright notice,
11     this list of conditions and the following disclaimer.
12
13  2. Neither the name of the Chelsio Corporation nor the names of its
14     contributors may be used to endorse or promote products derived from
15     this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
28
29 $FreeBSD$
30
31 ***************************************************************************/
32
33 #ifndef _OFFLOAD_DEV_H_
34 #define _OFFLOAD_DEV_H_
35
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
53 #define TOENAMSIZ 16
54
55 /* belongs in linux/netdevice.h */
56 #define NETIF_F_TCPIP_OFFLOAD (1 << 15)
57
58 /* Get the toedev associated with a ifnet */
59 #define TOEDEV(netdev) (*(struct toedev **)&(netdev)->if_softc)
60
61 /* offload type ids */
62 enum {
63         TOE_ID_CHELSIO_T1 = 1,
64         TOE_ID_CHELSIO_T1C,
65         TOE_ID_CHELSIO_T2,
66         TOE_ID_CHELSIO_T3,
67         TOE_ID_CHELSIO_T3B,
68 };
69
70 struct offload_id {
71         unsigned int id;
72         unsigned long data;
73 };
74
75 struct ifnet;
76 struct rt_entry;
77 struct tom_info;
78 struct sysctl_oid;
79 struct socket;
80 struct mbuf;
81
82 enum toetype {
83         T3A = 0,
84         T3B
85 };
86
87 struct toedev {
88         char name[TOENAMSIZ];       /* TOE device name */
89         enum toetype type;
90         struct adapter *adapter;
91         unsigned int ttid;          /* TOE type id */
92         unsigned long flags;        /* device flags */
93         unsigned int mtu;           /* max size of TX offloaded data */
94         unsigned int nconn;         /* max # of offloaded connections */
95         struct ifnet *lldev;   /* LL device associated with TOE messages */
96         const struct tom_info *offload_mod; /* attached TCP offload module */
97         struct sysctl_oid *sysctl_root;    /* root of proc dir for this TOE */
98         TAILQ_ENTRY(toedev) ofld_entry;  /* for list linking */
99         int (*open)(struct toedev *dev);
100         int (*close)(struct toedev *dev);
101         int (*can_offload)(struct toedev *dev, struct socket *so);
102         int (*connect)(struct toedev *dev, struct socket *so,
103                        struct ifnet *egress_ifp);
104         int (*send)(struct toedev *dev, struct mbuf *m);
105         int (*recv)(struct toedev *dev, struct mbuf **m, int n);
106         int (*ctl)(struct toedev *dev, unsigned int req, void *data);
107         void (*neigh_update)(struct toedev *dev, struct rtentry *neigh);
108         void (*failover)(struct toedev *dev, struct ifnet *bond_ifp,
109                          struct ifnet *ndev, int event);
110         void *priv;                 /* driver private data */
111         void *l2opt;                /* optional layer 2 data */
112         void *l3opt;                /* optional layer 3 data */
113         void *l4opt;                /* optional layer 4 data */
114         void *ulp;                  /* ulp stuff */
115 };
116
117 struct tom_info {
118         int (*attach)(struct toedev *dev, const struct offload_id *entry);
119         int (*detach)(struct toedev *dev);
120         const char *name;
121         const struct offload_id *id_table;
122         TAILQ_ENTRY(tom_info) entry;
123 };
124
125 static inline void init_offload_dev(struct toedev *dev)
126 {
127
128 }
129
130 extern int register_tom(struct tom_info *t);
131 extern int unregister_tom(struct tom_info *t);
132 extern int register_toedev(struct toedev *dev, const char *name);
133 extern int unregister_toedev(struct toedev *dev);
134 extern int activate_offload(struct toedev *dev);
135 extern int toe_send(struct toedev *dev, struct mbuf *m);
136 extern struct ifnet *offload_get_phys_egress(struct ifnet *dev,
137                                                   struct socket *so,
138                                                   int context);
139
140 #if defined(CONFIG_TCP_OFFLOAD_MODULE)
141 static inline int toe_receive_mbuf(struct toedev *dev, struct mbuf **m,
142                                   int n)
143 {
144         return dev->recv(dev, m, n);
145 }
146
147 extern int  prepare_tcp_for_offload(void);
148 extern void restore_tcp_to_nonoffload(void);
149 #elif defined(CONFIG_TCP_OFFLOAD)
150 extern int toe_receive_mbuf(struct toedev *dev, struct mbuf **m, int n);
151 #endif
152
153 #if defined(CONFIG_TCP_OFFLOAD) || \
154     (defined(CONFIG_TCP_OFFLOAD_MODULE) && defined(MODULE))
155 extern void toe_neigh_update(struct rtentry *neigh);
156 extern void toe_failover(struct ifnet *bond_ifp,
157                          struct ifnet *fail_ifp, int event);
158 extern int toe_enslave(struct ifnet *bond_ifp,
159                        struct ifnet *slave_ifp);
160 #else
161 static inline void toe_neigh_update(struct ifnet *neigh) {}
162 static inline void toe_failover(struct ifnet *bond_ifp,
163                                 struct ifnet *fail_ifp, int event)
164 {}
165 static inline int toe_enslave(struct ifnet *bond_ifp,
166                               struct ifnet *slave_ifp)
167 {
168         return 0;
169 }
170 #endif /* CONFIG_TCP_OFFLOAD */
171
172 #endif /* _OFFLOAD_DEV_H_ */