Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2006-2008 Chelsio, Inc. All rights reserved.
0003  *
0004  * This software is available to you under a choice of one of two
0005  * licenses.  You may choose to be licensed under the terms of the GNU
0006  * General Public License (GPL) Version 2, available from the file
0007  * COPYING in the main directory of this source tree, or the
0008  * OpenIB.org BSD license below:
0009  *
0010  *     Redistribution and use in source and binary forms, with or
0011  *     without modification, are permitted provided that the following
0012  *     conditions are met:
0013  *
0014  *      - Redistributions of source code must retain the above
0015  *        copyright notice, this list of conditions and the following
0016  *        disclaimer.
0017  *
0018  *      - Redistributions in binary form must reproduce the above
0019  *        copyright notice, this list of conditions and the following
0020  *        disclaimer in the documentation and/or other materials
0021  *        provided with the distribution.
0022  *
0023  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0024  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0025  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0026  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0027  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0028  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0029  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0030  * SOFTWARE.
0031  */
0032 #ifndef _CHELSIO_DEFS_H
0033 #define _CHELSIO_DEFS_H
0034 
0035 #include <linux/skbuff.h>
0036 #include <net/tcp.h>
0037 
0038 #include "t3cdev.h"
0039 
0040 #include "cxgb3_offload.h"
0041 
0042 #define VALIDATE_TID 1
0043 
0044 /*
0045  * Map an ATID or STID to their entries in the corresponding TID tables.
0046  */
0047 static inline union active_open_entry *atid2entry(const struct tid_info *t,
0048                           unsigned int atid)
0049 {
0050     return &t->atid_tab[atid - t->atid_base];
0051 }
0052 
0053 static inline union listen_entry *stid2entry(const struct tid_info *t,
0054                          unsigned int stid)
0055 {
0056     return &t->stid_tab[stid - t->stid_base];
0057 }
0058 
0059 /*
0060  * Find the connection corresponding to a TID.
0061  */
0062 static inline struct t3c_tid_entry *lookup_tid(const struct tid_info *t,
0063                            unsigned int tid)
0064 {
0065     struct t3c_tid_entry *t3c_tid = tid < t->ntids ?
0066         &(t->tid_tab[tid]) : NULL;
0067 
0068     return (t3c_tid && t3c_tid->client) ? t3c_tid : NULL;
0069 }
0070 
0071 /*
0072  * Find the connection corresponding to a server TID.
0073  */
0074 static inline struct t3c_tid_entry *lookup_stid(const struct tid_info *t,
0075                         unsigned int tid)
0076 {
0077     union listen_entry *e;
0078 
0079     if (tid < t->stid_base || tid >= t->stid_base + t->nstids)
0080         return NULL;
0081 
0082     e = stid2entry(t, tid);
0083     if ((void *)e->next >= (void *)t->tid_tab &&
0084         (void *)e->next < (void *)&t->atid_tab[t->natids])
0085         return NULL;
0086 
0087     return &e->t3c_tid;
0088 }
0089 
0090 /*
0091  * Find the connection corresponding to an active-open TID.
0092  */
0093 static inline struct t3c_tid_entry *lookup_atid(const struct tid_info *t,
0094                         unsigned int tid)
0095 {
0096     union active_open_entry *e;
0097 
0098     if (tid < t->atid_base || tid >= t->atid_base + t->natids)
0099         return NULL;
0100 
0101     e = atid2entry(t, tid);
0102     if ((void *)e->next >= (void *)t->tid_tab &&
0103         (void *)e->next < (void *)&t->atid_tab[t->natids])
0104         return NULL;
0105 
0106     return &e->t3c_tid;
0107 }
0108 
0109 int attach_t3cdev(struct t3cdev *dev);
0110 void detach_t3cdev(struct t3cdev *dev);
0111 #endif