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.
29 $FreeBSD: src/sys/dev/cxgb/ulp/toecore/toedev.h,v 1.1 2007/05/25 16:17:59 kmacy Exp $
31 ***************************************************************************/
33 #ifndef _OFFLOAD_DEV_H_
34 #define _OFFLOAD_DEV_H_
36 #include <net/route.h>
38 /* Parameter values for offload_get_phys_egress() */
44 /* Parameter values for toe_failover() */
56 /* belongs in linux/netdevice.h */
57 #define NETIF_F_TCPIP_OFFLOAD (1 << 15)
59 /* Get the toedev associated with a ifnet */
60 #define TOEDEV(netdev) (*(struct toedev **)&(netdev)->if_softc)
62 /* offload type ids */
64 TOE_ID_CHELSIO_T1
= 1,
89 char name
[TOENAMSIZ
]; /* TOE device name */
91 struct adapter
*adapter
;
92 unsigned int ttid
; /* TOE type id */
93 unsigned long flags
; /* device flags */
94 unsigned int mtu
; /* max size of TX offloaded data */
95 unsigned int nconn
; /* max # of offloaded connections */
96 struct ifnet
*lldev
; /* LL device associated with TOE messages */
97 const struct tom_info
*offload_mod
; /* attached TCP offload module */
98 struct sysctl_oid
*sysctl_root
; /* root of proc dir for this TOE */
99 TAILQ_ENTRY(toedev
) ofld_entry
; /* for list linking */
100 int (*open
)(struct toedev
*dev
);
101 int (*close
)(struct toedev
*dev
);
102 int (*can_offload
)(struct toedev
*dev
, struct socket
*so
);
103 int (*connect
)(struct toedev
*dev
, struct socket
*so
,
104 struct ifnet
*egress_ifp
);
105 int (*send
)(struct toedev
*dev
, struct mbuf
*m
);
106 int (*recv
)(struct toedev
*dev
, struct mbuf
**m
, int n
);
107 int (*ctl
)(struct toedev
*dev
, unsigned int req
, void *data
);
108 void (*neigh_update
)(struct toedev
*dev
, struct rtentry
*neigh
);
109 void (*failover
)(struct toedev
*dev
, struct ifnet
*bond_ifp
,
110 struct ifnet
*ndev
, int event
);
111 void *priv
; /* driver private data */
112 void *l2opt
; /* optional layer 2 data */
113 void *l3opt
; /* optional layer 3 data */
114 void *l4opt
; /* optional layer 4 data */
115 void *ulp
; /* ulp stuff */
119 int (*attach
)(struct toedev
*dev
, const struct offload_id
*entry
);
120 int (*detach
)(struct toedev
*dev
);
122 const struct offload_id
*id_table
;
123 TAILQ_ENTRY(tom_info
) entry
;
126 static inline void init_offload_dev(struct toedev
*dev
)
131 extern int register_tom(struct tom_info
*t
);
132 extern int unregister_tom(struct tom_info
*t
);
133 extern int register_toedev(struct toedev
*dev
, const char *name
);
134 extern int unregister_toedev(struct toedev
*dev
);
135 extern int activate_offload(struct toedev
*dev
);
136 extern int toe_send(struct toedev
*dev
, struct mbuf
*m
);
137 extern struct ifnet
*offload_get_phys_egress(struct ifnet
*dev
,
141 #if defined(CONFIG_TCP_OFFLOAD_MODULE)
142 static inline int toe_receive_mbuf(struct toedev
*dev
, struct mbuf
**m
,
145 return dev
->recv(dev
, m
, n
);
148 extern int prepare_tcp_for_offload(void);
149 extern void restore_tcp_to_nonoffload(void);
150 #elif defined(CONFIG_TCP_OFFLOAD)
151 extern int toe_receive_mbuf(struct toedev
*dev
, struct mbuf
**m
, int n
);
154 #if defined(CONFIG_TCP_OFFLOAD) || \
155 (defined(CONFIG_TCP_OFFLOAD_MODULE) && defined(MODULE))
156 extern void toe_neigh_update(struct rtentry
*neigh
);
157 extern void toe_failover(struct ifnet
*bond_ifp
,
158 struct ifnet
*fail_ifp
, int event
);
159 extern int toe_enslave(struct ifnet
*bond_ifp
,
160 struct ifnet
*slave_ifp
);
162 static inline void toe_neigh_update(struct ifnet
*neigh
) {}
163 static inline void toe_failover(struct ifnet
*bond_ifp
,
164 struct ifnet
*fail_ifp
, int event
)
166 static inline int toe_enslave(struct ifnet
*bond_ifp
,
167 struct ifnet
*slave_ifp
)
171 #endif /* CONFIG_TCP_OFFLOAD */
173 #endif /* _OFFLOAD_DEV_H_ */