162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright (c) 2006-2008 Chelsio, Inc. All rights reserved. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * This software is available to you under a choice of one of two 562306a36Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 662306a36Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 762306a36Sopenharmony_ci * COPYING in the main directory of this source tree, or the 862306a36Sopenharmony_ci * OpenIB.org BSD license below: 962306a36Sopenharmony_ci * 1062306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or 1162306a36Sopenharmony_ci * without modification, are permitted provided that the following 1262306a36Sopenharmony_ci * conditions are met: 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * - Redistributions of source code must retain the above 1562306a36Sopenharmony_ci * copyright notice, this list of conditions and the following 1662306a36Sopenharmony_ci * disclaimer. 1762306a36Sopenharmony_ci * 1862306a36Sopenharmony_ci * - Redistributions in binary form must reproduce the above 1962306a36Sopenharmony_ci * copyright notice, this list of conditions and the following 2062306a36Sopenharmony_ci * disclaimer in the documentation and/or other materials 2162306a36Sopenharmony_ci * provided with the distribution. 2262306a36Sopenharmony_ci * 2362306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2462306a36Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2562306a36Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2662306a36Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2762306a36Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 2862306a36Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2962306a36Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3062306a36Sopenharmony_ci * SOFTWARE. 3162306a36Sopenharmony_ci */ 3262306a36Sopenharmony_ci#ifndef _CHELSIO_DEFS_H 3362306a36Sopenharmony_ci#define _CHELSIO_DEFS_H 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#include <linux/skbuff.h> 3662306a36Sopenharmony_ci#include <net/tcp.h> 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#include "t3cdev.h" 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci#include "cxgb3_offload.h" 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define VALIDATE_TID 1 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci/* 4562306a36Sopenharmony_ci * Map an ATID or STID to their entries in the corresponding TID tables. 4662306a36Sopenharmony_ci */ 4762306a36Sopenharmony_cistatic inline union active_open_entry *atid2entry(const struct tid_info *t, 4862306a36Sopenharmony_ci unsigned int atid) 4962306a36Sopenharmony_ci{ 5062306a36Sopenharmony_ci return &t->atid_tab[atid - t->atid_base]; 5162306a36Sopenharmony_ci} 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_cistatic inline union listen_entry *stid2entry(const struct tid_info *t, 5462306a36Sopenharmony_ci unsigned int stid) 5562306a36Sopenharmony_ci{ 5662306a36Sopenharmony_ci return &t->stid_tab[stid - t->stid_base]; 5762306a36Sopenharmony_ci} 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci/* 6062306a36Sopenharmony_ci * Find the connection corresponding to a TID. 6162306a36Sopenharmony_ci */ 6262306a36Sopenharmony_cistatic inline struct t3c_tid_entry *lookup_tid(const struct tid_info *t, 6362306a36Sopenharmony_ci unsigned int tid) 6462306a36Sopenharmony_ci{ 6562306a36Sopenharmony_ci struct t3c_tid_entry *t3c_tid = tid < t->ntids ? 6662306a36Sopenharmony_ci &(t->tid_tab[tid]) : NULL; 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci return (t3c_tid && t3c_tid->client) ? t3c_tid : NULL; 6962306a36Sopenharmony_ci} 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci/* 7262306a36Sopenharmony_ci * Find the connection corresponding to a server TID. 7362306a36Sopenharmony_ci */ 7462306a36Sopenharmony_cistatic inline struct t3c_tid_entry *lookup_stid(const struct tid_info *t, 7562306a36Sopenharmony_ci unsigned int tid) 7662306a36Sopenharmony_ci{ 7762306a36Sopenharmony_ci union listen_entry *e; 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci if (tid < t->stid_base || tid >= t->stid_base + t->nstids) 8062306a36Sopenharmony_ci return NULL; 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci e = stid2entry(t, tid); 8362306a36Sopenharmony_ci if ((void *)e->next >= (void *)t->tid_tab && 8462306a36Sopenharmony_ci (void *)e->next < (void *)&t->atid_tab[t->natids]) 8562306a36Sopenharmony_ci return NULL; 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci return &e->t3c_tid; 8862306a36Sopenharmony_ci} 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci/* 9162306a36Sopenharmony_ci * Find the connection corresponding to an active-open TID. 9262306a36Sopenharmony_ci */ 9362306a36Sopenharmony_cistatic inline struct t3c_tid_entry *lookup_atid(const struct tid_info *t, 9462306a36Sopenharmony_ci unsigned int tid) 9562306a36Sopenharmony_ci{ 9662306a36Sopenharmony_ci union active_open_entry *e; 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci if (tid < t->atid_base || tid >= t->atid_base + t->natids) 9962306a36Sopenharmony_ci return NULL; 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci e = atid2entry(t, tid); 10262306a36Sopenharmony_ci if ((void *)e->next >= (void *)t->tid_tab && 10362306a36Sopenharmony_ci (void *)e->next < (void *)&t->atid_tab[t->natids]) 10462306a36Sopenharmony_ci return NULL; 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci return &e->t3c_tid; 10762306a36Sopenharmony_ci} 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ciint attach_t3cdev(struct t3cdev *dev); 11062306a36Sopenharmony_civoid detach_t3cdev(struct t3cdev *dev); 11162306a36Sopenharmony_ci#endif 112