forked from nuttx/nuttx-update
drivers/net/phy_notify.c and all network drivers that support PHY notifications: Support the signal notification through SIGEV_THREAD
This commit is contained in:
parent
5e8ae23edc
commit
d105dc9b5e
13 changed files with 27 additions and 45 deletions
|
@ -1752,7 +1752,7 @@ static int imxrt_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg);
|
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
/* Enable PHY link up/down interrupts */
|
/* Enable PHY link up/down interrupts */
|
||||||
|
|
|
@ -2763,7 +2763,7 @@ static int lpc43_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg);
|
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
/* Enable PHY link up/down interrupts */
|
/* Enable PHY link up/down interrupts */
|
||||||
|
|
|
@ -2328,7 +2328,7 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg);
|
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
/* Enable PHY link up/down interrupts */
|
/* Enable PHY link up/down interrupts */
|
||||||
|
|
|
@ -2364,7 +2364,7 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg);
|
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
/* Enable PHY link up/down interrupts */
|
/* Enable PHY link up/down interrupts */
|
||||||
|
|
|
@ -2731,7 +2731,7 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg);
|
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
/* Enable PHY link up/down interrupts */
|
/* Enable PHY link up/down interrupts */
|
||||||
|
|
|
@ -2319,7 +2319,7 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg);
|
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
/* Enable PHY link up/down interrupts */
|
/* Enable PHY link up/down interrupts */
|
||||||
|
|
|
@ -3215,7 +3215,7 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg);
|
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
/* Enable PHY link up/down interrupts */
|
/* Enable PHY link up/down interrupts */
|
||||||
|
|
|
@ -2875,7 +2875,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg);
|
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
/* Enable PHY link up/down interrupts */
|
/* Enable PHY link up/down interrupts */
|
||||||
|
|
|
@ -2977,7 +2977,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg);
|
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
/* Enable PHY link up/down interrupts */
|
/* Enable PHY link up/down interrupts */
|
||||||
|
|
|
@ -2876,7 +2876,7 @@ static int tiva_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg);
|
||||||
|
|
||||||
ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg);
|
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
/* Enable PHY link up/down interrupts */
|
/* Enable PHY link up/down interrupts */
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
@ -102,10 +101,9 @@
|
||||||
struct phy_notify_s
|
struct phy_notify_s
|
||||||
{
|
{
|
||||||
bool assigned;
|
bool assigned;
|
||||||
uint8_t signo;
|
|
||||||
char intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1];
|
char intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
FAR void *arg;
|
struct sigevent event;
|
||||||
phy_enable_t enable;
|
phy_enable_t enable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -177,10 +175,8 @@ static FAR struct phy_notify_s *phy_find_unassigned(void)
|
||||||
/* Assign and re-initialized the entry */
|
/* Assign and re-initialized the entry */
|
||||||
|
|
||||||
client->assigned = true;
|
client->assigned = true;
|
||||||
client->signo = 0;
|
|
||||||
client->intf[0] = '\0';
|
client->intf[0] = '\0';
|
||||||
client->pid = -1;
|
client->pid = -1;
|
||||||
client->arg = NULL;
|
|
||||||
client->enable = NULL;
|
client->enable = NULL;
|
||||||
|
|
||||||
/* Return the client entry assigned to the caller */
|
/* Return the client entry assigned to the caller */
|
||||||
|
@ -236,13 +232,10 @@ static FAR struct phy_notify_s *phy_find_assigned(FAR const char *intf,
|
||||||
static int phy_handler(int irq, FAR void *context, FAR void *arg)
|
static int phy_handler(int irq, FAR void *context, FAR void *arg)
|
||||||
{
|
{
|
||||||
FAR struct phy_notify_s *client = (FAR struct phy_notify_s *)arg;
|
FAR struct phy_notify_s *client = (FAR struct phy_notify_s *)arg;
|
||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
|
||||||
union sigval value;
|
|
||||||
#endif
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DEBUGASSERT(client != NULL && client->assigned && client->enable);
|
DEBUGASSERT(client != NULL && client->assigned && client->enable);
|
||||||
phyinfo("Signalling PID=%d with signal %d\n", client->pid, client->signo);
|
phyinfo("Signaling PID=%d with event %p\n", client->pid, &client->event);
|
||||||
|
|
||||||
/* Disable further interrupts */
|
/* Disable further interrupts */
|
||||||
|
|
||||||
|
@ -250,16 +243,10 @@ static int phy_handler(int irq, FAR void *context, FAR void *arg)
|
||||||
|
|
||||||
/* Signal the client that the PHY has something interesting to say to us */
|
/* Signal the client that the PHY has something interesting to say to us */
|
||||||
|
|
||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
ret = nxsig_notification(client->pid, &client->event, SI_QUEUE);
|
||||||
value.sival_ptr = client->arg;
|
|
||||||
ret = nxsig_queue(client->pid, client->signo, value);
|
|
||||||
#else
|
|
||||||
ret = nxsig_queue(client->pid, client->signo, client->arg);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
phyerr("ERROR: nxsig_queue failed: %d\n", ret);
|
phyerr("ERROR: nxsig_notification failed: %d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
@ -287,23 +274,22 @@ static int phy_handler(int irq, FAR void *context, FAR void *arg)
|
||||||
* terminator). Configurable with CONFIG_PHY_NOTIFICATION_MAXINTFLEN.
|
* terminator). Configurable with CONFIG_PHY_NOTIFICATION_MAXINTFLEN.
|
||||||
* pid - Identifies the task to receive the signal. The special value
|
* pid - Identifies the task to receive the signal. The special value
|
||||||
* of zero means to use the pid of the current task.
|
* of zero means to use the pid of the current task.
|
||||||
* signo - This is the signal number to use when notifying the task.
|
* event - Describes the way a task is to be notified
|
||||||
* arg - An argument that will accompany the notification signal.
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success; Negated errno on failure.
|
* OK on success; Negated errno on failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int phy_notify_subscribe(FAR const char *intf, pid_t pid, int signo,
|
int phy_notify_subscribe(FAR const char *intf, pid_t pid,
|
||||||
FAR void *arg)
|
FAR struct sigevent *event)
|
||||||
{
|
{
|
||||||
FAR struct phy_notify_s *client;
|
FAR struct phy_notify_s *client;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
DEBUGASSERT(intf);
|
DEBUGASSERT(intf);
|
||||||
|
|
||||||
phyinfo("%s: PID=%d signo=%d arg=%p\n", intf, pid, signo, arg);
|
phyinfo("%s: PID=%d event=%p\n", intf, pid, event);
|
||||||
|
|
||||||
/* The special value pid == 0 means to use the pid of the current task. */
|
/* The special value pid == 0 means to use the pid of the current task. */
|
||||||
|
|
||||||
|
@ -320,8 +306,7 @@ int phy_notify_subscribe(FAR const char *intf, pid_t pid, int signo,
|
||||||
{
|
{
|
||||||
/* Yes.. update the signal number and argument */
|
/* Yes.. update the signal number and argument */
|
||||||
|
|
||||||
client->signo = signo;
|
client->event = *event;
|
||||||
client->arg = arg;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -336,9 +321,8 @@ int phy_notify_subscribe(FAR const char *intf, pid_t pid, int signo,
|
||||||
|
|
||||||
/* Initialize the new client entry */
|
/* Initialize the new client entry */
|
||||||
|
|
||||||
client->signo = signo;
|
|
||||||
client->pid = pid;
|
client->pid = pid;
|
||||||
client->arg = arg;
|
client->event = *event;
|
||||||
snprintf(client->intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1, intf);
|
snprintf(client->intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1, intf);
|
||||||
client->intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN] = '\0';
|
client->intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN] = '\0';
|
||||||
|
|
||||||
|
@ -399,10 +383,8 @@ int phy_notify_unsubscribe(FAR const char *intf, pid_t pid)
|
||||||
/* Un-initialize the client entry */
|
/* Un-initialize the client entry */
|
||||||
|
|
||||||
client->assigned = false;
|
client->assigned = false;
|
||||||
client->signo = 0;
|
|
||||||
client->intf[0] = '\0';
|
client->intf[0] = '\0';
|
||||||
client->pid = -1;
|
client->pid = -1;
|
||||||
client->arg = NULL;
|
|
||||||
|
|
||||||
phy_semgive();
|
phy_semgive();
|
||||||
return OK;
|
return OK;
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
* Included Files
|
* Included Files
|
||||||
*******************************************************************************************/
|
*******************************************************************************************/
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
|
@ -119,9 +120,8 @@
|
||||||
|
|
||||||
struct mii_iotcl_notify_s
|
struct mii_iotcl_notify_s
|
||||||
{
|
{
|
||||||
pid_t pid; /* PID of the task to receive the signal. Zero means "this task" */
|
pid_t pid; /* PID of the task to receive the signal. Zero means "this task" */
|
||||||
uint8_t signo; /* Signal number to use when signalling */
|
struct sigevent event; /* Describe the way a task is to be notified */
|
||||||
FAR void *arg; /* An argument that will accompany the signal callback */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Structure passed to read from or write to the MII/PHY management interface via the
|
/* Structure passed to read from or write to the MII/PHY management interface via the
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -103,8 +104,7 @@ extern "C"
|
||||||
* terminator). Configurable with CONFIG_PHY_NOTIFICATION_MAXINTFLEN.
|
* terminator). Configurable with CONFIG_PHY_NOTIFICATION_MAXINTFLEN.
|
||||||
* pid - Identifies the task to receive the signal. The special value
|
* pid - Identifies the task to receive the signal. The special value
|
||||||
* of zero means to use the pid of the current task.
|
* of zero means to use the pid of the current task.
|
||||||
* signo - This is the signal number to use when notifying the task.
|
* event - Describe the way a task is to be notified
|
||||||
* arg - An argument that will accompany the notification signal.
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success; Negated errno on failure.
|
* OK on success; Negated errno on failure.
|
||||||
|
@ -112,8 +112,8 @@ extern "C"
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_PHY_INTERRUPT
|
#ifdef CONFIG_ARCH_PHY_INTERRUPT
|
||||||
int phy_notify_subscribe(FAR const char *intf, pid_t pid, int signo,
|
int phy_notify_subscribe(FAR const char *intf, pid_t pid,
|
||||||
FAR void *arg);
|
FAR struct sigevent *event);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
Loading…
Reference in a new issue