]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.h
remove unneeded declarations
[FreeBSD/FreeBSD.git] / sys / dev / cxgb / ulp / tom / cxgb_tcp_offload.h
1 /* $FreeBSD$ */
2
3 #ifndef CXGB_TCP_OFFLOAD_H_
4 #define CXGB_TCP_OFFLOAD_H_
5
6 struct socket;
7 struct sockbuf;
8
9 void sockbuf_lock(struct sockbuf *);
10 void sockbuf_lock_assert(struct sockbuf *);
11 void sockbuf_unlock(struct sockbuf *);
12 int  sockbuf_sbspace(struct sockbuf *);
13
14
15 #ifndef _SYS_SOCKETVAR_H_
16 #include <sys/selinfo.h>
17 #include <sys/sx.h>
18
19 /*
20  * Constants for sb_flags field of struct sockbuf.
21  */
22 #define SB_MAX          (256*1024)      /* default for max chars in sockbuf */
23 /*
24  * Constants for sb_flags field of struct sockbuf.
25  */
26 #define SB_WAIT         0x04            /* someone is waiting for data/space */
27 #define SB_SEL          0x08            /* someone is selecting */
28 #define SB_ASYNC        0x10            /* ASYNC I/O, need signals */
29 #define SB_UPCALL       0x20            /* someone wants an upcall */
30 #define SB_NOINTR       0x40            /* operations not interruptible */
31 #define SB_AIO          0x80            /* AIO operations queued */
32 #define SB_KNOTE        0x100           /* kernel note attached */
33 #define SB_NOCOALESCE   0x200           /* don't coalesce new data into existing mbufs */
34 #define SB_IN_TOE       0x400           /* socket buffer is in the middle of an operation */
35 #define SB_AUTOSIZE     0x800           /* automatically size socket buffer */
36
37
38 struct sockbuf {
39         struct  selinfo sb_sel; /* process selecting read/write */
40         struct  mtx sb_mtx;     /* sockbuf lock */
41         struct  sx sb_sx;       /* prevent I/O interlacing */
42         short   sb_state;       /* (c/d) socket state on sockbuf */
43 #define sb_startzero    sb_mb
44         struct  mbuf *sb_mb;    /* (c/d) the mbuf chain */
45         struct  mbuf *sb_mbtail; /* (c/d) the last mbuf in the chain */
46         struct  mbuf *sb_lastrecord;    /* (c/d) first mbuf of last
47                                                  * record in socket buffer */
48         struct  mbuf *sb_sndptr; /* (c/d) pointer into mbuf chain */
49         u_int   sb_sndptroff;   /* (c/d) byte offset of ptr into chain */
50         u_int   sb_cc;          /* (c/d) actual chars in buffer */
51         u_int   sb_hiwat;       /* (c/d) max actual char count */
52         u_int   sb_mbcnt;       /* (c/d) chars of mbufs used */
53         u_int   sb_mbmax;       /* (c/d) max chars of mbufs to use */
54         u_int   sb_ctl;         /* (c/d) non-data chars in buffer */
55         int     sb_lowat;       /* (c/d) low water mark */
56         int     sb_timeo;       /* (c/d) timeout for read/write */
57         short   sb_flags;       /* (c/d) flags, see below */
58 };
59
60 void    sbappend(struct sockbuf *sb, struct mbuf *m);
61 void    sbappend_locked(struct sockbuf *sb, struct mbuf *m);
62 void    sbappendstream(struct sockbuf *sb, struct mbuf *m);
63 void    sbappendstream_locked(struct sockbuf *sb, struct mbuf *m);
64 void    sbdrop(struct sockbuf *sb, int len);
65 void    sbdrop_locked(struct sockbuf *sb, int len);
66 void    sbdroprecord(struct sockbuf *sb);
67 void    sbdroprecord_locked(struct sockbuf *sb);
68 void    sbflush(struct sockbuf *sb);
69 void    sbflush_locked(struct sockbuf *sb);
70 int     sbwait(struct sockbuf *sb);
71 int     sblock(struct sockbuf *, int);
72 void    sbunlock(struct sockbuf *);
73
74
75
76 /* adjust counters in sb reflecting allocation of m */
77 #define sballoc(sb, m) { \
78         (sb)->sb_cc += (m)->m_len; \
79         if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \
80                 (sb)->sb_ctl += (m)->m_len; \
81         (sb)->sb_mbcnt += MSIZE; \
82         if ((m)->m_flags & M_EXT) \
83                 (sb)->sb_mbcnt += (m)->m_ext.ext_size; \
84 }
85
86 /* adjust counters in sb reflecting freeing of m */
87 #define sbfree(sb, m) { \
88         (sb)->sb_cc -= (m)->m_len; \
89         if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \
90                 (sb)->sb_ctl -= (m)->m_len; \
91         (sb)->sb_mbcnt -= MSIZE; \
92         if ((m)->m_flags & M_EXT) \
93                 (sb)->sb_mbcnt -= (m)->m_ext.ext_size; \
94         if ((sb)->sb_sndptr == (m)) { \
95                 (sb)->sb_sndptr = NULL; \
96                 (sb)->sb_sndptroff = 0; \
97         } \
98         if ((sb)->sb_sndptroff != 0) \
99                 (sb)->sb_sndptroff -= (m)->m_len; \
100 }
101
102 #define SS_NOFDREF              0x0001  /* no file table ref any more */
103 #define SS_ISCONNECTED          0x0002  /* socket connected to a peer */
104 #define SS_ISCONNECTING         0x0004  /* in process of connecting to peer */
105 #define SS_ISDISCONNECTING      0x0008  /* in process of disconnecting */
106 #define SS_NBIO                 0x0100  /* non-blocking ops */
107 #define SS_ASYNC                0x0200  /* async i/o notify */
108 #define SS_ISCONFIRMING         0x0400  /* deciding to accept connection req */
109 #define SS_ISDISCONNECTED       0x2000  /* socket disconnected from peer */
110 /*
111  * Protocols can mark a socket as SS_PROTOREF to indicate that, following
112  * pru_detach, they still want the socket to persist, and will free it
113  * themselves when they are done.  Protocols should only ever call sofree()
114  * following setting this flag in pru_detach(), and never otherwise, as
115  * sofree() bypasses socket reference counting.
116  */
117 #define SS_PROTOREF             0x4000  /* strong protocol reference */
118
119 /*
120  * Socket state bits now stored in the socket buffer state field.
121  */
122 #define SBS_CANTSENDMORE        0x0010  /* can't send more data to peer */
123 #define SBS_CANTRCVMORE         0x0020  /* can't receive more data from peer */
124 #define SBS_RCVATMARK           0x0040  /* at mark on input */
125
126
127
128 enum sopt_dir { SOPT_GET, SOPT_SET };
129 struct sockopt {
130         enum    sopt_dir sopt_dir; /* is this a get or a set? */
131         int     sopt_level;     /* second arg of [gs]etsockopt */
132         int     sopt_name;      /* third arg of [gs]etsockopt */
133         void   *sopt_val;       /* fourth arg of [gs]etsockopt */
134         size_t  sopt_valsize;   /* (almost) fifth arg of [gs]etsockopt */
135         struct  thread *sopt_td; /* calling thread or null if kernel */
136 };
137
138
139 int     sooptcopyin(struct sockopt *sopt, void *buf, size_t len, size_t minlen);
140 int     sooptcopyout(struct sockopt *sopt, const void *buf, size_t len);
141
142
143 void    soisconnected(struct socket *so);
144 void    soisconnecting(struct socket *so);
145 void    soisdisconnected(struct socket *so);
146 void    soisdisconnecting(struct socket *so);
147 void    socantrcvmore(struct socket *so);
148 void    socantrcvmore_locked(struct socket *so);
149 void    socantsendmore(struct socket *so);
150 void    socantsendmore_locked(struct socket *so);
151
152 #endif /* !NET_CORE */
153
154
155 #endif /* CXGB_TCP_OFFLOAD_H_ */