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: releng/10.2/sys/fs/nfs/nfsrvcache.h 269655 2014-08-07 03:50:30Z kib $ 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 */ 49261055Smav LIST_ENTRY(nfsrvcache) rc_ahash; /* ACK hash chain */ 50191783Srmacklem TAILQ_ENTRY(nfsrvcache) rc_lru; /* UDP lru chain */ 51191783Srmacklem u_int32_t rc_xid; /* rpc id number */ 52191783Srmacklem time_t rc_timestamp; /* Time done */ 53191783Srmacklem union { 54191783Srmacklem mbuf_t repmb; /* Reply mbuf list OR */ 55191783Srmacklem int repstat; /* Reply status */ 56191783Srmacklem } rc_un; 57191783Srmacklem union { 58191783Srmacklem struct { 59191783Srmacklem union nethostaddr haddr; /* Host address */ 60191783Srmacklem } udp; 61191783Srmacklem struct { 62191783Srmacklem u_int64_t sockref; 63191783Srmacklem u_int32_t len; 64191783Srmacklem u_int32_t tcpseq; 65191783Srmacklem int16_t refcnt; 66191783Srmacklem u_int16_t cksum; 67191783Srmacklem time_t cachetime; 68261055Smav int acked; 69191783Srmacklem } ot; 70191783Srmacklem } rc_un2; 71191783Srmacklem u_int16_t rc_proc; /* rpc proc number */ 72191783Srmacklem u_int16_t rc_flag; /* Flag bits */ 73191783Srmacklem}; 74191783Srmacklem 75191783Srmacklem#define rc_reply rc_un.repmb 76191783Srmacklem#define rc_status rc_un.repstat 77191783Srmacklem#define rc_inet rc_un2.udp.haddr.had_inet.s_addr 78191783Srmacklem#define rc_inet6 rc_un2.udp.haddr.had_inet6 79191783Srmacklem#define rc_haddr rc_un2.udp.haddr 80191783Srmacklem#define rc_sockref rc_un2.ot.sockref 81191783Srmacklem#define rc_tcpseq rc_un2.ot.tcpseq 82191783Srmacklem#define rc_refcnt rc_un2.ot.refcnt 83191783Srmacklem#define rc_reqlen rc_un2.ot.len 84191783Srmacklem#define rc_cksum rc_un2.ot.cksum 85191783Srmacklem#define rc_cachetime rc_un2.ot.cachetime 86261055Smav#define rc_acked rc_un2.ot.acked 87191783Srmacklem 88261055Smav/* TCP ACK values */ 89261055Smav#define RC_NO_SEQ 0 90261055Smav#define RC_NO_ACK 1 91261055Smav#define RC_ACK 2 92261055Smav#define RC_NACK 3 93261055Smav 94191783Srmacklem/* Return values */ 95191783Srmacklem#define RC_DROPIT 0 96191783Srmacklem#define RC_REPLY 1 97191783Srmacklem#define RC_DOIT 2 98191783Srmacklem 99191783Srmacklem/* Flag bits */ 100191783Srmacklem#define RC_LOCKED 0x0001 101191783Srmacklem#define RC_WANTED 0x0002 102191783Srmacklem#define RC_REPSTATUS 0x0004 103191783Srmacklem#define RC_REPMBUF 0x0008 104191783Srmacklem#define RC_UDP 0x0010 105191783Srmacklem#define RC_INETIPV6 0x0020 106191783Srmacklem#define RC_INPROG 0x0040 107191783Srmacklem#define RC_NFSV2 0x0100 108191783Srmacklem#define RC_NFSV3 0x0200 109191783Srmacklem#define RC_NFSV4 0x0400 110191783Srmacklem#define RC_NFSVERS (RC_NFSV2 | RC_NFSV3 | RC_NFSV4) 111191783Srmacklem#define RC_REFCNT 0x0800 112191783Srmacklem#define RC_SAMETCPCONN 0x1000 113191783Srmacklem 114191783SrmacklemLIST_HEAD(nfsrvhashhead, nfsrvcache); 115191783Srmacklem 116254337Srmacklem/* The fine-grained locked cache hash table for TCP. */ 117254337Srmacklemstruct nfsrchash_bucket { 118254337Srmacklem struct mtx mtx; 119254337Srmacklem struct nfsrvhashhead tbl; 120254337Srmacklem}; 121254337Srmacklem 122191783Srmacklem#endif /* _NFS_NFSRVCACHE_H_ */ 123