feature: pointer of netdev ioctl support cross-core access via clean dcache
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
parent
61007bcdb6
commit
6c2a487f85
@ -27,6 +27,11 @@
|
||||
|
||||
#include <nuttx/net/usrsock.h>
|
||||
|
||||
#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
|
||||
# include <nuttx/wireless/wireless.h>
|
||||
# include <metal/cache.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor definitions
|
||||
****************************************************************************/
|
||||
@ -35,6 +40,16 @@
|
||||
|
||||
#define USRSOCK_RPMSG_DNS_EVENT 127
|
||||
|
||||
#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
|
||||
# define WL_IS80211POINTERCMD(cmd) ((cmd) == SIOCGIWSCAN || \
|
||||
(cmd) == SIOCSIWCOUNTRY || \
|
||||
(cmd) == SIOCGIWRANGE || \
|
||||
(cmd) == SIOCSIWENCODEEXT || \
|
||||
(cmd) == SIOCGIWENCODEEXT || \
|
||||
(cmd) == SIOCGIWESSID || \
|
||||
(cmd) == SIOCSIWESSID)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
@ -49,6 +49,12 @@ struct usrsock_rpmsg_s
|
||||
struct file file;
|
||||
};
|
||||
|
||||
enum usrsock_cache_action_e
|
||||
{
|
||||
USRSOCK_COHERENT_BEFORE,
|
||||
USRSOCK_COHERENT_AFTER,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
@ -155,6 +161,41 @@ static int usrsock_rpmsg_ept_cb(struct rpmsg_endpoint *ept, void *data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
|
||||
|
||||
static void usersock_coherent_cache(FAR void *buf,
|
||||
enum usrsock_cache_action_e action)
|
||||
{
|
||||
FAR struct usrsock_request_ioctl_s *req = buf;
|
||||
FAR struct iwreq *wlreq;
|
||||
|
||||
if (req->head.reqid == USRSOCK_REQUEST_IOCTL)
|
||||
{
|
||||
if (WL_IS80211POINTERCMD(req->cmd))
|
||||
{
|
||||
wlreq = (FAR struct iwreq *)(req + 1);
|
||||
if (action == USRSOCK_COHERENT_BEFORE)
|
||||
{
|
||||
metal_cache_flush(wlreq->u.data.pointer,
|
||||
wlreq->u.data.length);
|
||||
}
|
||||
|
||||
if (action == USRSOCK_COHERENT_AFTER)
|
||||
{
|
||||
metal_cache_invalidate(wlreq->u.data.pointer,
|
||||
wlreq->u.data.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
static void usersock_coherent_cache(FAR void *buf,
|
||||
enum usrsock_cache_action_e action)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -251,6 +292,8 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
usersock_coherent_cache(buf, USRSOCK_COHERENT_BEFORE);
|
||||
|
||||
/* Send the packet to remote */
|
||||
|
||||
ret = rpmsg_send_nocopy(&priv.ept, buf, ret);
|
||||
@ -258,6 +301,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
usersock_coherent_cache(buf, USRSOCK_COHERENT_AFTER);
|
||||
}
|
||||
|
||||
/* Reclaim the resource */
|
||||
|
@ -716,9 +716,26 @@ static int usrsock_rpmsg_ioctl_handler(struct rpmsg_endpoint *ept,
|
||||
if (req->usockid >= 0 &&
|
||||
req->usockid < CONFIG_NETUTILS_USRSOCK_NSOCK_DESCRIPTORS)
|
||||
{
|
||||
#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
|
||||
FAR struct iwreq *wlreq = (FAR struct iwreq *)(req + 1);
|
||||
if (WL_IS80211POINTERCMD(req->cmd))
|
||||
{
|
||||
metal_cache_invalidate(wlreq->u.data.pointer,
|
||||
wlreq->u.data.length);
|
||||
}
|
||||
#endif
|
||||
|
||||
memcpy(ack + 1, req + 1, req->arglen);
|
||||
ret = psock_ioctl(&priv->socks[req->usockid],
|
||||
req->cmd, (unsigned long)(ack + 1));
|
||||
|
||||
#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
|
||||
if (WL_IS80211POINTERCMD(req->cmd))
|
||||
{
|
||||
metal_cache_flush(wlreq->u.data.pointer,
|
||||
wlreq->u.data.length);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return usrsock_rpmsg_send_data_ack(ept,
|
||||
|
Loading…
Reference in New Issue
Block a user