1
0
Fork 0
forked from nuttx/nuttx-update

rpmsg: upgrade API passing on parameters with the upgrade of OpenAMP

All the rpmsg transport layer and rpmsg services sync the API
with new OpenAMP

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
This commit is contained in:
wangyongrong 2024-06-27 16:09:25 +08:00 committed by Xiang Xiao
parent 2bc9256684
commit 8e799ff823
9 changed files with 68 additions and 111 deletions

View file

@ -614,7 +614,7 @@ static int rpmsgblk_mmc_multi_cmd_ioctl(FAR struct inode *inode,
msglen = sizeof(*msg) + arglen - 1;
rsplen += sizeof(*msg) - 1;
if (MAX(msglen, rsplen) > rpmsg_get_tx_buffer_size(priv->ept.rdev))
if (MAX(msglen, rsplen) > rpmsg_get_tx_buffer_size(&priv->ept))
{
int ret = 0;

View file

@ -207,18 +207,6 @@ FAR const char *rpmsg_get_cpuname(FAR struct rpmsg_device *rdev)
return rpmsg ? rpmsg->ops->get_cpuname(rpmsg) : NULL;
}
int rpmsg_get_tx_buffer_size(FAR struct rpmsg_device *rdev)
{
FAR struct rpmsg_s *rpmsg = rpmsg_get_by_rdev(rdev);
return rpmsg ? rpmsg->ops->get_tx_buffer_size(rpmsg) : -EINVAL;
}
int rpmsg_get_rx_buffer_size(FAR struct rpmsg_device *rdev)
{
FAR struct rpmsg_s *rpmsg = rpmsg_get_by_rdev(rdev);
return rpmsg ? rpmsg->ops->get_rx_buffer_size(rpmsg) : -EINVAL;
}
int rpmsg_register_callback(FAR void *priv,
rpmsg_dev_cb_t device_created,
rpmsg_dev_cb_t device_destroy,

View file

@ -48,8 +48,6 @@
static FAR const char *
rpmsg_port_get_local_cpuname(FAR struct rpmsg_s *rpmsg);
static FAR const char *rpmsg_port_get_cpuname(FAR struct rpmsg_s *rpmsg);
static int rpmsg_port_get_tx_buffer_size(FAR struct rpmsg_s *rpmsg);
static int rpmsg_port_get_rx_buffer_size(FAR struct rpmsg_s *rpmsg);
static void rpmsg_port_dump(FAR struct rpmsg_s *rpmsg);
/****************************************************************************
@ -65,8 +63,6 @@ static const struct rpmsg_ops_s g_rpmsg_port_ops =
rpmsg_port_dump,
rpmsg_port_get_local_cpuname,
rpmsg_port_get_cpuname,
rpmsg_port_get_tx_buffer_size,
rpmsg_port_get_rx_buffer_size,
};
/****************************************************************************
@ -372,6 +368,32 @@ static int rpmsg_port_release_tx_buffer(FAR struct rpmsg_device *rdev,
return RPMSG_SUCCESS;
}
/****************************************************************************
* Name: rpmsg_port_get_tx_buffer_size
****************************************************************************/
static int rpmsg_port_get_tx_buffer_size(FAR struct rpmsg_device *rdev)
{
FAR struct rpmsg_port_s *port =
metal_container_of(rdev, struct rpmsg_port_s, rdev);
return port->txq.len - sizeof(struct rpmsg_port_header_s) -
sizeof(struct rpmsg_hdr);
}
/****************************************************************************
* Name: rpmsg_port_get_rx_buffer_size
****************************************************************************/
static int rpmsg_port_get_rx_buffer_size(FAR struct rpmsg_device *rdev)
{
FAR struct rpmsg_port_s *port =
metal_container_of(rdev, struct rpmsg_port_s, rdev);
return port->rxq.len - sizeof(struct rpmsg_port_header_s) -
sizeof(struct rpmsg_hdr);
}
/****************************************************************************
* Name: rpmsg_port_rx_callback
****************************************************************************/
@ -540,30 +562,6 @@ static FAR const char *rpmsg_port_get_cpuname(FAR struct rpmsg_s *rpmsg)
return port->cpuname;
}
/****************************************************************************
* Name: rpmsg_port_get_tx_buffer_size
****************************************************************************/
static int rpmsg_port_get_tx_buffer_size(FAR struct rpmsg_s *rpmsg)
{
FAR struct rpmsg_port_s *port = (FAR struct rpmsg_port_s *)rpmsg;
return port->txq.len - sizeof(struct rpmsg_port_header_s) -
sizeof(struct rpmsg_hdr);
}
/****************************************************************************
* Name: rpmsg_port_get_rx_buffer_size
****************************************************************************/
static int rpmsg_port_get_rx_buffer_size(FAR struct rpmsg_s *rpmsg)
{
FAR struct rpmsg_port_s *port = (FAR struct rpmsg_port_s *)rpmsg;
return port->rxq.len - sizeof(struct rpmsg_port_header_s) -
sizeof(struct rpmsg_hdr);
}
/****************************************************************************
* Public Functions
****************************************************************************/
@ -604,6 +602,8 @@ int rpmsg_port_initialize(FAR struct rpmsg_port_s *port,
rdev->ops.get_tx_payload_buffer = rpmsg_port_get_tx_payload_buffer;
rdev->ops.send_offchannel_nocopy = rpmsg_port_send_offchannel_nocopy;
rdev->ops.release_tx_buffer = rpmsg_port_release_tx_buffer;
rdev->ops.get_rx_buffer_size = rpmsg_port_get_rx_buffer_size;
rdev->ops.get_tx_buffer_size = rpmsg_port_get_tx_buffer_size;
metal_list_init(&rdev->endpoints);
@ -611,7 +611,8 @@ int rpmsg_port_initialize(FAR struct rpmsg_port_s *port,
rdev->support_ns = true;
rpmsg_register_endpoint(rdev, &rdev->ns_ept, "NS", RPMSG_NS_EPT_ADDR,
RPMSG_NS_EPT_ADDR, rpmsg_port_ns_callback, NULL);
RPMSG_NS_EPT_ADDR, rpmsg_port_ns_callback, NULL,
port);
port->ops->register_callback(port, rpmsg_port_rx_callback);
return 0;

View file

@ -85,8 +85,11 @@ static FAR const char *
rpmsg_router_edge_get_local_cpuname(FAR struct rpmsg_s *rpmsg);
static FAR const char *
rpmsg_router_edge_get_cpuname(FAR struct rpmsg_s *rpmsg);
static int rpmsg_router_edge_get_tx_buffer_size(FAR struct rpmsg_s *rpmsg);
static int rpmsg_router_edge_get_rx_buffer_size(FAR struct rpmsg_s *rpmsg);
static int
rpmsg_router_edge_get_rx_buffer_size(FAR struct rpmsg_device *rdev);
static int
rpmsg_router_edge_get_tx_buffer_size(FAR struct rpmsg_device *rdev);
/****************************************************************************
* Private Data
@ -101,8 +104,6 @@ static const struct rpmsg_ops_s g_rpmsg_router_edge_ops =
NULL,
rpmsg_router_edge_get_local_cpuname,
rpmsg_router_edge_get_cpuname,
rpmsg_router_edge_get_tx_buffer_size,
rpmsg_router_edge_get_rx_buffer_size,
};
/****************************************************************************
@ -135,30 +136,6 @@ rpmsg_router_edge_get_cpuname(FAR struct rpmsg_s *rpmsg)
return edge->remotecpu;
}
/****************************************************************************
* Name: rpmsg_router_edge_get_tx_buffer_size
****************************************************************************/
static int rpmsg_router_edge_get_tx_buffer_size(FAR struct rpmsg_s *rpmsg)
{
FAR struct rpmsg_router_edge_s *edge =
(FAR struct rpmsg_router_edge_s *)rpmsg;
return edge->tx_len;
}
/****************************************************************************
* Name: rpmsg_router_edge_get_rx_buffer_size
****************************************************************************/
static int rpmsg_router_edge_get_rx_buffer_size(FAR struct rpmsg_s *rpmsg)
{
FAR struct rpmsg_router_edge_s *edge =
(FAR struct rpmsg_router_edge_s *)rpmsg;
return edge->rx_len;
}
/****************************************************************************
* Name: rpmsg_router_edge_get_tx_payload_buffer
****************************************************************************/
@ -255,6 +232,30 @@ static int rpmsg_router_edge_send_nocopy(FAR struct rpmsg_device *rdev,
return hubdev->ops.send_offchannel_nocopy(hubdev, src, dst, data, len);
}
/****************************************************************************
* Name: rpmsg_router_edge_get_rx_buffer_size
****************************************************************************/
static int
rpmsg_router_edge_get_rx_buffer_size(FAR struct rpmsg_device *rdev)
{
FAR struct rpmsg_router_edge_s *edge = rpmsg_router_edge_from_rdev(rdev);
return edge->rx_len;
}
/****************************************************************************
* Name: rpmsg_router_edge_get_tx_buffer_size
****************************************************************************/
static int
rpmsg_router_edge_get_tx_buffer_size(FAR struct rpmsg_device *rdev)
{
FAR struct rpmsg_router_edge_s *edge = rpmsg_router_edge_from_rdev(rdev);
return edge->tx_len;
}
/****************************************************************************
* Name: rpmsg_router_edge_cb
*
@ -608,6 +609,8 @@ rpmsg_router_edge_create(FAR struct rpmsg_device *hubdev,
rdev->ops.send_offchannel_nocopy = rpmsg_router_edge_send_nocopy;
rdev->ops.send_offchannel_raw = rpmsg_router_edge_send_offchannel_raw;
rdev->ops.get_tx_payload_buffer = rpmsg_router_edge_get_tx_payload_buffer;
rdev->ops.get_rx_buffer_size = rpmsg_router_edge_get_rx_buffer_size;
rdev->ops.get_tx_buffer_size = rpmsg_router_edge_get_tx_buffer_size;
metal_list_init(&rdev->endpoints);
rdev->support_ack = true;

View file

@ -322,10 +322,10 @@ static void rpmsg_router_bound(FAR struct rpmsg_endpoint *ept)
for (i = 0; i < 2; i++)
{
msg.cmd = RPMSG_ROUTER_CREATE;
msg.tx_len = MIN(rpmsg_get_rx_buffer_size(hub->ept[i].rdev),
rpmsg_get_tx_buffer_size(hub->ept[1 - i].rdev));
msg.rx_len = MIN(rpmsg_get_tx_buffer_size(hub->ept[i].rdev),
rpmsg_get_rx_buffer_size(hub->ept[1 - i].rdev));
msg.tx_len = MIN(rpmsg_get_rx_buffer_size(&hub->ept[i]),
rpmsg_get_tx_buffer_size(&hub->ept[1 - i]));
msg.rx_len = MIN(rpmsg_get_tx_buffer_size(&hub->ept[i]),
rpmsg_get_rx_buffer_size(&hub->ept[1 - i]));
strlcpy(msg.cpuname, hub->cpuname[i], sizeof(msg.cpuname));
ret = rpmsg_send(&hub->ept[i], &msg, sizeof(msg));
DEBUGASSERT(ret >= 0);

View file

@ -74,8 +74,6 @@ static void rpmsg_virtio_dump(FAR struct rpmsg_s *rpmsg);
static FAR const char *
rpmsg_virtio_get_local_cpuname(FAR struct rpmsg_s *rpmsg);
static FAR const char *rpmsg_virtio_get_cpuname(FAR struct rpmsg_s *rpmsg);
static int rpmsg_virtio_get_tx_buffer_size(FAR struct rpmsg_s *rpmsg);
static int rpmsg_virtio_get_rx_buffer_size_(FAR struct rpmsg_s *rpmsg);
static int rpmsg_virtio_create_virtqueues_(FAR struct virtio_device *vdev,
unsigned int flags,
@ -102,8 +100,6 @@ static const struct rpmsg_ops_s g_rpmsg_virtio_ops =
.dump = rpmsg_virtio_dump,
.get_local_cpuname = rpmsg_virtio_get_local_cpuname,
.get_cpuname = rpmsg_virtio_get_cpuname,
.get_tx_buffer_size = rpmsg_virtio_get_tx_buffer_size,
.get_rx_buffer_size = rpmsg_virtio_get_rx_buffer_size_,
};
static const struct virtio_dispatch g_rpmsg_virtio_dispatch =
@ -429,16 +425,6 @@ static FAR const char *rpmsg_virtio_get_cpuname(FAR struct rpmsg_s *rpmsg)
return RPMSG_VIRTIO_GET_CPUNAME(priv->dev);
}
static int rpmsg_virtio_get_tx_buffer_size(FAR struct rpmsg_s *rpmsg)
{
return rpmsg_virtio_get_buffer_size(rpmsg->rdev);
}
static int rpmsg_virtio_get_rx_buffer_size_(FAR struct rpmsg_s *rpmsg)
{
return rpmsg_virtio_get_rx_buffer_size(rpmsg->rdev);
}
static void rpmsg_virtio_wakeup_rx(FAR struct rpmsg_virtio_priv_s *priv)
{
int semcount;

View file

@ -129,8 +129,6 @@ static void rptun_panic(FAR struct rpmsg_s *rpmsg);
static void rptun_dump(FAR struct rpmsg_s *rpmsg);
static FAR const char *rptun_get_local_cpuname(FAR struct rpmsg_s *rpmsg);
static FAR const char *rptun_get_cpuname(FAR struct rpmsg_s *rpmsg);
static int rptun_get_tx_buffer_size(FAR struct rpmsg_s *rpmsg);
static int rptun_get_rx_buffer_size(FAR struct rpmsg_s *rpmsg);
/****************************************************************************
* Private Data
@ -167,8 +165,6 @@ static const struct rpmsg_ops_s g_rptun_rpmsg_ops =
rptun_dump,
rptun_get_local_cpuname,
rptun_get_cpuname,
rptun_get_tx_buffer_size,
rptun_get_rx_buffer_size,
};
/****************************************************************************
@ -769,16 +765,6 @@ static FAR const char *rptun_get_cpuname(FAR struct rpmsg_s *rpmsg)
return RPTUN_GET_CPUNAME(priv->dev);
}
static int rptun_get_tx_buffer_size(FAR struct rpmsg_s *rpmsg)
{
return rpmsg_virtio_get_buffer_size(rpmsg->rdev);
}
static int rptun_get_rx_buffer_size(FAR struct rpmsg_s *rpmsg)
{
return rpmsg_virtio_get_rx_buffer_size(rpmsg->rdev);
}
static int rptun_dev_start(FAR struct remoteproc *rproc)
{
FAR struct rptun_priv_s *priv = rproc->priv;

View file

@ -616,8 +616,8 @@ static int rpmsgfs_readdir_handler(FAR struct rpmsg_endpoint *ept,
entry = readdir(dir);
if (entry)
{
size = MIN(rpmsg_get_tx_buffer_size(ept->rdev),
rpmsg_get_rx_buffer_size(ept->rdev));
size = MIN(rpmsg_get_tx_buffer_size(ept),
rpmsg_get_rx_buffer_size(ept));
size = MIN(size - len, strlen(entry->d_name) + 1);
msg->type = entry->d_type;
strlcpy(msg->name, entry->d_name, size);

View file

@ -65,8 +65,6 @@ struct rpmsg_s
* wait: wait sem.
* post: post sem.
* get_cpuname: get cpu name.
* get_tx_buffer_size: get tx buffer size.
* get_rx_buffer_size: get rx buffer size.
*/
struct rpmsg_ops_s
@ -78,8 +76,6 @@ struct rpmsg_ops_s
CODE void (*dump)(FAR struct rpmsg_s *rpmsg);
CODE FAR const char *(*get_local_cpuname)(FAR struct rpmsg_s *rpmsg);
CODE FAR const char *(*get_cpuname)(FAR struct rpmsg_s *rpmsg);
CODE int (*get_tx_buffer_size)(FAR struct rpmsg_s *rpmsg);
CODE int (*get_rx_buffer_size)(FAR struct rpmsg_s *rpmsg);
};
CODE typedef void (*rpmsg_dev_cb_t)(FAR struct rpmsg_device *rdev,
@ -109,9 +105,6 @@ int rpmsg_post(FAR struct rpmsg_endpoint *ept, FAR sem_t *sem);
FAR const char *rpmsg_get_local_cpuname(FAR struct rpmsg_device *rdev);
FAR const char *rpmsg_get_cpuname(FAR struct rpmsg_device *rdev);
int rpmsg_get_tx_buffer_size(FAR struct rpmsg_device *rdev);
int rpmsg_get_rx_buffer_size(FAR struct rpmsg_device *rdev);
int rpmsg_register_callback(FAR void *priv,
rpmsg_dev_cb_t device_created,
rpmsg_dev_cb_t device_destroy,