Lines Matching refs:c
223 static int p9_fcall_init(struct p9_client *c, struct p9_fcall *fc, in p9_fcall_init() argument
226 if (likely(c->fcall_cache) && alloc_msize == c->msize) { in p9_fcall_init()
227 fc->sdata = kmem_cache_alloc(c->fcall_cache, GFP_NOFS); in p9_fcall_init()
228 fc->cache = c->fcall_cache; in p9_fcall_init()
266 p9_tag_alloc(struct p9_client *c, int8_t type, unsigned int max_size) in p9_tag_alloc() argument
269 int alloc_msize = min(c->msize, max_size); in p9_tag_alloc()
275 if (p9_fcall_init(c, &req->tc, alloc_msize)) in p9_tag_alloc()
277 if (p9_fcall_init(c, &req->rc, alloc_msize)) in p9_tag_alloc()
293 spin_lock_irq(&c->lock); in p9_tag_alloc()
295 tag = idr_alloc(&c->reqs, req, P9_NOTAG, P9_NOTAG + 1, in p9_tag_alloc()
298 tag = idr_alloc(&c->reqs, req, 0, P9_NOTAG, GFP_NOWAIT); in p9_tag_alloc()
300 spin_unlock_irq(&c->lock); in p9_tag_alloc()
335 struct p9_req_t *p9_tag_lookup(struct p9_client *c, u16 tag) in p9_tag_lookup() argument
341 req = idr_find(&c->reqs, tag); in p9_tag_lookup()
351 p9_req_put(c, req); in p9_tag_lookup()
368 static int p9_tag_remove(struct p9_client *c, struct p9_req_t *r) in p9_tag_remove() argument
373 p9_debug(P9_DEBUG_MUX, "clnt %p req %p tag: %d\n", c, r, tag); in p9_tag_remove()
374 spin_lock_irqsave(&c->lock, flags); in p9_tag_remove()
375 idr_remove(&c->reqs, tag); in p9_tag_remove()
376 spin_unlock_irqrestore(&c->lock, flags); in p9_tag_remove()
377 return p9_req_put(c, r); in p9_tag_remove()
380 int p9_req_put(struct p9_client *c, struct p9_req_t *r) in p9_req_put() argument
399 static void p9_tag_cleanup(struct p9_client *c) in p9_tag_cleanup() argument
405 idr_for_each_entry(&c->reqs, req, id) { in p9_tag_cleanup()
407 if (p9_tag_remove(c, req) == 0) in p9_tag_cleanup()
421 void p9_client_cb(struct p9_client *c, struct p9_req_t *req, int status) in p9_client_cb() argument
433 p9_req_put(c, req); in p9_client_cb()
498 static int p9_check_errors(struct p9_client *c, struct p9_req_t *req) in p9_check_errors() argument
505 if (req->rc.size >= c->msize) { in p9_check_errors()
514 trace_9p_protocol_dump(c, &req->rc); in p9_check_errors()
522 if (!p9_is_proto_dotl(c)) { in p9_check_errors()
525 err = p9pdu_readf(&req->rc, c->proto_version, "s?d", in p9_check_errors()
532 if (p9_is_proto_dotu(c) && ecode < 512) in p9_check_errors()
543 err = p9pdu_readf(&req->rc, c->proto_version, "d", &ecode); in p9_check_errors()
572 static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req, in p9_check_zc_errors() argument
584 trace_9p_protocol_dump(c, &req->rc); in p9_check_zc_errors()
593 if (!p9_is_proto_dotl(c)) { in p9_check_zc_errors()
615 err = p9pdu_readf(&req->rc, c->proto_version, "s?d", in p9_check_zc_errors()
620 if (p9_is_proto_dotu(c) && ecode < 512) in p9_check_zc_errors()
631 err = p9pdu_readf(&req->rc, c->proto_version, "d", &ecode); in p9_check_zc_errors()
644 p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...);
658 static int p9_client_flush(struct p9_client *c, struct p9_req_t *oldreq) in p9_client_flush() argument
670 req = p9_client_rpc(c, P9_TFLUSH, "w", oldtag); in p9_client_flush()
678 if (c->trans_mod->cancelled) in p9_client_flush()
679 c->trans_mod->cancelled(c, oldreq); in p9_client_flush()
682 p9_tag_remove(c, req); in p9_client_flush()
686 static struct p9_req_t *p9_client_prepare_req(struct p9_client *c, in p9_client_prepare_req() argument
693 p9_debug(P9_DEBUG_MUX, "client %p op %d\n", c, type); in p9_client_prepare_req()
696 if (c->status == Disconnected) in p9_client_prepare_req()
700 if (c->status == BeginDisconnect && type != P9_TCLUNK) in p9_client_prepare_req()
703 req = p9_tag_alloc(c, type, req_size); in p9_client_prepare_req()
709 err = p9pdu_vwritef(&req->tc, c->proto_version, fmt, ap); in p9_client_prepare_req()
712 p9pdu_finalize(c, &req->tc); in p9_client_prepare_req()
713 trace_9p_client_req(c, type, req->tc.tag); in p9_client_prepare_req()
716 p9_tag_remove(c, req); in p9_client_prepare_req()
718 p9_req_put(c, req); in p9_client_prepare_req()
732 p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...) in p9_client_rpc() argument
740 req = p9_client_prepare_req(c, type, c->msize, fmt, ap); in p9_client_rpc()
752 err = c->trans_mod->request(c, req); in p9_client_rpc()
755 p9_req_put(c, req); in p9_client_rpc()
757 c->status = Disconnected; in p9_client_rpc()
769 if (err == -ERESTARTSYS && c->status == Connected && in p9_client_rpc()
780 if (err == -ERESTARTSYS && c->status == Connected) { in p9_client_rpc()
785 if (c->trans_mod->cancel(c, req)) in p9_client_rpc()
786 p9_client_flush(c, req); in p9_client_rpc()
801 err = p9_check_errors(c, req); in p9_client_rpc()
802 trace_9p_client_res(c, type, req->rc.tag, err); in p9_client_rpc()
806 p9_tag_remove(c, req); in p9_client_rpc()
823 static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type, in p9_client_zc_rpc() argument
838 req = p9_client_prepare_req(c, type, P9_ZC_HDR_SZ, fmt, ap); in p9_client_zc_rpc()
850 err = c->trans_mod->zc_request(c, req, uidata, uodata, in p9_client_zc_rpc()
854 c->status = Disconnected; in p9_client_zc_rpc()
862 if (err == -ERESTARTSYS && c->status == Connected) { in p9_client_zc_rpc()
867 if (c->trans_mod->cancel(c, req)) in p9_client_zc_rpc()
868 p9_client_flush(c, req); in p9_client_zc_rpc()
883 err = p9_check_zc_errors(c, req, uidata, in_hdrlen); in p9_client_zc_rpc()
884 trace_9p_client_res(c, type, req->rc.tag, err); in p9_client_zc_rpc()
888 p9_tag_remove(c, req); in p9_client_zc_rpc()
934 static int p9_client_version(struct p9_client *c) in p9_client_version() argument
942 c->msize, c->proto_version); in p9_client_version()
944 switch (c->proto_version) { in p9_client_version()
946 req = p9_client_rpc(c, P9_TVERSION, "ds", in p9_client_version()
947 c->msize, "9P2000.L"); in p9_client_version()
950 req = p9_client_rpc(c, P9_TVERSION, "ds", in p9_client_version()
951 c->msize, "9P2000.u"); in p9_client_version()
954 req = p9_client_rpc(c, P9_TVERSION, "ds", in p9_client_version()
955 c->msize, "9P2000"); in p9_client_version()
964 err = p9pdu_readf(&req->rc, c->proto_version, "ds", &msize, &version); in p9_client_version()
967 trace_9p_protocol_dump(c, &req->rc); in p9_client_version()
973 c->proto_version = p9_proto_2000L; in p9_client_version()
975 c->proto_version = p9_proto_2000u; in p9_client_version()
977 c->proto_version = p9_proto_legacy; in p9_client_version()
991 if (msize < c->msize) in p9_client_version()
992 c->msize = msize; in p9_client_version()
996 p9_tag_remove(c, req); in p9_client_version()