mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 16:59:28 +08:00
drivers/rpmsg_router: rename dst_ept to peer_ept
peer_ept is a better name than dst_ept Signed-off-by: yintao <yintao@xiaomi.com>
This commit is contained in:
@@ -73,15 +73,15 @@ struct rpmsg_router_hub_s
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This is the callback function for router core.
|
* This is the callback function for router core.
|
||||||
* It will receive data from source edge core by ept(r:cpu:name), and find
|
* It will receive data from source edge core by ept(r:peer_cpu:name),
|
||||||
* dest edge core communicating with it, send data to dest edge core.
|
* and send data to peer edge's endpoint.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* ept - rpmsg_endpoint for communicating with edge core (r:dst_cpu:name)
|
* ept - endpoint for communicating with edge core (r:peer_cpu:name)
|
||||||
* data - received data
|
* data - received data
|
||||||
* len - received data length
|
* len - received data length
|
||||||
* src - source address
|
* src - source address
|
||||||
* priv - save dest edge core rpmsg_endpoint (r:src_cpu:name)
|
* priv - save peer edge core rpmsg_endpoint (r:src_cpu:name)
|
||||||
*
|
*
|
||||||
* Returned Values:
|
* Returned Values:
|
||||||
* Returns number of bytes it has sent or negative error value on failure.
|
* Returns number of bytes it has sent or negative error value on failure.
|
||||||
@@ -92,17 +92,17 @@ static int rpmsg_router_hub_cb(FAR struct rpmsg_endpoint *ept,
|
|||||||
FAR void *data, size_t len,
|
FAR void *data, size_t len,
|
||||||
uint32_t src, FAR void *priv)
|
uint32_t src, FAR void *priv)
|
||||||
{
|
{
|
||||||
FAR struct rpmsg_endpoint *dst_ept = priv;
|
FAR struct rpmsg_endpoint *peer_ept = priv;
|
||||||
|
|
||||||
/* Retransmit data to dest edge core */
|
/* Retransmit data to dest edge core */
|
||||||
|
|
||||||
if (!dst_ept)
|
if (!peer_ept)
|
||||||
{
|
{
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
rpmsg_send_offchannel_raw(dst_ept, dst_ept->addr,
|
rpmsg_send_offchannel_raw(peer_ept, peer_ept->addr,
|
||||||
dst_ept->dest_addr, data, len, true);
|
peer_ept->dest_addr, data, len, true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,6 +127,7 @@ static void rpmsg_router_hub_ept_release(FAR struct rpmsg_endpoint *ept)
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This is the unbind callback function for router core.
|
* This is the unbind callback function for router core.
|
||||||
|
* it will send NS_DESTROY to peer endpoint and destroy source endpoint.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* ept - rpmsg_endpoint for communicating with edge core (r:cpu:name)
|
* ept - rpmsg_endpoint for communicating with edge core (r:cpu:name)
|
||||||
@@ -135,20 +136,20 @@ static void rpmsg_router_hub_ept_release(FAR struct rpmsg_endpoint *ept)
|
|||||||
|
|
||||||
static void rpmsg_router_hub_unbind(FAR struct rpmsg_endpoint *ept)
|
static void rpmsg_router_hub_unbind(FAR struct rpmsg_endpoint *ept)
|
||||||
{
|
{
|
||||||
FAR struct rpmsg_endpoint *dst_ept = ept->priv;
|
FAR struct rpmsg_endpoint *peer_ept = ept->priv;
|
||||||
FAR struct rpmsg_device *rdev = dst_ept->rdev;
|
FAR struct rpmsg_device *rdev = peer_ept->rdev;
|
||||||
|
|
||||||
rpmsg_destroy_ept(ept);
|
rpmsg_destroy_ept(ept);
|
||||||
if (dst_ept->cb)
|
if (peer_ept->cb)
|
||||||
{
|
{
|
||||||
rpmsg_send_ns_message(dst_ept, RPMSG_NS_DESTROY);
|
rpmsg_send_ns_message(peer_ept, RPMSG_NS_DESTROY);
|
||||||
metal_mutex_acquire(&rdev->lock);
|
metal_mutex_acquire(&rdev->lock);
|
||||||
rpmsg_ept_decref(dst_ept);
|
rpmsg_ept_decref(peer_ept);
|
||||||
metal_mutex_release(&rdev->lock);
|
metal_mutex_release(&rdev->lock);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
kmm_free(dst_ept);
|
kmm_free(peer_ept);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,11 +158,10 @@ static void rpmsg_router_hub_unbind(FAR struct rpmsg_endpoint *ept)
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This is the bound callback function for router core.
|
* This is the bound callback function for router core.
|
||||||
* It will create endpoint to source edge after dest edge
|
* It will create endpoint to source edge after peer's endpoint is bound.
|
||||||
* core is bound.
|
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* ept - rpmsg_endpoint for communicating with edge core (r:cpu:name)
|
* ept - peer's endpoint for communicating with edge core (r:src_cpu:name)
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ static void rpmsg_router_hub_bound(FAR struct rpmsg_endpoint *ept)
|
|||||||
FAR struct rpmsg_device *rdev = ept->rdev;
|
FAR struct rpmsg_device *rdev = ept->rdev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Create endpoint (r:dst_cpu:name) and send ACK to source edge core */
|
/* Create endpoint (r:peer_cpu:name) and send ACK to source edge core */
|
||||||
|
|
||||||
ret = rpmsg_create_ept(src_ept, src_ept->rdev, src_ept->name,
|
ret = rpmsg_create_ept(src_ept, src_ept->rdev, src_ept->name,
|
||||||
RPMSG_ADDR_ANY, src_ept->dest_addr,
|
RPMSG_ADDR_ANY, src_ept->dest_addr,
|
||||||
@@ -198,7 +198,7 @@ static void rpmsg_router_hub_bound(FAR struct rpmsg_endpoint *ept)
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* rdev - real rpmsg device
|
* rdev - real rpmsg device
|
||||||
* priv - rpmsg router hub for router core
|
* priv - rpmsg router hub for router core
|
||||||
* name - endpoint name (r:dst_cpu:name)
|
* name - endpoint name (r:peer_cpu:name)
|
||||||
* dest - destination address
|
* dest - destination address
|
||||||
*
|
*
|
||||||
* Returned Values:
|
* Returned Values:
|
||||||
@@ -244,14 +244,14 @@ static bool rpmsg_router_hub_match(FAR struct rpmsg_device *rdev,
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This function is used to bind the router core device.
|
* This function is used to bind the router core device.
|
||||||
* It will try to create endpoint (r:src_cpu:name) to another dest cpu.
|
* It will try to create endpoint (r:src_cpu:name) to peer cpu.
|
||||||
* The source endpoint information will be saved in the private field of
|
* The source endpoint information will be saved in the private field of
|
||||||
* the dest endpoint.
|
* the peer endpoint.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* rdev - real rpmsg device
|
* rdev - real rpmsg device
|
||||||
* priv - rpmsg router hub for router core
|
* priv - rpmsg router hub for router core
|
||||||
* name - source edge core endpoint name (r:dst_cpu:name)
|
* name - source edge core endpoint name (r:peer_cpu:name)
|
||||||
* dest - destination address
|
* dest - destination address
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -262,9 +262,9 @@ static void rpmsg_router_hub_bind(FAR struct rpmsg_device *rdev,
|
|||||||
{
|
{
|
||||||
FAR struct rpmsg_router_hub_s *hub = priv;
|
FAR struct rpmsg_router_hub_s *hub = priv;
|
||||||
FAR struct rpmsg_endpoint *src_ept;
|
FAR struct rpmsg_endpoint *src_ept;
|
||||||
FAR struct rpmsg_endpoint *dst_ept;
|
FAR struct rpmsg_endpoint *peer_ept;
|
||||||
FAR struct rpmsg_device *dst_rdev;
|
FAR struct rpmsg_device *peer_rdev;
|
||||||
char dst_name[RPMSG_NAME_SIZE];
|
char peer_name[RPMSG_NAME_SIZE];
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -291,37 +291,37 @@ static void rpmsg_router_hub_bind(FAR struct rpmsg_device *rdev,
|
|||||||
|
|
||||||
DEBUGASSERT(i < 2);
|
DEBUGASSERT(i < 2);
|
||||||
|
|
||||||
dst_rdev = hub->ept[1 - i].rdev;
|
peer_rdev = hub->ept[1 - i].rdev;
|
||||||
snprintf(dst_name, RPMSG_NAME_SIZE,
|
snprintf(peer_name, RPMSG_NAME_SIZE,
|
||||||
RPMSG_ROUTER_NAME_PREFIX"%s%s", hub->cpuname[i],
|
RPMSG_ROUTER_NAME_PREFIX"%s%s", hub->cpuname[i],
|
||||||
name + RPMSG_ROUTER_NAME_PREFIX_LEN +
|
name + RPMSG_ROUTER_NAME_PREFIX_LEN +
|
||||||
strlen(hub->cpuname[1 - i]));
|
strlen(hub->cpuname[1 - i]));
|
||||||
|
|
||||||
src_ept = kmm_zalloc(sizeof(*src_ept));
|
src_ept = kmm_zalloc(sizeof(*src_ept));
|
||||||
dst_ept = kmm_zalloc(sizeof(*dst_ept));
|
peer_ept = kmm_zalloc(sizeof(*peer_ept));
|
||||||
|
|
||||||
DEBUGASSERT(src_ept && dst_ept);
|
DEBUGASSERT(src_ept && peer_ept);
|
||||||
|
|
||||||
/* Save information for the ept(r:dst_cpu:name) of the source cpu */
|
/* Save information for the source ept(r:peer_cpu:name) */
|
||||||
|
|
||||||
src_ept->priv = dst_ept;
|
src_ept->priv = peer_ept;
|
||||||
src_ept->rdev = rdev;
|
src_ept->rdev = rdev;
|
||||||
src_ept->dest_addr = dest;
|
src_ept->dest_addr = dest;
|
||||||
src_ept->release_cb = rpmsg_router_hub_ept_release;
|
src_ept->release_cb = rpmsg_router_hub_ept_release;
|
||||||
strlcpy(src_ept->name, name, sizeof(src_ept->name));
|
strlcpy(src_ept->name, name, sizeof(src_ept->name));
|
||||||
|
|
||||||
/* Create endpoint (r:src_cpu:name) to another dest cpu */
|
/* Create endpoint (r:src_cpu:name) to the peer cpu */
|
||||||
|
|
||||||
dst_ept->priv = src_ept;
|
peer_ept->priv = src_ept;
|
||||||
dst_ept->ns_bound_cb = rpmsg_router_hub_bound;
|
peer_ept->ns_bound_cb = rpmsg_router_hub_bound;
|
||||||
dst_ept->release_cb = rpmsg_router_hub_ept_release;
|
peer_ept->release_cb = rpmsg_router_hub_ept_release;
|
||||||
ret = rpmsg_create_ept(dst_ept, dst_rdev, dst_name,
|
ret = rpmsg_create_ept(peer_ept, peer_rdev, peer_name,
|
||||||
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
|
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
|
||||||
rpmsg_router_hub_cb,
|
rpmsg_router_hub_cb,
|
||||||
rpmsg_router_hub_unbind);
|
rpmsg_router_hub_unbind);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
kmm_free(dst_ept);
|
kmm_free(peer_ept);
|
||||||
kmm_free(src_ept);
|
kmm_free(src_ept);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user