1/************************************************************************** 2SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 4Copyright (c) 2007-2008, Chelsio Inc. 5All rights reserved. 6 7Redistribution and use in source and binary forms, with or without 8modification, 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 17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27POSSIBILITY OF SUCH DAMAGE. 28 29$FreeBSD$ 30 31***************************************************************************/ 32 33#ifndef _CXGB_OFFLOAD_H 34#define _CXGB_OFFLOAD_H 35 36#ifdef TCP_OFFLOAD 37enum { 38 ULD_TOM = 1, 39 ULD_IWARP = 2, 40}; 41 42struct adapter; 43struct uld_info { 44 SLIST_ENTRY(uld_info) link; 45 int refcount; 46 int uld_id; 47 int (*activate)(struct adapter *); 48 int (*deactivate)(struct adapter *); 49}; 50 51struct tom_tunables { 52 int sndbuf; 53 int ddp; 54 int indsz; 55 int ddp_thres; 56}; 57 58/* CPL message priority levels */ 59enum { 60 CPL_PRIORITY_DATA = 0, /* data messages */ 61 CPL_PRIORITY_CONTROL = 1 /* offload control messages */ 62}; 63 64#define S_HDR_NDESC 0 65#define M_HDR_NDESC 0xf 66#define V_HDR_NDESC(x) ((x) << S_HDR_NDESC) 67#define G_HDR_NDESC(x) (((x) >> S_HDR_NDESC) & M_HDR_NDESC) 68 69#define S_HDR_QSET 4 70#define M_HDR_QSET 0xf 71#define V_HDR_QSET(x) ((x) << S_HDR_QSET) 72#define G_HDR_QSET(x) (((x) >> S_HDR_QSET) & M_HDR_QSET) 73 74#define S_HDR_CTRL 8 75#define V_HDR_CTRL(x) ((x) << S_HDR_CTRL) 76#define F_HDR_CTRL V_HDR_CTRL(1U) 77 78#define S_HDR_DF 9 79#define V_HDR_DF(x) ((x) << S_HDR_DF) 80#define F_HDR_DF V_HDR_DF(1U) 81 82#define S_HDR_SGL 10 83#define V_HDR_SGL(x) ((x) << S_HDR_SGL) 84#define F_HDR_SGL V_HDR_SGL(1U) 85 86struct ofld_hdr 87{ 88 void *sgl; /* SGL, if F_HDR_SGL set in flags */ 89 int plen; /* amount of payload (in bytes) */ 90 int flags; 91}; 92 93/* 94 * Convenience function for fixed size CPLs that fit in 1 desc. 95 */ 96#define M_GETHDR_OFLD(qset, ctrl, cpl) \ 97 m_gethdr_ofld(qset, ctrl, sizeof(*cpl), (void **)&cpl) 98static inline struct mbuf * 99m_gethdr_ofld(int qset, int ctrl, int cpllen, void **cpl) 100{ 101 struct mbuf *m; 102 struct ofld_hdr *oh; 103 104 m = m_gethdr(M_NOWAIT, MT_DATA); 105 if (m == NULL) 106 return (NULL); 107 108 oh = mtod(m, struct ofld_hdr *); 109 oh->flags = V_HDR_NDESC(1) | V_HDR_QSET(qset) | V_HDR_CTRL(ctrl); 110 *cpl = (void *)(oh + 1); 111 m->m_pkthdr.len = m->m_len = sizeof(*oh) + cpllen; 112 113 return (m); 114} 115 116int t3_register_uld(struct uld_info *); 117int t3_unregister_uld(struct uld_info *); 118int t3_activate_uld(struct adapter *, int); 119int t3_deactivate_uld(struct adapter *, int); 120#endif /* TCP_OFFLOAD */ 121 122#define CXGB_UNIMPLEMENTED() \ 123 panic("IMPLEMENT: %s:%s:%d", __FUNCTION__, __FILE__, __LINE__) 124 125#endif 126