1 /*-
2 * Copyright (c) 2012, 2015 Chelsio Communications, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD$
27 *
28 */
29
30 #ifndef __CXGBEI_OFLD_H__
31 #define __CXGBEI_OFLD_H__
32
33 #include <dev/iscsi/icl.h>
34
35 #define CXGBEI_CONN_SIGNATURE 0x56788765
36
37 struct cxgbei_cmp {
38 LIST_ENTRY(cxgbei_cmp) link;
39
40 uint32_t tt; /* Transfer tag. */
41
42 uint32_t next_buffer_offset;
43 uint32_t last_datasn;
44 };
45 LIST_HEAD(cxgbei_cmp_head, cxgbei_cmp);
46
47 struct icl_cxgbei_conn {
48 struct icl_conn ic;
49
50 /* cxgbei specific stuff goes here. */
51 uint32_t icc_signature;
52 int ulp_submode;
53 struct adapter *sc;
54 struct toepcb *toep;
55
56 /* Receive related. */
57 bool rx_active; /* protected by so_rcv lock */
58 bool rx_exiting; /* protected by so_rcv lock */
59 STAILQ_HEAD(, icl_pdu) rcvd_pdus; /* protected by so_rcv lock */
60 struct thread *rx_thread;
61
62 struct cxgbei_cmp_head *cmp_table; /* protected by cmp_lock */
63 struct mtx cmp_lock;
64 unsigned long cmp_hash_mask;
65
66 /* Transmit related. */
67 bool tx_active; /* protected by ic lock */
68 STAILQ_HEAD(, icl_pdu) sent_pdus; /* protected by ic lock */
69 struct thread *tx_thread;
70 };
71
72 static inline struct icl_cxgbei_conn *
73 ic_to_icc(struct icl_conn *ic)
74 {
75
76 return (__containerof(ic, struct icl_cxgbei_conn, ic));
77 }
78
79 /* PDU flags and signature. */
80 enum {
81 ICPF_RX_HDR = 1 << 0, /* PDU header received. */
82 ICPF_RX_FLBUF = 1 << 1, /* PDU payload received in a freelist. */
83 ICPF_RX_DDP = 1 << 2, /* PDU payload DDP'd. */
84 ICPF_RX_STATUS = 1 << 3, /* Rx status received. */
85
86 CXGBEI_PDU_SIGNATURE = 0x12344321
87 };
88
89 struct icl_cxgbei_pdu {
90 struct icl_pdu ip;
91
92 /* cxgbei specific stuff goes here. */
93 uint32_t icp_signature;
94 uint32_t icp_seq; /* For debug only */
95 u_int icp_flags;
96
97 u_int ref_cnt;
98 icl_pdu_cb cb;
99 int error;
100 };
101
102 static inline struct icl_cxgbei_pdu *
103 ip_to_icp(struct icl_pdu *ip)
104 {
105
106 return (__containerof(ip, struct icl_cxgbei_pdu, ip));
107 }
108
109 struct cxgbei_data {
110 u_int max_tx_data_len;
111 u_int max_rx_data_len;
112
113 u_int ddp_threshold;
114 struct ppod_region pr;
115
116 struct sysctl_ctx_list ctx; /* from uld_activate to deactivate */
117 };
118
119 #define CXGBEI_MAX_ISO_PAYLOAD 65535
120
121 /* cxgbei.c */
122 u_int cxgbei_select_worker_thread(struct icl_cxgbei_conn *);
123 void cwt_queue_for_tx(struct icl_cxgbei_conn *);
124 void parse_pdus(struct icl_cxgbei_conn *, struct sockbuf *);
125
126 /* icl_cxgbei.c */
127 void cwt_tx_main(void *);
128 int icl_cxgbei_mod_load(void);
129 int icl_cxgbei_mod_unload(void);
130 struct icl_pdu *icl_cxgbei_new_pdu(int);
131 void icl_cxgbei_new_pdu_set_conn(struct icl_pdu *, struct icl_conn *);
132 void icl_cxgbei_conn_pdu_free(struct icl_conn *, struct icl_pdu *);
133 struct cxgbei_cmp *cxgbei_find_cmp(struct icl_cxgbei_conn *, uint32_t);
134
135 #endif
Cache object: c52f3323adcae3fcdc5becd01e7c532a
|