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