summaryrefslogtreecommitdiff
path: root/nuttx/include/nuttx/net
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-08-16 12:56:02 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-08-16 12:56:02 -0600
commitb803a9d7d9c0f55829123a8674d1cb991a06c54a (patch)
treed9d6c3de358cf9131310299ad45a1accbd5ab25d /nuttx/include/nuttx/net
parent61b76c886f04582459709e62c4f3acb09946e3d0 (diff)
downloadnuttx-b803a9d7d9c0f55829123a8674d1cb991a06c54a.tar.gz
nuttx-b803a9d7d9c0f55829123a8674d1cb991a06c54a.tar.bz2
nuttx-b803a9d7d9c0f55829123a8674d1cb991a06c54a.zip
Add support for an ioctl that can be used to notify an application when there is a change in the network status signalled by a PHY interrupt
Diffstat (limited to 'nuttx/include/nuttx/net')
-rw-r--r--nuttx/include/nuttx/net/ioctl.h7
-rw-r--r--nuttx/include/nuttx/net/phy.h149
2 files changed, 153 insertions, 3 deletions
diff --git a/nuttx/include/nuttx/net/ioctl.h b/nuttx/include/nuttx/net/ioctl.h
index 7c2e1cb49..549d571ea 100644
--- a/nuttx/include/nuttx/net/ioctl.h
+++ b/nuttx/include/nuttx/net/ioctl.h
@@ -162,9 +162,10 @@
/* MDIO/MCD *****************************************************************/
-#define SIOCGMIIPHY _SIOC(0x0042) /* Get address of MII PHY in use */
-#define SIOCGMIIREG _SIOC(0x0043) /* Get a MII register via MDIO */
-#define SIOCSMIIREG _SIOC(0x0044) /* Set a MII register via MDIO */
+#define SIOCMIISIG _SIOC(0x0042) /* Receive signal on PHY interrupt */
+#define SIOCGMIIPHY _SIOC(0x0043) /* Get address of MII PHY in use */
+#define SIOCGMIIREG _SIOC(0x0044) /* Get a MII register via MDIO */
+#define SIOCSMIIREG _SIOC(0x0045) /* Set a MII register via MDIO */
/****************************************************************************
* Type Definitions
diff --git a/nuttx/include/nuttx/net/phy.h b/nuttx/include/nuttx/net/phy.h
new file mode 100644
index 000000000..6e7645af3
--- /dev/null
+++ b/nuttx/include/nuttx/net/phy.h
@@ -0,0 +1,149 @@
+/****************************************************************************
+ * include/nuttx/net/phy.h
+ *
+ * Copyright (C) 2014 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Includes some definitions that a compatible with the LGPL GNU C Library
+ * header file of the same name.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_NET_PHY_H
+#define __INCLUDE_NUTTX_NET_PHY_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+/****************************************************************************
+ * Public Type Definitions
+ ****************************************************************************/
+/* Configuration ************************************************************/
+/* Prerequisites: CONFIG_DISABLE_SIGNALS must not be defined */
+
+#ifdef CONFIG_DISABLE_SIGNALS
+# undef CONFIG_ARCH_PHY_INTERRUPT
+#endif
+
+/* Maximum number of phy_notify clients */
+
+#ifndef CONFIG_PHY_NOTIFICATION_NCLIENTS
+# define CONFIG_PHY_NOTIFICATION_NCLIENTS 1
+#endif
+
+/* Maximum length of on interface device name (excluding NULL termination) */
+
+#ifndef CONFIG_PHY_NOTIFICATION_MAXINTFLEN
+# define CONFIG_PHY_NOTIFICATION_MAXINTFLEN 4
+#endif
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Function: phy_notify_subscribe
+ *
+ * Description:
+ * Setup up to deliver signals to the task identified by 'pid' when
+ * there is any change indicated by an interrupt from the PHY associated
+ * with 'intf'
+ *
+ * NOTE: This function is intended to be called only from an Ethernet
+ * driver in support of the SIOCMIISIG ioctl command. It should never
+ * by called directly by application logic.
+ *
+ * Parameters:
+ * intf - Provides the name of the network interface, for example, "eth0".
+ * The length of intf must not exceed 4 bytes (excluding NULL
+ * terminator). Configurable with CONFIG_PHY_NOTIFICATION_MAXINTFLEN.
+ * pid - Identifies the task to receive the signal.
+ * signo - This is the signal number to use when notifying the task.
+ * arg - An argument that will accompany the notification signal.
+ *
+ * Returned Value:
+ * OK on success; Negated errno on failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_PHY_INTERRUPT
+int phy_notify_subscribe(FAR const char *intf, pid_t pid, int signo,
+ FAR void *arg);
+#endif
+
+/****************************************************************************
+ * Function: phy_notify_unsubscribe
+ *
+ * Description:
+ * Stop the deliver of signals for events from the PHY associated with
+ * 'intf' to the task identified by 'pid'
+ *
+ * NOTE: This function is intended to be called only from an Ethernet
+ * driver in support of the SIOCMIISIG ioctl command. It should never
+ * by called directly by application logic.
+ *
+ * Parameters:
+ * intf - Provides the name of the network interface, for example, "eth0".
+ * The length of 'intf' must not exceed 4 bytes (excluding NULL
+ * terminator). Configurable with CONFIG_PHY_NOTIFICATION_MAXINTFLEN.
+ * pid - Identifies the task that was receiving notifications.
+ *
+ * Returned Value:
+ * OK on success; Negated errno on failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_PHY_INTERRUPT
+int phy_notify_unsubscribe(FAR const char *intf, pid_t pid);
+#endif
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __INCLUDE_NUTTX_NET_PHY_H */