Lines Matching refs:req
59 struct list_head req; member
76 struct ncp_request_reply *req; in ncp_alloc_req() local
78 req = kmalloc(sizeof(struct ncp_request_reply), GFP_KERNEL); in ncp_alloc_req()
79 if (!req) in ncp_alloc_req()
82 init_waitqueue_head(&req->wq); in ncp_alloc_req()
83 atomic_set(&req->refs, (1)); in ncp_alloc_req()
84 req->status = RQ_IDLE; in ncp_alloc_req()
86 return req; in ncp_alloc_req()
89 static void ncp_req_get(struct ncp_request_reply *req) in ncp_req_get() argument
91 atomic_inc(&req->refs); in ncp_req_get()
94 static void ncp_req_put(struct ncp_request_reply *req) in ncp_req_put() argument
96 if (atomic_dec_and_test(&req->refs)) in ncp_req_put()
97 kfree(req); in ncp_req_put()
134 static inline void ncp_finish_request(struct ncp_server *server, struct ncp_request_reply *req, int… in ncp_finish_request() argument
136 req->result = result; in ncp_finish_request()
137 if (req->status != RQ_ABANDONED) in ncp_finish_request()
138 memcpy(req->reply_buf, server->rxbuf, req->datalen); in ncp_finish_request()
139 req->status = RQ_DONE; in ncp_finish_request()
140 wake_up_all(&req->wq); in ncp_finish_request()
141 ncp_req_put(req); in ncp_finish_request()
146 struct ncp_request_reply *req; in __abort_ncp_connection() local
151 req = list_entry(server->tx.requests.next, struct ncp_request_reply, req); in __abort_ncp_connection()
153 list_del_init(&req->req); in __abort_ncp_connection()
154 ncp_finish_request(server, req, -EIO); in __abort_ncp_connection()
156 req = server->rcv.creq; in __abort_ncp_connection()
157 if (req) { in __abort_ncp_connection()
159 ncp_finish_request(server, req, -EIO); in __abort_ncp_connection()
163 req = server->tx.creq; in __abort_ncp_connection()
164 if (req) { in __abort_ncp_connection()
166 ncp_finish_request(server, req, -EIO); in __abort_ncp_connection()
175 static inline void __ncp_abort_request(struct ncp_server *server, struct ncp_request_reply *req, in… in __ncp_abort_request() argument
178 switch (req->status) { in __ncp_abort_request()
183 list_del_init(&req->req); in __ncp_abort_request()
184 ncp_finish_request(server, req, err); in __ncp_abort_request()
187 req->status = RQ_ABANDONED; in __ncp_abort_request()
194 static inline void ncp_abort_request(struct ncp_server *server, struct ncp_request_reply *req, int … in ncp_abort_request() argument
197 __ncp_abort_request(server, req, err); in ncp_abort_request()
206 static int ncpdgram_send(struct socket *sock, struct ncp_request_reply *req) in ncpdgram_send() argument
210 memcpy(vec, req->tx_ciov, req->tx_iovlen * sizeof(vec[0])); in ncpdgram_send()
211 return do_send(sock, vec, req->tx_iovlen, in ncpdgram_send()
212 req->tx_totallen, MSG_DONTWAIT); in ncpdgram_send()
256 static inline void ncp_init_header(struct ncp_server *server, struct ncp_request_reply *req, struct… in ncp_init_header() argument
258 req->status = RQ_INPROGRESS; in ncp_init_header()
264 static void ncpdgram_start_request(struct ncp_server *server, struct ncp_request_reply *req) in ncpdgram_start_request() argument
269 req->tx_ciov = req->tx_iov + 1; in ncpdgram_start_request()
271 h = req->tx_iov[1].iov_base; in ncpdgram_start_request()
272 ncp_init_header(server, req, h); in ncpdgram_start_request()
273 signlen = sign_packet(server, req->tx_iov[1].iov_base + sizeof(struct ncp_request_header) - 1, in ncpdgram_start_request()
274 req->tx_iov[1].iov_len - sizeof(struct ncp_request_header) + 1, in ncpdgram_start_request()
275 cpu_to_le32(req->tx_totallen), req->sign); in ncpdgram_start_request()
277 req->tx_ciov[1].iov_base = req->sign; in ncpdgram_start_request()
278 req->tx_ciov[1].iov_len = signlen; in ncpdgram_start_request()
279 req->tx_iovlen += 1; in ncpdgram_start_request()
280 req->tx_totallen += signlen; in ncpdgram_start_request()
282 server->rcv.creq = req; in ncpdgram_start_request()
285 ncpdgram_send(server->ncp_sock, req); in ncpdgram_start_request()
293 static void ncptcp_start_request(struct ncp_server *server, struct ncp_request_reply *req) in ncptcp_start_request() argument
298 req->tx_ciov = req->tx_iov; in ncptcp_start_request()
299 h = req->tx_iov[1].iov_base; in ncptcp_start_request()
300 ncp_init_header(server, req, h); in ncptcp_start_request()
301 signlen = sign_packet(server, req->tx_iov[1].iov_base + sizeof(struct ncp_request_header) - 1, in ncptcp_start_request()
302 req->tx_iov[1].iov_len - sizeof(struct ncp_request_header) + 1, in ncptcp_start_request()
303 cpu_to_be32(req->tx_totallen + 24), req->sign + 4) + 16; in ncptcp_start_request()
305 req->sign[0] = htonl(NCP_TCP_XMIT_MAGIC); in ncptcp_start_request()
306 req->sign[1] = htonl(req->tx_totallen + signlen); in ncptcp_start_request()
307 req->sign[2] = htonl(NCP_TCP_XMIT_VERSION); in ncptcp_start_request()
308 req->sign[3] = htonl(req->datalen + 8); in ncptcp_start_request()
309 req->tx_iov[0].iov_base = req->sign; in ncptcp_start_request()
310 req->tx_iov[0].iov_len = signlen; in ncptcp_start_request()
311 req->tx_iovlen += 1; in ncptcp_start_request()
312 req->tx_totallen += signlen; in ncptcp_start_request()
314 server->tx.creq = req; in ncptcp_start_request()
318 static inline void __ncp_start_request(struct ncp_server *server, struct ncp_request_reply *req) in __ncp_start_request() argument
322 memcpy(server->txbuf, req->tx_iov[1].iov_base, req->tx_iov[1].iov_len); in __ncp_start_request()
323 req->tx_iov[1].iov_base = server->txbuf; in __ncp_start_request()
326 ncptcp_start_request(server, req); in __ncp_start_request()
328 ncpdgram_start_request(server, req); in __ncp_start_request()
331 static int ncp_add_request(struct ncp_server *server, struct ncp_request_reply *req) in ncp_add_request() argument
339 ncp_req_get(req); in ncp_add_request()
341 req->status = RQ_QUEUED; in ncp_add_request()
342 list_add_tail(&req->req, &server->tx.requests); in ncp_add_request()
346 __ncp_start_request(server, req); in ncp_add_request()
353 struct ncp_request_reply *req; in __ncp_next_request() local
359 req = list_entry(server->tx.requests.next, struct ncp_request_reply, req); in __ncp_next_request()
360 list_del_init(&req->req); in __ncp_next_request()
361 __ncp_start_request(server, req); in __ncp_next_request()
399 struct ncp_request_reply *req; in ncpdgram_rcv_proc() local
433 req = server->rcv.creq; in ncpdgram_rcv_proc()
434 if (req && (req->tx_type == NCP_ALLOC_SLOT_REQUEST || (server->sequence == reply.sequence && in ncpdgram_rcv_proc()
441 result = _recv(sock, server->rxbuf, req->datalen, MSG_DONTWAIT); in ncpdgram_rcv_proc()
443 if (result >= 0 && server->sign_active && req->tx_type != NCP_DEALLOC_SLOT_REQUEST) { in ncpdgram_rcv_proc()
460 ncp_finish_request(server, req, result); in ncpdgram_rcv_proc()
477 struct ncp_request_reply* req; in __ncpdgram_timeout_proc() local
479 req = server->rcv.creq; in __ncpdgram_timeout_proc()
480 if (req) { in __ncpdgram_timeout_proc()
485 __ncp_abort_request(server, req, -ETIMEDOUT); in __ncpdgram_timeout_proc()
490 ncpdgram_send(server->ncp_sock, req); in __ncpdgram_timeout_proc()
539 struct ncp_request_reply *req; in __ncptcp_rcv_proc() local
549 req = server->rcv.creq; in __ncptcp_rcv_proc()
550 if (req) { in __ncptcp_rcv_proc()
551 __ncp_abort_request(server, req, -EIO); in __ncptcp_rcv_proc()
616 req = server->rcv.creq; in __ncptcp_rcv_proc()
617 if (!req) { in __ncptcp_rcv_proc()
621 if (datalen > req->datalen + 8) { in __ncptcp_rcv_proc()
622 pr_err("tcp: Unexpected reply len %d (expected at most %Zd)\n", datalen, req->datalen + 8); in __ncptcp_rcv_proc()
626 req->datalen = datalen - 8; in __ncptcp_rcv_proc()
639 req = server->rcv.creq; in __ncptcp_rcv_proc()
640 if (req->tx_type != NCP_ALLOC_SLOT_REQUEST) { in __ncptcp_rcv_proc()
643 __ncp_abort_request(server, req, -EIO); in __ncptcp_rcv_proc()
648 __ncp_abort_request(server, req, -EIO); in __ncptcp_rcv_proc()
653 if (server->sign_active && req->tx_type != NCP_DEALLOC_SLOT_REQUEST) { in __ncptcp_rcv_proc()
654 …if (sign_verify_reply(server, server->rxbuf + 6, req->datalen - 6, cpu_to_be32(req->datalen + 16),… in __ncptcp_rcv_proc()
656 __ncp_abort_request(server, req, -EIO); in __ncptcp_rcv_proc()
661 ncp_finish_request(server, req, req->datalen); in __ncptcp_rcv_proc()
704 struct ncp_request_reply *req; in do_ncp_rpc_call() local
706 req = ncp_alloc_req(); in do_ncp_rpc_call()
707 if (!req) in do_ncp_rpc_call()
710 req->reply_buf = reply_buf; in do_ncp_rpc_call()
711 req->datalen = max_reply_size; in do_ncp_rpc_call()
712 req->tx_iov[1].iov_base = server->packet; in do_ncp_rpc_call()
713 req->tx_iov[1].iov_len = size; in do_ncp_rpc_call()
714 req->tx_iovlen = 1; in do_ncp_rpc_call()
715 req->tx_totallen = size; in do_ncp_rpc_call()
716 req->tx_type = *(u_int16_t*)server->packet; in do_ncp_rpc_call()
718 result = ncp_add_request(server, req); in do_ncp_rpc_call()
722 if (wait_event_interruptible(req->wq, req->status == RQ_DONE)) { in do_ncp_rpc_call()
723 ncp_abort_request(server, req, -EINTR); in do_ncp_rpc_call()
728 result = req->result; in do_ncp_rpc_call()
731 ncp_req_put(req); in do_ncp_rpc_call()