|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [UNIKRAFT PATCH v2 3/9] lib/uk9p: Delete the old serialization
Reviewed-by: Costin Lupu <costin.lupu@xxxxxxxxx>
On 5/9/20 7:44 PM, Cristian Banu wrote:
> This patch deletes the old serialization implementation and removes
> the functions from exportsyms.uk.
>
> Signed-off-by: Cristian Banu <cristb@xxxxxxxxx>
> ---
> lib/uk9p/9pdev.c | 36 -----
> lib/uk9p/9preq.c | 287 ------------------------------------
> lib/uk9p/exportsyms.uk | 7 -
> lib/uk9p/include/uk/9pdev.h | 23 ---
> lib/uk9p/include/uk/9preq.h | 55 -------
> 5 files changed, 408 deletions(-)
>
> diff --git a/lib/uk9p/9pdev.c b/lib/uk9p/9pdev.c
> index 14ea7ca..1d7e09b 100644
> --- a/lib/uk9p/9pdev.c
> +++ b/lib/uk9p/9pdev.c
> @@ -288,42 +288,6 @@ void uk_9pdev_xmit_notify(struct uk_9pdev *dev)
> #endif
> }
>
> -struct uk_9preq *uk_9pdev_call(struct uk_9pdev *dev, uint8_t type,
> - uint32_t size, const char *fmt, ...)
> -{
> - struct uk_9preq *req;
> - va_list vl;
> - int rc;
> -
> - req = uk_9pdev_req_create(dev, type, size);
> - if (PTRISERR(req))
> - return req;
> -
> - va_start(vl, fmt);
> - rc = uk_9preq_vserialize(req, fmt, vl);
> - va_end(vl);
> -
> - if (rc < 0)
> - goto out;
> -
> - rc = uk_9preq_ready(req, UK_9PREQ_ZCDIR_NONE, NULL, 0, 0);
> - if (rc < 0)
> - goto out;
> -
> - rc = uk_9pdev_request(dev, req);
> - if (rc < 0)
> - goto out;
> -
> - rc = uk_9preq_waitreply(req);
> - if (rc < 0)
> - goto out;
> -
> - return req;
> -out:
> - uk_9pdev_req_remove(dev, req);
> - return ERR2PTR(rc);
> -}
> -
> struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type,
> uint32_t size)
> {
> diff --git a/lib/uk9p/9preq.c b/lib/uk9p/9preq.c
> index 8d787e7..997f772 100644
> --- a/lib/uk9p/9preq.c
> +++ b/lib/uk9p/9preq.c
> @@ -138,293 +138,6 @@ int uk_9preq_put(struct uk_9preq *req)
> return last;
> }
>
> -static int _fcall_write(struct uk_9preq_fcall *fcall, const void *buf,
> - uint32_t size)
> -{
> - if (fcall->offset + size > fcall->size)
> - return -ENOBUFS;
> -
> - memcpy((char *)fcall->buf + fcall->offset, buf, size);
> - fcall->offset += size;
> - return 0;
> -}
> -
> -static int _fcall_serialize(struct uk_9preq_fcall *f, const char *fmt, ...);
> -
> -static int _fcall_vserialize(struct uk_9preq_fcall *fcall, const char *fmt,
> - va_list vl)
> -{
> - int rc = 0;
> -
> - while (*fmt) {
> - switch (*fmt) {
> - case 'b': {
> - uint8_t x;
> -
> - x = va_arg(vl, unsigned int);
> - rc = _fcall_write(fcall, &x, sizeof(x));
> - if (rc < 0)
> - goto out;
> - break;
> - }
> - case 'w': {
> - uint16_t x;
> -
> - x = va_arg(vl, unsigned int);
> - rc = _fcall_write(fcall, &x, sizeof(x));
> - if (rc < 0)
> - goto out;
> - break;
> - }
> - case 'd': {
> - uint32_t x;
> -
> - x = va_arg(vl, uint32_t);
> - rc = _fcall_write(fcall, &x, sizeof(x));
> - if (rc < 0)
> - goto out;
> - break;
> - }
> - case 'q': {
> - uint64_t x;
> -
> - x = va_arg(vl, uint64_t);
> - rc = _fcall_write(fcall, &x, sizeof(x));
> - if (rc < 0)
> - goto out;
> - break;
> - }
> - case 's': {
> - struct uk_9p_str *p;
> -
> - p = va_arg(vl, struct uk_9p_str *);
> - rc = _fcall_write(fcall, &p->size, sizeof(p->size));
> - if (rc < 0)
> - goto out;
> - rc = _fcall_write(fcall, p->data, p->size);
> - if (rc < 0)
> - goto out;
> - break;
> - }
> - case 'Q': {
> - struct uk_9p_qid *p;
> -
> - p = va_arg(vl, struct uk_9p_qid *);
> - rc = _fcall_serialize(fcall, "bdq", p->type,
> - p->version, p->path);
> - if (rc < 0)
> - goto out;
> - break;
> - }
> - case 'S': {
> - struct uk_9p_stat *p;
> -
> - p = va_arg(vl, struct uk_9p_stat *);
> - rc = _fcall_serialize(fcall, "wwdQdddqsssssddd",
> - p->size, p->type, p->dev, &p->qid,
> - p->mode, p->atime, p->mtime, p->length,
> - &p->name, &p->uid, &p->gid, &p->muid,
> - &p->extension, p->n_uid, p->n_gid,
> - p->n_muid);
> - if (rc < 0)
> - goto out;
> - break;
> - }
> - default:
> - rc = -EINVAL;
> - goto out;
> - }
> -
> - fmt++;
> - }
> -
> -out:
> - return rc;
> -}
> -
> -static int _fcall_serialize(struct uk_9preq_fcall *f, const char *fmt, ...)
> -{
> - va_list vl;
> - int rc;
> -
> - va_start(vl, fmt);
> - rc = _fcall_vserialize(f, fmt, vl);
> - va_end(vl);
> -
> - return rc;
> -}
> -
> -int uk_9preq_vserialize(struct uk_9preq *req, const char *fmt, va_list vl)
> -{
> - int rc;
> -
> - UK_ASSERT(req);
> - UK_ASSERT(UK_READ_ONCE(req->state) == UK_9PREQ_INITIALIZED);
> - rc = _fcall_vserialize(&req->xmit, fmt, vl);
> -
> - return rc;
> -}
> -
> -int uk_9preq_serialize(struct uk_9preq *req, const char *fmt, ...)
> -{
> - va_list vl;
> - int rc;
> -
> - va_start(vl, fmt);
> - rc = uk_9preq_vserialize(req, fmt, vl);
> - va_end(vl);
> -
> - return rc;
> -}
> -
> -static int _fcall_read(struct uk_9preq_fcall *fcall, void *buf, uint32_t
> size)
> -{
> - if (fcall->offset + size > fcall->size)
> - return -ENOBUFS;
> -
> - memcpy(buf, (char *)fcall->buf + fcall->offset, size);
> - fcall->offset += size;
> - return 0;
> -}
> -
> -static int _fcall_deserialize(struct uk_9preq_fcall *f, const char *fmt,
> ...);
> -
> -static int _fcall_vdeserialize(struct uk_9preq_fcall *fcall,
> - const char *fmt,
> - va_list vl)
> -{
> - int rc = 0;
> -
> - while (*fmt) {
> - switch (*fmt) {
> - case 'b': {
> - uint8_t *x;
> -
> - x = va_arg(vl, uint8_t *);
> - rc = _fcall_read(fcall, x, sizeof(*x));
> - if (rc < 0)
> - goto out;
> - break;
> - }
> - case 'w': {
> - uint16_t *x;
> -
> - x = va_arg(vl, uint16_t *);
> - rc = _fcall_read(fcall, x, sizeof(*x));
> - if (rc < 0)
> - goto out;
> - break;
> - }
> - case 'd': {
> - uint32_t *x;
> -
> - x = va_arg(vl, uint32_t *);
> - rc = _fcall_read(fcall, x, sizeof(*x));
> - if (rc < 0)
> - goto out;
> - break;
> - }
> - case 'q': {
> - uint64_t *x;
> -
> - x = va_arg(vl, uint64_t *);
> - rc = _fcall_read(fcall, x, sizeof(*x));
> - if (rc < 0)
> - goto out;
> - break;
> - }
> - case 's': {
> - struct uk_9p_str *p;
> -
> - p = va_arg(vl, struct uk_9p_str *);
> - rc = _fcall_read(fcall, &p->size, sizeof(p->size));
> - if (rc < 0)
> - goto out;
> - p->data = (char *)fcall->buf + fcall->offset;
> - fcall->offset += p->size;
> - break;
> - }
> - case 'Q': {
> - struct uk_9p_qid *p;
> -
> - p = va_arg(vl, struct uk_9p_qid *);
> - rc = _fcall_deserialize(fcall, "bdq", &p->type,
> - &p->version, &p->path);
> - if (rc < 0)
> - goto out;
> - break;
> - }
> - case 'S': {
> - struct uk_9p_stat *p;
> -
> - p = va_arg(vl, struct uk_9p_stat *);
> - rc = _fcall_deserialize(fcall, "wwdQdddqsssssddd",
> - &p->size, &p->type, &p->dev, &p->qid,
> - &p->mode, &p->atime, &p->mtime,
> - &p->length, &p->name, &p->uid, &p->gid,
> - &p->muid, &p->extension, &p->n_uid,
> - &p->n_gid, &p->n_muid);
> - if (rc < 0)
> - goto out;
> - break;
> - }
> - default:
> - rc = -EINVAL;
> - goto out;
> - }
> -
> - fmt++;
> - }
> -
> -out:
> - return rc;
> -}
> -
> -static int _fcall_deserialize(struct uk_9preq_fcall *f, const char *fmt, ...)
> -{
> - va_list vl;
> - int rc;
> -
> - va_start(vl, fmt);
> - rc = _fcall_vdeserialize(f, fmt, vl);
> - va_end(vl);
> -
> - return rc;
> -}
> -
> -int uk_9preq_vdeserialize(struct uk_9preq *req, const char *fmt, va_list vl)
> -{
> - int rc;
> -
> - UK_ASSERT(req);
> - UK_ASSERT(UK_READ_ONCE(req->state) == UK_9PREQ_RECEIVED);
> - rc = _fcall_vdeserialize(&req->recv, fmt, vl);
> -
> - return rc;
> -}
> -
> -int uk_9preq_deserialize(struct uk_9preq *req, const char *fmt, ...)
> -{
> - va_list vl;
> - int rc;
> -
> - va_start(vl, fmt);
> - rc = uk_9preq_vdeserialize(req, fmt, vl);
> - va_end(vl);
> -
> - return rc;
> -}
> -
> -int uk_9preq_copy_to(struct uk_9preq *req, void *buf, uint32_t size)
> -{
> - return _fcall_read(&req->recv, buf, size);
> -}
> -
> -int uk_9preq_copy_from(struct uk_9preq *req, const void *buf, uint32_t size)
> -{
> - return _fcall_write(&req->xmit, buf, size);
> -}
> -
> int uk_9preq_ready(struct uk_9preq *req, enum uk_9preq_zcdir zc_dir,
> void *zc_buf, uint32_t zc_size, uint32_t zc_offset)
> {
> diff --git a/lib/uk9p/exportsyms.uk b/lib/uk9p/exportsyms.uk
> index aae9e8a..7f8e7dd 100644
> --- a/lib/uk9p/exportsyms.uk
> +++ b/lib/uk9p/exportsyms.uk
> @@ -5,12 +5,6 @@ uk_9pdev_trans_set_default
>
> uk_9preq_get
> uk_9preq_put
> -uk_9preq_vserialize
> -uk_9preq_serialize
> -uk_9preq_vdeserialize
> -uk_9preq_deserialize
> -uk_9preq_copy_to
> -uk_9preq_copy_from
> uk_9preq_receive_cb
> uk_9preq_waitreply
> uk_9preq_error
> @@ -19,7 +13,6 @@ uk_9pdev_connect
> uk_9pdev_disconnect
> uk_9pdev_request
> uk_9pdev_xmit_notify
> -uk_9pdev_call
> uk_9pdev_set_msize
> uk_9pdev_get_msize
>
> diff --git a/lib/uk9p/include/uk/9pdev.h b/lib/uk9p/include/uk/9pdev.h
> index 139498f..04ff523 100644
> --- a/lib/uk9p/include/uk/9pdev.h
> +++ b/lib/uk9p/include/uk/9pdev.h
> @@ -107,29 +107,6 @@ int uk_9pdev_request(struct uk_9pdev *dev, struct
> uk_9preq *req);
> */
> void uk_9pdev_xmit_notify(struct uk_9pdev *dev);
>
> -/**
> - * Creates and sends 9P request to the given 9P device, serializing it with
> - * the given arguments. This function acts as a shorthand for the explicit
> - * calls to req_create(), serialize(), ready(), request(), waitreply().
> - *
> - * @param dev
> - * The Unikraft 9P Device.
> - * @param type
> - * Transmit type of the request, e.g. Tversion, Tread, and so on.
> - * @param size
> - * The maximum size for the receive and send buffers.
> - * @param fmt
> - * The format of the data to be serialized, in the way uk_9preq_serialize()
> - * expects it.
> - * @param ...
> - * The arguments to be serialized.
> - * @return
> - * - (!PTRISERR): The 9p request in the UK_9PREQ_RECEIVED state.
> - * - PTRISERR: The error code with which any of the steps failed.
> - */
> -struct uk_9preq *uk_9pdev_call(struct uk_9pdev *dev, uint8_t type,
> - uint32_t size, const char *fmt, ...);
> -
> /**
> * Create a new request, automatically allocating its tag, based on its type.
> *
> diff --git a/lib/uk9p/include/uk/9preq.h b/lib/uk9p/include/uk/9preq.h
> index 70c1b03..b9713e2 100644
> --- a/lib/uk9p/include/uk/9preq.h
> +++ b/lib/uk9p/include/uk/9preq.h
> @@ -182,61 +182,6 @@ void uk_9preq_get(struct uk_9preq *req);
> */
> int uk_9preq_put(struct uk_9preq *req);
>
> -/*
> - * The following family of serialization and deserialization functions work
> - * by employing a printf-like formatting mechanism for data types supported
> by
> - * the 9p protocol:
> - * - 'b': byte (uint8_t)
> - * - 'w': word (uint16_t)
> - * - 'd': double-word (uint32_t)
> - * - 'q': quad-word (uint64_t)
> - * - 's': uk_9p_str *
> - * - 'S': uk_9p_stat *
> - *
> - * Similarly to vprintf(), the vserialize() and vdeserialize() functions take
> - * a va_list instead of a variable number of arguments.
> - *
> - * Possible return values:
> - * - 0: Operation successful.
> - * - (-EINVAL): Invalid format specifier.
> - * - (-ENOBUFS): End of buffer reached.
> - */
> -
> -int uk_9preq_vserialize(struct uk_9preq *req, const char *fmt, va_list vl);
> -int uk_9preq_serialize(struct uk_9preq *req, const char *fmt, ...);
> -int uk_9preq_vdeserialize(struct uk_9preq *req, const char *fmt, va_list vl);
> -int uk_9preq_deserialize(struct uk_9preq *req, const char *fmt, ...);
> -
> -/**
> - * Copies raw data from the request receive buffer to the provided buffer.
> - *
> - * @param req
> - * Reference to the 9p request.
> - * @param buf
> - * Destination buffer.
> - * @param size
> - * Amount to copy.
> - * Possible return values:
> - * - 0: Operation successful.
> - * - (-ENOBUFS): End of buffer reached.
> - */
> -int uk_9preq_copy_to(struct uk_9preq *req, void *buf, uint32_t size);
> -
> -/**
> - * Copies raw data from the provided buffer to the request transmission
> buffer.
> - *
> - * @param req
> - * Reference to the 9p request.
> - * @param buf
> - * Source buffer.
> - * @param size
> - * Amount to copy.
> - * Possible return values:
> - * - 0: Operation successful.
> - * - (-ENOBUFS): End of buffer reached.
> - */
> -int uk_9preq_copy_from(struct uk_9preq *req, const void *buf, uint32_t size);
> -
> /**
> * Marks the given request as being ready, transitioning between states
> * INITIALIZED and READY.
>
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |