Lines Matching refs:req
58 struct list_head req; member
75 struct ncp_request_reply *req; in ncp_alloc_req() local
77 req = kmalloc(sizeof(struct ncp_request_reply), GFP_KERNEL); in ncp_alloc_req()
78 if (!req) in ncp_alloc_req()
81 init_waitqueue_head(&req->wq); in ncp_alloc_req()
82 atomic_set(&req->refs, (1)); in ncp_alloc_req()
83 req->status = RQ_IDLE; in ncp_alloc_req()
85 return req; in ncp_alloc_req()
88 static void ncp_req_get(struct ncp_request_reply *req) in ncp_req_get() argument
90 atomic_inc(&req->refs); in ncp_req_get()
93 static void ncp_req_put(struct ncp_request_reply *req) in ncp_req_put() argument
95 if (atomic_dec_and_test(&req->refs)) in ncp_req_put()
96 kfree(req); in ncp_req_put()
133 static inline void ncp_finish_request(struct ncp_server *server, struct ncp_request_reply *req, int… in ncp_finish_request() argument
135 req->result = result; in ncp_finish_request()
136 if (req->status != RQ_ABANDONED) in ncp_finish_request()
137 memcpy(req->reply_buf, server->rxbuf, req->datalen); in ncp_finish_request()
138 req->status = RQ_DONE; in ncp_finish_request()
139 wake_up_all(&req->wq); in ncp_finish_request()
140 ncp_req_put(req); in ncp_finish_request()
145 struct ncp_request_reply *req; in __abort_ncp_connection() local
150 req = list_entry(server->tx.requests.next, struct ncp_request_reply, req); in __abort_ncp_connection()
152 list_del_init(&req->req); in __abort_ncp_connection()
153 ncp_finish_request(server, req, -EIO); in __abort_ncp_connection()
155 req = server->rcv.creq; in __abort_ncp_connection()
156 if (req) { in __abort_ncp_connection()
158 ncp_finish_request(server, req, -EIO); in __abort_ncp_connection()
162 req = server->tx.creq; in __abort_ncp_connection()
163 if (req) { in __abort_ncp_connection()
165 ncp_finish_request(server, req, -EIO); in __abort_ncp_connection()
174 static inline void __ncp_abort_request(struct ncp_server *server, struct ncp_request_reply *req, in… in __ncp_abort_request() argument
177 switch (req->status) { in __ncp_abort_request()
182 list_del_init(&req->req); in __ncp_abort_request()
183 ncp_finish_request(server, req, err); in __ncp_abort_request()
186 req->status = RQ_ABANDONED; in __ncp_abort_request()
193 static inline void ncp_abort_request(struct ncp_server *server, struct ncp_request_reply *req, int … in ncp_abort_request() argument
196 __ncp_abort_request(server, req, err); in ncp_abort_request()
205 static int ncpdgram_send(struct socket *sock, struct ncp_request_reply *req) in ncpdgram_send() argument
209 memcpy(vec, req->tx_ciov, req->tx_iovlen * sizeof(vec[0])); in ncpdgram_send()
210 return do_send(sock, vec, req->tx_iovlen, in ncpdgram_send()
211 req->tx_totallen, MSG_DONTWAIT); in ncpdgram_send()
255 static inline void ncp_init_header(struct ncp_server *server, struct ncp_request_reply *req, struct… in ncp_init_header() argument
257 req->status = RQ_INPROGRESS; in ncp_init_header()
263 static void ncpdgram_start_request(struct ncp_server *server, struct ncp_request_reply *req) in ncpdgram_start_request() argument
268 req->tx_ciov = req->tx_iov + 1; in ncpdgram_start_request()
270 h = req->tx_iov[1].iov_base; in ncpdgram_start_request()
271 ncp_init_header(server, req, h); in ncpdgram_start_request()
272 signlen = sign_packet(server, req->tx_iov[1].iov_base + sizeof(struct ncp_request_header) - 1, in ncpdgram_start_request()
273 req->tx_iov[1].iov_len - sizeof(struct ncp_request_header) + 1, in ncpdgram_start_request()
274 cpu_to_le32(req->tx_totallen), req->sign); in ncpdgram_start_request()
276 req->tx_ciov[1].iov_base = req->sign; in ncpdgram_start_request()
277 req->tx_ciov[1].iov_len = signlen; in ncpdgram_start_request()
278 req->tx_iovlen += 1; in ncpdgram_start_request()
279 req->tx_totallen += signlen; in ncpdgram_start_request()
281 server->rcv.creq = req; in ncpdgram_start_request()
284 ncpdgram_send(server->ncp_sock, req); in ncpdgram_start_request()
292 static void ncptcp_start_request(struct ncp_server *server, struct ncp_request_reply *req) in ncptcp_start_request() argument
297 req->tx_ciov = req->tx_iov; in ncptcp_start_request()
298 h = req->tx_iov[1].iov_base; in ncptcp_start_request()
299 ncp_init_header(server, req, h); in ncptcp_start_request()
300 signlen = sign_packet(server, req->tx_iov[1].iov_base + sizeof(struct ncp_request_header) - 1, in ncptcp_start_request()
301 req->tx_iov[1].iov_len - sizeof(struct ncp_request_header) + 1, in ncptcp_start_request()
302 cpu_to_be32(req->tx_totallen + 24), req->sign + 4) + 16; in ncptcp_start_request()
304 req->sign[0] = htonl(NCP_TCP_XMIT_MAGIC); in ncptcp_start_request()
305 req->sign[1] = htonl(req->tx_totallen + signlen); in ncptcp_start_request()
306 req->sign[2] = htonl(NCP_TCP_XMIT_VERSION); in ncptcp_start_request()
307 req->sign[3] = htonl(req->datalen + 8); in ncptcp_start_request()
308 req->tx_iov[0].iov_base = req->sign; in ncptcp_start_request()
309 req->tx_iov[0].iov_len = signlen; in ncptcp_start_request()
310 req->tx_iovlen += 1; in ncptcp_start_request()
311 req->tx_totallen += signlen; in ncptcp_start_request()
313 server->tx.creq = req; in ncptcp_start_request()
317 static inline void __ncp_start_request(struct ncp_server *server, struct ncp_request_reply *req) in __ncp_start_request() argument
321 memcpy(server->txbuf, req->tx_iov[1].iov_base, req->tx_iov[1].iov_len); in __ncp_start_request()
322 req->tx_iov[1].iov_base = server->txbuf; in __ncp_start_request()
325 ncptcp_start_request(server, req); in __ncp_start_request()
327 ncpdgram_start_request(server, req); in __ncp_start_request()
330 static int ncp_add_request(struct ncp_server *server, struct ncp_request_reply *req) in ncp_add_request() argument
338 ncp_req_get(req); in ncp_add_request()
340 req->status = RQ_QUEUED; in ncp_add_request()
341 list_add_tail(&req->req, &server->tx.requests); in ncp_add_request()
345 __ncp_start_request(server, req); in ncp_add_request()
352 struct ncp_request_reply *req; in __ncp_next_request() local
358 req = list_entry(server->tx.requests.next, struct ncp_request_reply, req); in __ncp_next_request()
359 list_del_init(&req->req); in __ncp_next_request()
360 __ncp_start_request(server, req); in __ncp_next_request()
398 struct ncp_request_reply *req; in ncpdgram_rcv_proc() local
432 req = server->rcv.creq; in ncpdgram_rcv_proc()
433 if (req && (req->tx_type == NCP_ALLOC_SLOT_REQUEST || (server->sequence == reply.sequence && in ncpdgram_rcv_proc()
440 result = _recv(sock, server->rxbuf, req->datalen, MSG_DONTWAIT); in ncpdgram_rcv_proc()
442 if (result >= 0 && server->sign_active && req->tx_type != NCP_DEALLOC_SLOT_REQUEST) { in ncpdgram_rcv_proc()
459 ncp_finish_request(server, req, result); in ncpdgram_rcv_proc()
476 struct ncp_request_reply* req; in __ncpdgram_timeout_proc() local
478 req = server->rcv.creq; in __ncpdgram_timeout_proc()
479 if (req) { in __ncpdgram_timeout_proc()
484 __ncp_abort_request(server, req, -ETIMEDOUT); in __ncpdgram_timeout_proc()
489 ncpdgram_send(server->ncp_sock, req); in __ncpdgram_timeout_proc()
538 struct ncp_request_reply *req; in __ncptcp_rcv_proc() local
548 req = server->rcv.creq; in __ncptcp_rcv_proc()
549 if (req) { in __ncptcp_rcv_proc()
550 __ncp_abort_request(server, req, -EIO); in __ncptcp_rcv_proc()
615 req = server->rcv.creq; in __ncptcp_rcv_proc()
616 if (!req) { in __ncptcp_rcv_proc()
620 if (datalen > req->datalen + 8) { in __ncptcp_rcv_proc()
621 …printk(KERN_ERR "ncpfs: tcp: Unexpected reply len %d (expected at most %Zd)\n", datalen, req->data… in __ncptcp_rcv_proc()
625 req->datalen = datalen - 8; in __ncptcp_rcv_proc()
638 req = server->rcv.creq; in __ncptcp_rcv_proc()
639 if (req->tx_type != NCP_ALLOC_SLOT_REQUEST) { in __ncptcp_rcv_proc()
642 __ncp_abort_request(server, req, -EIO); in __ncptcp_rcv_proc()
647 __ncp_abort_request(server, req, -EIO); in __ncptcp_rcv_proc()
652 if (server->sign_active && req->tx_type != NCP_DEALLOC_SLOT_REQUEST) { in __ncptcp_rcv_proc()
653 …if (sign_verify_reply(server, server->rxbuf + 6, req->datalen - 6, cpu_to_be32(req->datalen + 16),… in __ncptcp_rcv_proc()
655 __ncp_abort_request(server, req, -EIO); in __ncptcp_rcv_proc()
660 ncp_finish_request(server, req, req->datalen); in __ncptcp_rcv_proc()
703 struct ncp_request_reply *req; in do_ncp_rpc_call() local
705 req = ncp_alloc_req(); in do_ncp_rpc_call()
706 if (!req) in do_ncp_rpc_call()
709 req->reply_buf = reply_buf; in do_ncp_rpc_call()
710 req->datalen = max_reply_size; in do_ncp_rpc_call()
711 req->tx_iov[1].iov_base = server->packet; in do_ncp_rpc_call()
712 req->tx_iov[1].iov_len = size; in do_ncp_rpc_call()
713 req->tx_iovlen = 1; in do_ncp_rpc_call()
714 req->tx_totallen = size; in do_ncp_rpc_call()
715 req->tx_type = *(u_int16_t*)server->packet; in do_ncp_rpc_call()
717 result = ncp_add_request(server, req); in do_ncp_rpc_call()
721 if (wait_event_interruptible(req->wq, req->status == RQ_DONE)) { in do_ncp_rpc_call()
722 ncp_abort_request(server, req, -EINTR); in do_ncp_rpc_call()
727 result = req->result; in do_ncp_rpc_call()
730 ncp_req_put(req); in do_ncp_rpc_call()