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/dev/cxgb/cxgb_offload.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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 _CXGB_OFFLOAD_H
   34 #define _CXGB_OFFLOAD_H
   35 
   36 #ifdef CONFIG_DEFINED
   37 #include <common/cxgb_version.h>
   38 #include <cxgb_config.h>
   39 #include <cxgb_l2t.h>
   40 #include <common/cxgb_tcb.h>
   41 #else
   42 #include <dev/cxgb/common/cxgb_version.h>
   43 #include <dev/cxgb/cxgb_config.h>
   44 #include <dev/cxgb/cxgb_l2t.h>
   45 #include <dev/cxgb/common/cxgb_tcb.h>
   46 #endif
   47 
   48 struct adapter;
   49 struct cxgb_client;
   50 
   51 void cxgb_offload_init(void);
   52 void cxgb_offload_exit(void);
   53 
   54 void cxgb_adapter_ofld(struct adapter *adapter);
   55 void cxgb_adapter_unofld(struct adapter *adapter);
   56 int cxgb_offload_activate(struct adapter *adapter);
   57 void cxgb_offload_deactivate(struct adapter *adapter);
   58 int cxgb_ofld_recv(struct toedev *dev, struct mbuf **m, int n);
   59 
   60 void cxgb_set_dummy_ops(struct toedev *dev);
   61 
   62 
   63 /*
   64  * Client registration.  Users of T3 driver must register themselves.
   65  * The T3 driver will call the add function of every client for each T3
   66  * adapter activated, passing up the toedev ptr.  Each client fills out an
   67  * array of callback functions to process CPL messages.
   68  */
   69 
   70 void cxgb_register_client(struct cxgb_client *client);
   71 void cxgb_unregister_client(struct cxgb_client *client);
   72 void cxgb_add_clients(struct toedev *tdev);
   73 void cxgb_remove_clients(struct toedev *tdev);
   74 
   75 typedef int (*cxgb_cpl_handler_func)(struct toedev *dev,
   76                                       struct mbuf *m, void *ctx);
   77 
   78 struct cxgb_client {
   79         char                    *name;
   80         void                    (*add) (struct toedev *);
   81         void                    (*remove) (struct toedev *);
   82         cxgb_cpl_handler_func   *handlers;
   83         int                     (*redirect)(void *ctx, struct rtentry *old,
   84                                             struct rtentry *new,
   85                                             struct l2t_entry *l2t);
   86         TAILQ_ENTRY(cxgb_client)         client_entry;
   87 };
   88 
   89 /*
   90  * TID allocation services.
   91  */
   92 int cxgb_alloc_atid(struct toedev *dev, struct cxgb_client *client,
   93                      void *ctx);
   94 int cxgb_alloc_stid(struct toedev *dev, struct cxgb_client *client,
   95                      void *ctx);
   96 void *cxgb_free_atid(struct toedev *dev, int atid);
   97 void cxgb_free_stid(struct toedev *dev, int stid);
   98 void cxgb_insert_tid(struct toedev *dev, struct cxgb_client *client,
   99                       void *ctx,
  100         unsigned int tid);
  101 void cxgb_queue_tid_release(struct toedev *dev, unsigned int tid);
  102 void cxgb_remove_tid(struct toedev *dev, void *ctx, unsigned int tid);
  103 
  104 struct toe_tid_entry {
  105         struct cxgb_client      *client;
  106         void                    *ctx;
  107 };
  108 
  109 /* CPL message priority levels */
  110 enum {
  111         CPL_PRIORITY_DATA = 0,     /* data messages */
  112         CPL_PRIORITY_SETUP = 1,    /* connection setup messages */
  113         CPL_PRIORITY_TEARDOWN = 0, /* connection teardown messages */
  114         CPL_PRIORITY_LISTEN = 1,   /* listen start/stop messages */
  115         CPL_PRIORITY_ACK = 1,      /* RX ACK messages */
  116         CPL_PRIORITY_CONTROL = 1   /* offload control messages */
  117 };
  118 
  119 /* Flags for return value of CPL message handlers */
  120 enum {
  121         CPL_RET_BUF_DONE = 1,   // buffer processing done, buffer may be freed
  122         CPL_RET_BAD_MSG = 2,    // bad CPL message (e.g., unknown opcode)
  123         CPL_RET_UNKNOWN_TID = 4 // unexpected unknown TID
  124 };
  125 
  126 typedef int (*cpl_handler_func)(struct toedev *dev, struct mbuf *m);
  127 
  128 /*
  129  * Returns a pointer to the first byte of the CPL header in an sk_buff that
  130  * contains a CPL message.
  131  */
  132 static inline void *cplhdr(struct mbuf *m)
  133 {
  134         return mtod(m, uint8_t *);
  135 }
  136 
  137 void t3_register_cpl_handler(unsigned int opcode, cpl_handler_func h);
  138 
  139 union listen_entry {
  140         struct toe_tid_entry toe_tid;
  141         union listen_entry *next;
  142 };
  143 
  144 union active_open_entry {
  145         struct toe_tid_entry toe_tid;
  146         union active_open_entry *next;
  147 };
  148 
  149 /*
  150  * Holds the size, base address, free list start, etc of the TID, server TID,
  151  * and active-open TID tables for a offload device.
  152  * The tables themselves are allocated dynamically.
  153  */
  154 struct tid_info {
  155         struct toe_tid_entry *tid_tab;
  156         unsigned int ntids;
  157         volatile unsigned int tids_in_use;
  158 
  159         union listen_entry *stid_tab;
  160         unsigned int nstids;
  161         unsigned int stid_base;
  162 
  163         union active_open_entry *atid_tab;
  164         unsigned int natids;
  165         unsigned int atid_base;
  166 
  167         /*
  168          * The following members are accessed R/W so we put them in their own
  169          * cache lines.
  170          *
  171          * XXX We could combine the atid fields above with the lock here since
  172          * atids are use once (unlike other tids).  OTOH the above fields are
  173          * usually in cache due to tid_tab.
  174          */
  175         struct mtx atid_lock /* ____cacheline_aligned_in_smp */;
  176         union active_open_entry *afree;
  177         unsigned int atids_in_use;
  178 
  179         struct mtx stid_lock /*____cacheline_aligned */;
  180         union listen_entry *sfree;
  181         unsigned int stids_in_use;
  182 };
  183 
  184 struct toe_data {
  185 #ifdef notyet   
  186         struct list_head list_node;
  187 #endif  
  188         struct toedev *dev;
  189         unsigned int tx_max_chunk;  /* max payload for TX_DATA */
  190         unsigned int max_wrs;       /* max in-flight WRs per connection */
  191         unsigned int nmtus;
  192         const unsigned short *mtus;
  193         struct tid_info tid_maps;
  194 
  195         struct toe_tid_entry *tid_release_list;
  196         struct mtx tid_release_lock;
  197         struct task tid_release_task;
  198 };
  199 
  200 /*
  201  * toedev -> toe_data accessor
  202  */
  203 #define TOE_DATA(dev) (*(struct toe_data **)&(dev)->l4opt)
  204 
  205 /*
  206  * Map an ATID or STID to their entries in the corresponding TID tables.
  207  */
  208 static inline union active_open_entry *atid2entry(const struct tid_info *t,
  209                                                   unsigned int atid)
  210 {
  211         return &t->atid_tab[atid - t->atid_base];
  212 }
  213 
  214 
  215 static inline union listen_entry *stid2entry(const struct tid_info *t,
  216                                              unsigned int stid)
  217 {
  218         return &t->stid_tab[stid - t->stid_base];
  219 }
  220 
  221 /*
  222  * Find the connection corresponding to a TID.
  223  */
  224 static inline struct toe_tid_entry *lookup_tid(const struct tid_info *t,
  225                                                unsigned int tid)
  226 {
  227         return tid < t->ntids ? &(t->tid_tab[tid]) : NULL;
  228 }
  229 
  230 /*
  231  * Find the connection corresponding to a server TID.
  232  */
  233 static inline struct toe_tid_entry *lookup_stid(const struct tid_info *t,
  234                                                 unsigned int tid)
  235 {
  236         if (tid < t->stid_base || tid >= t->stid_base + t->nstids)
  237                 return NULL;
  238         return &(stid2entry(t, tid)->toe_tid);
  239 }
  240 
  241 /*
  242  * Find the connection corresponding to an active-open TID.
  243  */
  244 static inline struct toe_tid_entry *lookup_atid(const struct tid_info *t,
  245                                                 unsigned int tid)
  246 {
  247         if (tid < t->atid_base || tid >= t->atid_base + t->natids)
  248                 return NULL;
  249         return &(atid2entry(t, tid)->toe_tid);
  250 }
  251 
  252 void *cxgb_alloc_mem(unsigned long size);
  253 void cxgb_free_mem(void *addr);
  254 void cxgb_neigh_update(struct rtentry *rt);
  255 void cxgb_redirect(struct rtentry *old, struct rtentry *new);
  256 int process_rx(struct toedev *dev, struct mbuf **m, int n);
  257 int attach_toedev(struct toedev *dev);
  258 void detach_toedev(struct toedev *dev);
  259 
  260 
  261 #endif

Cache object: b571dd50e256ac8be062df29c1ff85f7


[ 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.