1191783Srmacklem/*- 2191783Srmacklem * Copyright (c) 1989, 1993 3191783Srmacklem * The Regents of the University of California. All rights reserved. 4191783Srmacklem * 5191783Srmacklem * This code is derived from software contributed to Berkeley by 6191783Srmacklem * Rick Macklem at The University of Guelph. 7191783Srmacklem * 8191783Srmacklem * Redistribution and use in source and binary forms, with or without 9191783Srmacklem * modification, are permitted provided that the following conditions 10191783Srmacklem * are met: 11191783Srmacklem * 1. Redistributions of source code must retain the above copyright 12191783Srmacklem * notice, this list of conditions and the following disclaimer. 13191783Srmacklem * 2. Redistributions in binary form must reproduce the above copyright 14191783Srmacklem * notice, this list of conditions and the following disclaimer in the 15191783Srmacklem * documentation and/or other materials provided with the distribution. 16191783Srmacklem * 4. Neither the name of the University nor the names of its contributors 17191783Srmacklem * may be used to endorse or promote products derived from this software 18191783Srmacklem * without specific prior written permission. 19191783Srmacklem * 20191783Srmacklem * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21191783Srmacklem * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22191783Srmacklem * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23191783Srmacklem * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24191783Srmacklem * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25191783Srmacklem * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26191783Srmacklem * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27191783Srmacklem * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28191783Srmacklem * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29191783Srmacklem * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30191783Srmacklem * SUCH DAMAGE. 31191783Srmacklem * 32191783Srmacklem * $FreeBSD$ 33191783Srmacklem */ 34191783Srmacklem 35191783Srmacklem#ifndef _NFS_NFSRVCACHE_H_ 36191783Srmacklem#define _NFS_NFSRVCACHE_H_ 37191783Srmacklem 38191783Srmacklem/* 39191783Srmacklem * Definitions for the server recent request cache 40191783Srmacklem */ 41191783Srmacklem#define NFSRVCACHE_MAX_SIZE 2048 42191783Srmacklem#define NFSRVCACHE_MIN_SIZE 64 43191783Srmacklem 44254337Srmacklem#define NFSRVCACHE_HASHSIZE 500 45191783Srmacklem 46254337Srmacklem/* Cache table entry. */ 47191783Srmacklemstruct nfsrvcache { 48191783Srmacklem LIST_ENTRY(nfsrvcache) rc_hash; /* Hash chain */ 49191783Srmacklem TAILQ_ENTRY(nfsrvcache) rc_lru; /* UDP lru chain */ 50191783Srmacklem u_int32_t rc_xid; /* rpc id number */ 51191783Srmacklem time_t rc_timestamp; /* Time done */ 52191783Srmacklem union { 53191783Srmacklem mbuf_t repmb; /* Reply mbuf list OR */ 54191783Srmacklem int repstat; /* Reply status */ 55191783Srmacklem } rc_un; 56191783Srmacklem union { 57191783Srmacklem struct { 58191783Srmacklem union nethostaddr haddr; /* Host address */ 59191783Srmacklem } udp; 60191783Srmacklem struct { 61191783Srmacklem u_int64_t sockref; 62191783Srmacklem u_int32_t len; 63191783Srmacklem u_int32_t tcpseq; 64191783Srmacklem int16_t refcnt; 65191783Srmacklem u_int16_t cksum; 66191783Srmacklem time_t cachetime; 67191783Srmacklem } ot; 68191783Srmacklem } rc_un2; 69191783Srmacklem u_int16_t rc_proc; /* rpc proc number */ 70191783Srmacklem u_int16_t rc_flag; /* Flag bits */ 71191783Srmacklem}; 72191783Srmacklem 73191783Srmacklem#define rc_reply rc_un.repmb 74191783Srmacklem#define rc_status rc_un.repstat 75191783Srmacklem#define rc_inet rc_un2.udp.haddr.had_inet.s_addr 76191783Srmacklem#define rc_inet6 rc_un2.udp.haddr.had_inet6 77191783Srmacklem#define rc_haddr rc_un2.udp.haddr 78191783Srmacklem#define rc_sockref rc_un2.ot.sockref 79191783Srmacklem#define rc_tcpseq rc_un2.ot.tcpseq 80191783Srmacklem#define rc_refcnt rc_un2.ot.refcnt 81191783Srmacklem#define rc_reqlen rc_un2.ot.len 82191783Srmacklem#define rc_cksum rc_un2.ot.cksum 83191783Srmacklem#define rc_cachetime rc_un2.ot.cachetime 84191783Srmacklem 85191783Srmacklem/* Return values */ 86191783Srmacklem#define RC_DROPIT 0 87191783Srmacklem#define RC_REPLY 1 88191783Srmacklem#define RC_DOIT 2 89191783Srmacklem 90191783Srmacklem/* Flag bits */ 91191783Srmacklem#define RC_LOCKED 0x0001 92191783Srmacklem#define RC_WANTED 0x0002 93191783Srmacklem#define RC_REPSTATUS 0x0004 94191783Srmacklem#define RC_REPMBUF 0x0008 95191783Srmacklem#define RC_UDP 0x0010 96191783Srmacklem#define RC_INETIPV6 0x0020 97191783Srmacklem#define RC_INPROG 0x0040 98191783Srmacklem#define RC_TCPSEQ 0x0080 99191783Srmacklem#define RC_NFSV2 0x0100 100191783Srmacklem#define RC_NFSV3 0x0200 101191783Srmacklem#define RC_NFSV4 0x0400 102191783Srmacklem#define RC_NFSVERS (RC_NFSV2 | RC_NFSV3 | RC_NFSV4) 103191783Srmacklem#define RC_REFCNT 0x0800 104191783Srmacklem#define RC_SAMETCPCONN 0x1000 105191783Srmacklem 106191783SrmacklemLIST_HEAD(nfsrvhashhead, nfsrvcache); 107191783Srmacklem 108254337Srmacklem/* The fine-grained locked cache hash table for TCP. */ 109254337Srmacklemstruct nfsrchash_bucket { 110254337Srmacklem struct mtx mtx; 111254337Srmacklem char lock_name[16]; 112254337Srmacklem struct nfsrvhashhead tbl; 113254337Srmacklem}; 114254337Srmacklem 115191783Srmacklem#endif /* _NFS_NFSRVCACHE_H_ */ 116