2 /**************************************************************************
4 Copyright (c) 2007, Chelsio Inc.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
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.
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.
31 ***************************************************************************/
33 #ifndef _OFFLOAD_DEV_H_
34 #define _OFFLOAD_DEV_H_
37 /* Parameter values for offload_get_phys_egress() */
43 /* Parameter values for toe_failover() */
55 /* belongs in linux/netdevice.h */
56 #define NETIF_F_TCPIP_OFFLOAD (1 << 15)
58 /* Get the toedev associated with a ifnet */
59 #define TOEDEV(netdev) (*(struct toedev **)&(netdev)->if_softc)
61 /* offload type ids */
63 TOE_ID_CHELSIO_T1 = 1,
88 char name[TOENAMSIZ]; /* TOE device name */
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 */
118 int (*attach)(struct toedev *dev, const struct offload_id *entry);
119 int (*detach)(struct toedev *dev);
121 const struct offload_id *id_table;
122 TAILQ_ENTRY(tom_info) entry;
125 static inline void init_offload_dev(struct toedev *dev)
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,
140 #if defined(CONFIG_TCP_OFFLOAD_MODULE)
141 static inline int toe_receive_mbuf(struct toedev *dev, struct mbuf **m,
144 return dev->recv(dev, m, n);
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);
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);
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)
165 static inline int toe_enslave(struct ifnet *bond_ifp,
166 struct ifnet *slave_ifp)
170 #endif /* CONFIG_TCP_OFFLOAD */
172 #endif /* _OFFLOAD_DEV_H_ */