The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netinet/tcp_offload.c

Version: -  FREEBSD  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    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 
   28 #include <sys/cdefs.h>
   29 __FBSDID("$FreeBSD: releng/8.2/sys/netinet/tcp_offload.c 199583 2009-11-20 15:27:52Z jhb $");
   30 
   31 #include <sys/param.h>
   32 #include <sys/systm.h>
   33 #include <sys/types.h>
   34 #include <sys/malloc.h>
   35 #include <sys/kernel.h>
   36 #include <sys/sysctl.h>
   37 #include <sys/mbuf.h>
   38 #include <sys/socket.h>
   39 #include <sys/socketvar.h>
   40 
   41 #include <net/if.h>
   42 #include <net/if_types.h>
   43 #include <net/if_var.h>
   44 #include <net/route.h>
   45 #include <net/vnet.h>
   46 
   47 #include <netinet/in.h>
   48 #include <netinet/in_systm.h>
   49 #include <netinet/in_pcb.h>
   50 #include <netinet/tcp.h>
   51 #include <netinet/tcp_var.h>
   52 #include <netinet/tcp_offload.h>
   53 #include <netinet/toedev.h>
   54 
   55 uint32_t toedev_registration_count;
   56 
   57 int
   58 tcp_offload_connect(struct socket *so, struct sockaddr *nam)
   59 {
   60         struct ifnet *ifp;
   61         struct toedev *tdev;
   62         struct rtentry *rt;
   63         int error;
   64 
   65         if (toedev_registration_count == 0)
   66                 return (EINVAL);
   67         
   68         /*
   69          * Look up the route used for the connection to 
   70          * determine if it uses an interface capable of
   71          * offloading the connection.
   72          */
   73         rt = rtalloc1(nam, 0 /*report*/, 0 /*ignflags*/);
   74         if (rt) 
   75                 RT_UNLOCK(rt);
   76         else 
   77                 return (EHOSTUNREACH);
   78 
   79         ifp = rt->rt_ifp;
   80         if ((ifp->if_capenable & IFCAP_TOE) == 0) {
   81                 error = EINVAL;
   82                 goto fail;
   83         }
   84         
   85         tdev = TOEDEV(ifp);
   86         if (tdev == NULL) {
   87                 error = EPERM;
   88                 goto fail;
   89         }
   90         
   91         if (tdev->tod_can_offload(tdev, so) == 0) {
   92                 error = EPERM;
   93                 goto fail;
   94         }
   95         
   96         return (tdev->tod_connect(tdev, so, rt, nam));
   97 fail:
   98         RTFREE(rt);
   99         return (error);
  100 }
  101 
  102 
  103 /*
  104  * This file contains code as a short-term staging area before it is moved in 
  105  * to sys/netinet/tcp_offload.c
  106  */
  107 
  108 void
  109 tcp_offload_twstart(struct tcpcb *tp)
  110 {
  111 
  112         INP_INFO_WLOCK(&V_tcbinfo);
  113         INP_WLOCK(tp->t_inpcb);
  114         tcp_twstart(tp);
  115         INP_INFO_WUNLOCK(&V_tcbinfo);
  116 }
  117 
  118 struct tcpcb *
  119 tcp_offload_close(struct tcpcb *tp)
  120 {
  121 
  122         INP_INFO_WLOCK(&V_tcbinfo);
  123         INP_WLOCK(tp->t_inpcb);
  124         tp = tcp_close(tp);
  125         INP_INFO_WUNLOCK(&V_tcbinfo);
  126         if (tp)
  127                 INP_WUNLOCK(tp->t_inpcb);
  128 
  129         return (tp);
  130 }
  131 
  132 struct tcpcb *
  133 tcp_offload_drop(struct tcpcb *tp, int error)
  134 {
  135 
  136         INP_INFO_WLOCK(&V_tcbinfo);
  137         INP_WLOCK(tp->t_inpcb);
  138         tp = tcp_drop(tp, error);
  139         INP_INFO_WUNLOCK(&V_tcbinfo);
  140         if (tp)
  141                 INP_WUNLOCK(tp->t_inpcb);
  142 
  143         return (tp);
  144 }
  145 

Cache object: 445e5b0c9cc0fd9f4e4b14f4875aff75


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.